Invalidpdfexception pdf header signature not found

后端 未结 1 1963
盖世英雄少女心
盖世英雄少女心 2020-12-01 22:32

I have some code that reads pdf files. The code fails at the line :

iTextSharp.text.pdf.PRTokeniser.CheckPdfHeader() at
                             


        
相关标签:
1条回答
  • 2020-12-01 23:05

    If a file doesn't start with %PDF- then there's nothing to fix: the file isn't a PDF file.

    However, there may be another problem: maybe you're trying to access a file that has zero length due to some problem while creating the InputStream. Another context in which I've seen this happen, is a PDF loaded from a server, where the server returned a 404 message in HTML instead of a PDF file ;-)

    Whenever that exception happens, you should store the bytes somewhere, and examine them. Without those bytes, nobody will be able to give you useful advice.

    0 讨论(0)
提交回复
热议问题