1
我正在使用ICEPDF在我的Java应用程序中显示和打印PDF文档。ICEPDF打印问题
我得到以下异常:
org.icepdf.core.pobjects.Catalog <clinit>
INFO: ICEsoft ICEpdf Core 4.1.4
Exception in thread "Thread-4" java.lang.ArrayIndexOutOfBoundsException: 0
at org.icepdf.ri.common.PrintHelper.getSetupDialog(PrintHelper.java:526)
at org.icepdf.ri.common.PrintHelper.setupPrintService(PrintHelper.java:199)
at org.icepdf.ri.common.SwingController.initialisePrinting(SwingController.java:2590)
at org.icepdf.ri.common.SwingController.access$400(SwingController.java:102)
at org.icepdf.ri.common.SwingController$3.run(SwingController.java:2548)
at java.lang.Thread.run(Thread.java:680)
我使用的代码:
public class ViewerComponentExample {
public static void main(String[] args) {
// Get a file from the command line to open
String filePath = "boll.pdf";
// build a component controller
SwingController controller = new SwingController();
SwingViewBuilder factory = new SwingViewBuilder(controller);
JPanel viewerComponentPanel = factory.buildViewerPanel();
// add interactive mouse link annotation support via callback
controller.getDocumentViewController().setAnnotationCallback(
new org.icepdf.ri.common.MyAnnotationCallback(
controller.getDocumentViewController()));
JFrame applicationFrame = new JFrame();
applicationFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
applicationFrame.getContentPane().add(viewerComponentPanel);
// Now that the GUI is all in place, we can try openning a PDF
controller.openDocument(filePath);
// show the component
applicationFrame.pack();
applicationFrame.setVisible(true);
}
}
以上可以看出,观察者罚款,它除了允许所有的操作从印刷! (见上述例外)。
任何帮助,高度赞赏。
谢谢
您是否尝试过icepdf帮助论坛?他们通常很擅长回答问题。 – 2011-02-27 17:27:00
我对它排序。问题是我的打印机没有被设置为默认打印机! 没有“没有默认打印机”的处理,如果它不存在(即使你有打印机),icepdf抛出异常。 感谢您的帮助无论如何:) – user1265230 2011-02-27 18:47:00