user2824073
user2824073

Reputation: 2485

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

Upvotes: 1

Views: 246

Answers (1)

Francesco Marchioni
Francesco Marchioni

Reputation: 4328

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

Upvotes: 2

Related Questions