我发现使用 iText 可以创建交互式 PDF 表单( http://itextpdf.com/book/chapter.php?id=8 )。这很有趣,我想知道是否可以从 Java 桌面应用程序内部填写 PDF 表单。
最后,我需要知道是否可以从 Java 应用程序中打开 PDF 文件。可能吗 ?
谢谢
最佳答案
您可以考虑使用ICEPDF有开源版和专业版。以下示例取自文档,展示了如何在 JPanel 中显示 PDF:
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);
关于java - 使用 PDF 表单作为 Java UI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26786499/