Skip to content

Conversation

@radarhere
Copy link
Member

Resolves #7084

The issue attempts to append an image to a PDF, but Pillow raises an error, "xref entry duplicated (and not identical)". This error was added in #2965 with the rest of the PDF appending functionality.

Reading https://blog.idrsolutions.com/what-are-pdf-xref-tables/ to learn more about xref tables, I found

it is possible for a PDF file to contain several xref tables and the later values are used.

And indeed, skipping past the duplicate value fixes the issue. We're already using the later value, because Pillow is reading the trailers in reverse order.

I created the test image using Pillow, modified the xref tables so that there is a duplicate entry with a different value, and then asserted that the later value, 1197, is used rather than the earlier value, 1196.

@hugovk hugovk merged commit 380a927 into python-pillow:main Apr 29, 2023
@radarhere radarhere deleted the xref_table branch April 29, 2023 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PIL.PdfParser.PdfFormatError: xref entry duplicated (and not identical)

2 participants