2016-04-12 9 views
-1

既存のJava(SWT)アプリケーションでPDFファイルを開きたいと思います。 PDFは外部フレームで開くべきではありません。私はOLEインターフェイスを使ってみましたが、成功しませんでした。JavaでAdobe Acrobatを使用したOLE(SWTプロジェクト)

clientSite = new OleControlSite(frame, SWT.NONE, "AcroExch.App", fileName); automation = new OleAutomation(clientSite); clientSite.doVerb(OLE.OLEIVERB_OPEN);

答えて

1

uはAdobeが

try{ 

    if ((new File("c:\\your_file.pdf")).exists()) { 

    Process p = Runtime 
     .getRuntime() 
     .exec("rundll32 url.dll,FileProtocolHandler c:\\your_file.pdf"); 
    p.waitFor(); 

} else { 

    System.out.println("File does not exist"); 

} 

} catch (Exception ex) { 
ex.printStackTrace(); 
} 
+0

[OK]を、この作品のおかげで下に従って使用してPDFファイルを開きたい場合は、この

try { File pdfFile = new File("c:\\stack-overflow.pdf"); if (pdfFile.exists()) { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().open(pdfFile); } else { System.out.println("Awt Desktop is not supported!"); } } else { System.out.println("File is not exists!"); } System.out.println("Done"); } catch (Exception ex) { ex.printStackTrace(); } 

//を試みることができます。しかし、既存のJavaアプリケーションウィンドウでファイルを開くにはどうすればよいですか? (上記のような外部ウィンドウにはありません) – San

+0

ここからipedalを使用することができます。https://www.idrsolutions.com/jpedal/downloads/trial –

+0

http://files.idrsolutions.com/samplecode/org/jpedal/examples/あなたに役立つ場合は、/ SilentPrint.java.htmlの回答を受け入れてください。 –

関連する問題