Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dictionary::extend does not merge sub dictionaries #120

Closed
drahnr opened this issue Oct 16, 2020 · 1 comment · Fixed by #322
Closed

Dictionary::extend does not merge sub dictionaries #120

drahnr opened this issue Oct 16, 2020 · 1 comment · Fixed by #322

Comments

@drahnr
Copy link

drahnr commented Oct 16, 2020

Attempting to impl DCTDecode support uncovered an issue with Dictionary::extend which does not merge sub dictionaries recursively as anticipated.

@raimundomartins
Copy link

raimundomartins commented Jan 5, 2021

I also expected it to merge the 2 dictionaries. But when extending these two:

<</Type /Page/Resources [1 0 R 2 0 R]/XObject <</X1 1 0 R>>>>
<</Type /Page/Resources 3 0 R/XObject <</X2 2 0 R>>>>

I obtain
<</Type /Page/Resources [3 0 R [1 0 R 2 0 R]]/XObject <</X2 2 0 R>>>>
when I expected
<</Type /Page/Resources [3 0 R 1 0 R 2 0 R]/XObject <</X2 2 0 R/X1 1 0 R>>>>
Besides the missing X1, the array is not properly extended. This has an impact on the example PDF merging code if merging 3 PDFs. Notice that if I swap the merging order, I instead obtain:
<</Type /Pages/Resources [3 0 R 1 0 R 2 0 R]/XObject <</X1 1 0 R>>>>
The array now merges correctly, but X2 is still missing.

EDIT: Actually, I implemented code that does what I expected and was surprised (for 1sec) to see the outcome was
<</Type [/Pages /Pages]/Resources [1 0 R 2 0 R 3 0 R]/XObject <</X1 1 0 R/X2 2 0 R>>>>
So this might not be such a trivial matter after all. Maybe all I need is to check that the value is the same and not make an array in such a case, but it could have other consequences.

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 a pull request may close this issue.

2 participants