程序运行到 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无用
悬赏问题
- ¥50 汇编语言除法溢出问题
- ¥50 C++实现删除N个数据列表共有的元素
- ¥15 Visual Studio问题
- ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
- ¥20 求一个html代码,有偿
- ¥100 关于使用MATLAB中copularnd函数的问题
- ¥20 在虚拟机的pycharm上
- ¥15 jupyterthemes 设置完毕后没有效果
- ¥15 matlab图像高斯低通滤波
- ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗