• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

iText 5: PDF header signature not found

 
Singh Kuldeep
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
Hope you all are doing well.
I am trying to use iText for pdf handling. I wrote a class for reading pdf file and writing it to a text file.But is throwing an exception PDF header signature not found.
My code is

EXCEPTION:
com.itextpdf.text.exceptions.InvalidPdfException: PDF header signature not found.
at com.itextpdf.text.pdf.PRTokeniser.getHeaderOffset(PRTokeniser.java:209)
at com.itextpdf.text.pdf.PdfReader.getOffsetTokeniser(PdfReader.java:441)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:176)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:219)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:207)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:197)
at com.kd.example.pdf.MyPdfReader.main(MyPdfReader.java:21)
If anyone of you have any idea that can resolve this problem, please let me know.

Thank you
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does it work for other PDFs? Can you upload an example PDF that exhibits this somewhere, and then post a link here?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it seems it has something to do with that particular PDF - I just tested this code with some PDF file, and it worked fine.

Alternatively, you can try an API like PDFBox, which also supports text extraction, and which has a much more business-friendly license then iText 5.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic