简体   繁体   English

itext7的PdfReader在Java中不起作用

[英]PdfReader of itext7 is not working in java

This is my code 这是我的代码

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

And I import pdfxfa-2.0.1.jar file in eclipse. 然后在eclipse中导入pdfxfa-2.0.1.jar文件。 But not proceed in new PdfReader . 但不要在new PdfReader And It is not caught in the catch clause and not print error. 并且它不会被catch子句捕获,并且不会显示错误。 Please help me. 请帮我。 Thank you. 谢谢。

You should try adding another more general exception to see if there is an error, ie 您应该尝试添加另一个更一般的异常,以查看是否存在错误,即

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();
}

If still the exception is not thrown, and caught by the Exception then you can blame the PdfReader . 如果仍然没有引发异常,并且被Exception捕获,那么您可以责怪PdfReader

You cannot really tell where the problem is without you showing how you're invoking methods of the reader . 如果不显示调用reader方法,就无法真正判断问题所在。 Merely assigning the reader does not mean the PdfReader is not working just because no error is thrown. 仅分配阅读器并不意味着PdfReader不能正常工作,因为没有引发任何错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM