wood burning stoves 2.0*
The moose likes Other Open Source Projects and the fly likes iText 5: PDF header signature not found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "iText 5: PDF header signature not found" Watch "iText 5: PDF header signature not found" New topic
Author

iText 5: PDF header signature not found

Singh Kuldeep
Greenhorn

Joined: Jul 18, 2012
Posts: 19
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
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
Does it work for other PDFs? Can you upload an example PDF that exhibits this somewhere, and then post a link here?


Ping & DNS - my free Android networking tools app
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: iText 5: PDF header signature not found
 
Similar Threads
Itext seeking help
exeption
Problem in merging pdf files using the itext library
itext "Exception in thread "main" java.io.FileNotFoundException: value"
how to save multiple report files??