这是我的代码

import com.itextpdf.kernel.pdf.PdfReader;
...
...
try{
   PdfReader reader = new PdfReader("C:/Users/Warrior/Documents/1.pdf");
}catch(IOException e){
   e.printStackTree();
}


然后在eclipse中导入pdfxfa-2.0.1.jar文件。
但不要在new PdfReader中继续。
并且它不会被catch子句捕获,并且不会显示错误。
请帮我。
谢谢。

最佳答案

您应该尝试添加另一个更一般的异常,以查看是否存在错误,即

try{
   PdfReader reader = new PdfReader("..."); // The path to your pdf document
   // What do you want to achieve with the PdfReader instance here?
   // Do some action with your reader. You don't need to assign without using it
   // to see what is happening.
} catch(IOException e){
   e.printStackTrace();
} catch(Exception ex) {
   ex.printStackTrace();
}


如果仍然没有引发异常,并且被Exception捕获,则可以怪罪PdfReader

如果不显示如何调用reader的方法,就无法真正判断问题出在哪里。仅分配阅读器并不意味着PdfReader不能正常工作,仅仅是因为没有引发任何错误。

08-03 22:11
查看更多