简体   繁体   中英

Use PDF Forms as Java UI


I have seen that using iText it's possible to create interactive PDF forms( http://itextpdf.com/book/chapter.php?id=8 ). That's quite interesting, I wonder if it's possible to fillup the PDF form from inside a Java Desktop application. In the end, I'd need to know if it's possible to open a PDF file from within a Java application. Would it be possible ?
Thanks

You can consider using ICEPDF which is available in OpenSource edition and Pro edition. The following example, taken from the documentation shows how to display a PDF in a JPanel:

String filePath = "somefilepath/myfile.pdf";

// build a controller
SwingController controller = new SwingController();

// Build a SwingViewFactory configured with the controller
SwingViewBuilder factory = new SwingViewBuilder(controller);

// Use the factory to build a JPanel that is pre-configured
//with a complete, active Viewer UI.
JPanel viewerComponentPanel = factory.buildViewerPanel();

// add copy keyboard command
ComponentKeyBinding.install(controller, viewerComponentPanel);

// add interactive mouse link annotation support via callback
controller.getDocumentViewController().setAnnotationCallback(
      new org.icepdf.ri.common.MyAnnotationCallback(
             controller.getDocumentViewController()));

// Create a JFrame to display the panel in
JFrame window = new JFrame("Using the Viewer Component");
window.getContentPane().add(viewerComponentPanel);
window.pack();
window.setVisible(true);

// Open a PDF document to view
controller.openDocument(filePath);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM