[okular] [Bug 395660] okular cannot preserve annotations in some pdf files.

Tobias Deiminger bugzilla_noreply at kde.org
Thu Jun 21 22:08:06 UTC 2018


https://bugs.kde.org/show_bug.cgi?id=395660

Tobias Deiminger <haxtibal at posteo.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |haxtibal at posteo.de

--- Comment #4 from Tobias Deiminger <haxtibal at posteo.de> ---
(In reply to Albert Astals Cid from comment #3)
> It does fail on current version, would need someone to investigate why,
> probably a poppler issue
I reproduced the error with a standalone poppler application, to rule out
errors in Okular. Poppler immediatelly gave first hints about what's wrong:
"Error: Couldn't find trailer dictionary"
"Error: Invalid XRef entry"

Looking a bit deeper, it are two characteristics of 'Untitled 1.pdf' that make
poppler fail
- The document has an "XRef stream", instead of a "XRef table". XRef streams
are available since PDF 1.5 and legitimately have no "trailer" keyword.
- The first object in the XRef stream is 1 (see "17 0 obj <<... /Index [1 17]
...>>", instead of 0. 

The start-at-1 thing causes XRef::entries[0].type = xrefEntryNone (see
initialization in XRef::resize).

Then, upon document save, PDFDoc::saveIncrementalUpdate iterates over entires
ranging from 0 to (getNumObjects-1). Accessing entries[0] where type ==
xrefEntryNone causes poppler to think this is a damaged file and it tries to
reconstruct the xref table with XRef::constructXRef. Now XRef::constructXRef
wants a "trailer" keyword. But there is no "trailer" keyword in the file
(that's not an error because we've got a PDF 1.5 XRef stream). But
XRef::constructXRef can't work without, and bails out with error.

I believe there are two things to fix in poppler:
- XRef::constructXRef should support PDF 1.5 XRef streams without trailer
dictionary.
- First object number > 0 doesn't indicate a damaged file, but it's valid (am
unsure about this). No need to reconstruct XRef at all. Actually, everything
works fine if I trick poppler to start iteration at 1 in saveIncrementalUpdate.

There's no problem with the second document 'Untitled 2.pdf', because it uses
XRef table with trailer dictionary and has objects 0..22.

Albert, does this sound reasonable? This was my first play on XRef, so the
observation my be somewhat wrong. Anyway, we should open a bug at poppler.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Okular-devel mailing list