2016-04-12 52 views
-1

Mevcut bir Java (SWT) -Uygulamasında bir PDF Dosyası açmak istiyorum. PDF harici bir çerçevede açılmamalıdır. OLE arayüzü üzerinden denedim ama başarılı olamadım.OLE, Adobe Acrobat in Java ile (SWT Projesi)

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

cevap

1

Sen deneyebilirsiniz bu

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(); 
    } 

// u kerpiç Tamam

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

aşağıda izleyin bu işleri sayesinde kullanarak pdf açmak istiyorum. Ancak dosyayı mevcut Java Uygulama Penceresinde nasıl açabilirim? (yukarıdaki gibi harici bir pencerede değil) – San

+0

ipedal'i buradan kullanabilirsiniz https://www.idrsolutions.com/jpedal/downloads/trial –

+0

http://files.idrsolutions.com/samplecode/org/jpedal/examples/ yazdırma/SilentPrint.java.html size yardımcı olup olmadığını yanıt kabul edin. –