Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - cross reference table and byte offset
  FAQ FAQ  Forum Search   Register Register  Login Login


Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

cross reference table and byte offset

 Post Reply Post Reply
Author
Leon View Drop Down
New Member
New Member


Joined: 15 Jul 2017
Location: United States
Points: 2
Post Options Post Options   Quote Leon Quote  Post ReplyReply Direct Link To This Post Topic: cross reference table and byte offset
    Posted: 15 Jul 2017 at 6:55pm
I have got a sample PDF from the Internet, the content is listed below.

%PDF-1.7
1 0 obj
<<
 /Type /Catalog
 /Outlines 2 0 R 
 /Pages 3 0 R
>>
endobj
2 0 obj
<<
 /Type /Outlines 
 /Count 0
>>
endobj
3 0 obj
<<
 /Type /Pages
 /Kids [4 0 R]
 /Count 1
>>
endobj
4 0 obj
<<
 /Type /Page %
 /Parent 3 0 R
 /MediaBox [0 0 612 792]
 /Contents 5 0 R
 /Resources
 << /ProcSet 6 0 R
    /Font << /F1 7 0 R >>
 >>
>>
endobj
5 0 obj
<< /Length 48 >>
stream
BT
/F1 24 Tf
100 700 Td
(Hello World)Tj
ET
endstream
endobj
6 0 obj
[/PDF /Text]
endobj
7 0 obj
<<
 /Type /Font
 /Subtype /Type1
 /Name /F1
 /BaseFont /Helvetica
 /Encoding /MacRomanEncoding
>>
endobj
xref
0 8
0000000000 65535 f
0000000012 00000 n
0000000089 00000 n
0000000145 00000 n
0000000214 00000 n
0000000381 00000 n
0000000485 00000 n
0000000518 00000 n
trailer
<<
 /Size 8
 /Root 1 0 R
>>
startxref
642
%%EOF

Adobe Reader DC can open the document without any problem but it asks if I want to save the document when I close it without making any changes. By searching online I realized that the source of the problem is the cross reference table. More precisely the byte offsets of all objects as well as that for xref itself are wrong. I used a Hex edit to find correct byte offsets and corrected them, and the problem is gone.
But my question is, if xref is to be used to locate the objects in byte stream, the above PDF will certainly lead to the wrong places. It looks to me that Adobe Reader does not rely on xref since it opens the above PDF without any problem. But if that is the case, what is the use of xref?

I appreciate any any input.      
Back to Top
Sponsored Links


Back to Top
BAlheit View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 1088
Post Options Post Options   Quote BAlheit Quote  Post ReplyReply Direct Link To This Post Posted: 16 Jul 2017 at 8:27am
Acrobat Reader uses the xref table. In your case Acrobat Reader repairs the offsets.
Back to Top
Leon View Drop Down
New Member
New Member


Joined: 15 Jul 2017
Location: United States
Points: 2
Post Options Post Options   Quote Leon Quote  Post ReplyReply Direct Link To This Post Posted: 16 Jul 2017 at 2:08pm
Thank you very much for your reply.

In order for Acrobat reader to do that (to repair wrong offsets), it must not rely on xref but search objects directly from the document. Again, back to my question, if everyone (including Adobe) has to search object directly, what is the use of xref?

Back to Top
BAlheit View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 1088
Post Options Post Options   Quote BAlheit Quote  Post ReplyReply Direct Link To This Post Posted: 17 Jul 2017 at 7:04am
Originally posted by Leon Leon wrote:

... In order for Acrobat reader to do that (to repair wrong offsets), it must not rely on xref but search objects directly from the document. ...
Acrobat Reader uses the xref table! When there is a small difference between xref offset and correct offset Acrobat Reader will correct the value.
Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4067
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: Yesterday at 12:09am
If the table is correct and matches the file size, then no correction is needed. But if the table appears wrong then both Acrobat and Reader will attempt to repair the table.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.09
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.027 seconds.