java - 使用 PDF 表单作为 Java UI

标签 java swing itext


我发现使用 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/

相关文章:

java - 带有文本框和按钮的选项面板

java - 在java中显示图像

c# - 使用 iTextSharp c# 从 PDF 中逐行提取文本

java - 超越 Java 中的 Integer.MAX_VALUE 约束

java - 老年代对象的统计?

java - 如何在bin文件的字节数组[]中搜索字节序列?

pdf - iTextSharp 4.1.6和5.x版本之间的区别

java - 从下面的页面中提取段落的正则表达式

java - 如何禁用内联 p :calendar (primefaces)

java - 如何将 Spring Boot 项目连接到 SonarQube