A PDF file contains a couple of key pointers. One of them is a pointer to the start of the table which describes the structure of the PDF file. By convention, this is needs to be located in the last 1024 bytes of the PDF file. So the error is that this cannot be found. The common reasons for this are:-
1. The PDF file is corrupt. Does it open in Adobe Acrobat? You are streaming it as a byte stream?
2. The file is being read into a stream and the end bytes have not been read properly. Do you flush and close the stream?
3. The PDF is being read into a fixed buffer which is larger than the file and there is empty space at the end.
4. The is something odd in the PDF file and we need to tweak our parser. The PDF spec is not strictly enforced so Adobe Acrobat will often open files which do not meet the spec. We need to figure it out.
If you are streaming the PDF files a useful sanity check is to write the data back to a file and see if it still opens.
Are there any cryptic PDF messages you would like us to explain?
This post is part of our “Understanding the PDF File Format” series. In each article, we discuss a PDF feature, bug, gotcha or tip. If you wish to learn more about PDF, we have 13 years worth of PDF knowledge and tips, so click here to visit our series index!
Latest posts by Mark Stephens (see all)
- Introducing the new XFA Parser in FormVu - May 16, 2018
- Moving to JPedal release 8 - May 2, 2018
- Which version of Java SE should I use? - April 25, 2018
- How we are improving our code quality with IDEA in 2018 - March 7, 2018
- How we are improving our code quality with NetBeans in 2018 - March 1, 2018