我正在使用java制作PDF阅读器,我想在自己的应用程序的JFrame中打开PDF文件,以便我可以创建自己的功能。有没有办法做到这一点? 我正在使用" iText"," pdfBox"和" ICEpdf"操纵PDF文档。
答案 0 :(得分:2)
public static void pdfViewerICE() {
String filePath = "PDF_URL";
// build a controller
controller = new SwingController();
// Build a SwingViewFactory configured with the controller
SwingViewBuilder factory = new SwingViewBuilder(controller);
PropertiesManager properties = new PropertiesManager(
System.getProperties(),
ResourceBundle.getBundle(PropertiesManager.DEFAULT_MESSAGE_BUNDLE));
properties.set(PropertiesManager.PROPERTY_DEFAULT_ZOOM_LEVEL, "1.75");
// Use the factory to build a JPanel that is pre-configured
//with a complete, active Viewer UI.
JPanel viewerComponentPanel = factory.buildViewerPanel();
controller.openDocument(filePath);
}
上面的代码通过您的java程序使用ICEPDF打开PDF。 注意:在类路径http://www.icesoft.org/java/downloads/icepdf-downloads.jsf中包含ICEPDF jar(icepdf-viewer.jar,icepdf-core.jar)