Closed DilumAluthge closed 3 years ago
@DilumAluthge what you call as identical PDF files are differentiated by the scheme you mentioned in your post on discourse recently. Sorry, I am presuming you are the same person.
I will not be surprised PDFs generated by your code will have wrong cross references and are corrupt from a PDF specification standpoint. While PDFIO has been made lenient at places to accommodate the PDFs generated by some well known creators but generally I am not in favor of supporting any file that has been tampered with and inconsistent with the PDF specifications.
Actually, I still get this error even without running the code in my Discourse comment.
If bar.pdf
has this:
1 0 obj
<</Type /Catalog /Pages 3 0 R
>>
endobj
And foo.pdf
has this:
1 0 obj
<</Type /Catalog
/Pages 3 0 R
>>
endobj
And there are no other differences between the files, then PDFIO can load bar.pdf but not foo.pdf.
This should be legal, right? You are allowed to add whitespace inside a dictionary? At least, that's what it says here: https://www.oreilly.com/library/view/developing-with-pdf/9781449327903/ch01.html#example_1-6
Also, this works:
1 0 obj
<</Type /Catalog /Pages 3 0 R
>>
endobj
But this errors:
1 0 obj
<</Type /Catalog /Pages 3 0 R>>
endobj
And again, the example here seems to imply that you are allowed to strip out the whitespace inside a dictionary.
Ensure you have fixed the cross reference tables and/or dictionaries after you add the any whitespaces. The same chapter tells you how to update the cross reference tables. PDF objects are located based on the object offsets from cross reference tables.
Thanks!
Does PDFIO have any functionality for generating the cross-reference table? Or do I need to do it manually?
I.e. is there a function that would parse the entire PDF file, make a list of all the indirect objects, and output the table?
Thanks for all of your help, both here and on Discourse! As you can tell, I am very new to working with PDF files.
I have two almost identical files, foo.pdf and bar.pdf. I can open them both in a PDF viewer.
I cannot open bar.pdf in PDFIO.jl, but I can open foo.pdf in PDFIO.jl. See the log below.
I can't share the PDF files publicly, but I'd be happy to email them to you if you like.
I am on the
master
branch of PDFIO.jl, i.e. I installed it with] add PDFIO#master
.And the PDFIO.jl tests pass for me.