I'm trying to build a PDF reader in PHP, but I'm running into issues getting the offsets from the xref stream.
I'm using: http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/p df/pdfs/PDF32000_2008.pdf as my PDF
It has two xref streams, one at 116 and the second at 8983958. Based on reading the spec, I believe I should process the one at 8983958 first.
After gzinflate()ing it, I have a stream of data that starts with the following values:
HEX: 2 1 0 0 10 0 2 0 0 27 ec 0 2 0 0 1 f4 0
DEC: 2 1 0 0 16 0 2 0 0 39 236 0 2 0 0 1 244 0
That's great, I break it into rows of 6, strip the predictor function byte, which is 2, and I get the following:
1 0 0 16 0
0 0 39 236 0
0 0 1 244 0
So far, so good. The first offset is 16, which is the location of the first object.
The next offset, located by using a hex editor, appears to be at 116. However, no matter what I do, there doesn't be anyway to take 39236 and turn it into 116, using PNG Filter UP or otherwise.
Is there a very simple step I am completely missing? I feel like I've been going in circles for the past few days and I would greatly appriciate any assistance you could offer. Thank you.