Closed gtache closed 9 months ago
Thanks for finding this. As you noticed the issue only shows up after a second incremental save. This is an error in the code as xref streams offset is set by the dictionary value. The offset - XREF_MARKER.length is a throwback parsing an xref table where the parser has already moved passed XREF and needs to be adjusted.
The method parseCrossReferenceStream substracts XREF_MARKER.length from the offset
which makes sense for uncompressed xrefs starting with "xref", but this method is (probably?) only called for compressed xrefs like
where the starting position is the exact one indicated by startxref. This causes problems with incremental updates where the new trailer references the previous one with a wrong position and the pdf is therefore corrupted.
This change was made for GH-291, so I guess there was a reason for it though.