Bug 103469 - Unable to open PDF File - "Couldn't find trailer dictionary"
Summary: Unable to open PDF File - "Couldn't find trailer dictionary"
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other Linux (All)
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-26 15:27 UTC by Nathanael D. Noblet
Modified: 2017-11-22 20:53 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
"corrupt" pdf file (23.78 KB, application/pdf)
2017-10-26 15:27 UTC, Nathanael D. Noblet
Details
Original PDF (3.79 KB, application/pdf)
2017-10-26 15:27 UTC, Nathanael D. Noblet
Details
the said patch (1.10 KB, patch)
2017-10-30 22:48 UTC, Albert Astals Cid
Details | Splinter Review
New patch (1.12 KB, patch)
2017-11-22 16:03 UTC, Albert Astals Cid
Details | Splinter Review

Description Nathanael D. Noblet 2017-10-26 15:27:11 UTC
Created attachment 135069 [details]
"corrupt" pdf file

Hello,

  I have a program that takes an input PDF ads text at three coordinates and outputs it back to a new PDF file. I can successfully do this to a number of PDFs. I have however one very simple PDF file that once edited cannot be read by evince (pdfinfo, pdftocairo and friends as well), but can by every other PDF reader I've tried.
Comment 1 Nathanael D. Noblet 2017-10-26 15:27:42 UTC
Created attachment 135070 [details]
Original PDF
Comment 2 Albert Astals Cid 2017-10-30 22:46:21 UTC
The problem is that the W field is 1 8 8, and we're only prepared for 4 bytes in the gen field.

The attached patch fixes it but also makes each entry 4 bytes bigger, i guess it's the prize we have to pay unless we want to make the size of XRefEntry somehow depend on the W field values?

Comments from anyone?
Comment 3 Albert Astals Cid 2017-10-30 22:48:05 UTC
Created attachment 135172 [details] [review]
the said patch
Comment 4 Adrian Johnson 2017-10-31 10:46:29 UTC
I think it is safe to assume that gen numbers will always fit in an int. The PDF spec says gen numbers must start at 0 and be incremented on each save so it should not be possible to get > 32-bit gen numbers without the PDF file becoming impracticably huge.

I suggest accept 8-byte fields but store it in an int and print an error if is too big. I'm confident we will never see that error reported.

But if you really want to use a 64-bit:

-  int gen;
+  Goffset gen;

use long long. Goffset is for file offsets.
Comment 5 Albert Astals Cid 2017-11-22 16:03:11 UTC
Created attachment 135666 [details] [review]
New patch

Adrian, what do you think, should i commit now?
Comment 6 Adrian Johnson 2017-11-22 19:53:12 UTC
Looks good.
Comment 7 Albert Astals Cid 2017-11-22 20:53:01 UTC
Pushed.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.