baidu_30206235 2016-05-23 09:41 采纳率: 0%
浏览 22073

iText PDF header signature not found.

程序运行到 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.

  • 写回答

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真的坏了。

    评论

报告相同问题?