程序运行到 PdfReader reader = new PdfReader("D:\createSamplePDF.pdf");
PdfStamper stamp = new PdfStamper(reader, new FileOutputStream("D:\createSamplePDF.pdf"));报错
Exception in thread "main" com.itextpdf.text.exceptions.InvalidPdfException: PDF header signature not found.
iText PDF header signature not found.
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
3条回答 默认 最新
qq_27443123 2020-12-18 16:10关注如上所说 这个pdf文件有问题:
尝试用1L的方法解决 但是不会,汗。
PDF header signature not found。找不到签名头。那么我给他加头就行了
//标题 document.addTitle("this is a title"); //作者 document.addAuthor("tt"); //主题 document.addSubject("subject"); //关键字 document.addKeywords("Keywords"); //创建时间 document.addCreationDate(); //应用程序 document.addCreator("tt");当我加了这些代码后就可以了。这时会出现一个其他的错误 说没有page。
那么我们给加一个空白页久ok了。
document.newPage(); writer.setPageEmpty(false);
总结 : 只针对于iText 创建出来的文档进行这样的设置久可以了,如果不是iText 创建的,那么你的PDF真的坏了。
评论 打赏 举报解决 2无用