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)
- 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
- 3 ways that the European Union is changing the way Companies write software in 2018 - January 31, 2018
- IDRsolutions product range update for 2018 - January 22, 2018
- 4 ways Companies can make remote working successful - December 21, 2017