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

Merge error - Fatal: pdfcpu: name: duplicate key #676

Closed
themajashurka opened this issue Aug 21, 2023 · 7 comments
Closed

Merge error - Fatal: pdfcpu: name: duplicate key #676

themajashurka opened this issue Aug 21, 2023 · 7 comments
Assignees

Comments

@themajashurka
Copy link

I've tried to merge validated pdf-s without success with pdfcpu 0.5.0, Windows binary.
I get this error: Fatal: pdfcpu: name: duplicate key
After downgrading to 0.4.2, it happens to work.

@themajashurka
Copy link
Author

Here is the verbose output:

writing pdf/16407433543771_3802185_merged.pdf...
merging into pdf/DPD_16407433543771_1.pdf
 INFO: 2023/08/21 10:13:07 PDF Version 1.5 conforming reader
 INFO: 2023/08/21 10:13:07 validating
DEBUG: 2023/08/21 10:13:07 kmin=JR_PAGE_ANCHOR_0_1 kmax=JR_PAGE_ANCHOR_0_1
DEBUG: 2023/08/21 10:13:07 Insert k:DPD_16407433543771_1.pdf at beginning
pdf/DPD_16407433543771_2.pdf
 INFO: 2023/08/21 10:13:07 PDF Version 1.5 conforming reader
 INFO: 2023/08/21 10:13:07 validating
DEBUG: 2023/08/21 10:13:07 patchSourceObjectNumbers: ctxSource: xRefTableSize:23 trailer.Size:24 -
DEBUG: 2023/08/21 10:13:07 patchSourceObjectNumbers:   ctxDest: xRefTableSize:26 trailer.Size:27 -
DEBUG: 2023/08/21 10:13:07 patchSourceObjectNumbers end
DEBUG: 2023/08/21 10:13:07 appendSourcePageTreeToDestPageTree
DEBUG: 2023/08/21 10:13:07 appendSourcePageTreeToDestPageTree begin
DEBUG: 2023/08/21 10:13:07 Kids before: [(1 0 R)]
DEBUG: 2023/08/21 10:13:07 Kids after: [(1 0 R) (34 0 R)]
DEBUG: 2023/08/21 10:13:07 appendSourcePageTreeToDestPageTree end
DEBUG: 2023/08/21 10:13:07 appendSourceObjectsToDest
DEBUG: 2023/08/21 10:13:07 appendSourceObjectsToDest begin
DEBUG: 2023/08/21 10:13:07 adding obj 30 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 34 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 46 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 48 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 29 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 41 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 47 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 35 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 32 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 43 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 27 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 36 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 40 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 39 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 44 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 31 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 42 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 28 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 37 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 38 from src to dest
DEBUG: 2023/08/21 10:13:07 adding obj 45 from src to dest
DEBUG: 2023/08/21 10:13:07 appendSourceObjectsToDest end
DEBUG: 2023/08/21 10:13:07 kmin=DPD_16407433543771_1.pdf kmax=JR_PAGE_ANCHOR_0_1
DEBUG: 2023/08/21 10:13:07 Insert k:JR_PAGE_ANCHOR_0_1 in the middle
Fatal: pdfcpu: name: duplicate key
github.com/pdfcpu/pdfcpu/pkg/pdfcpu/model.init
        /Users/horstrutter/Documents/go/pdfcpu/pkg/pdfcpu/model/annotation.go:75
runtime.doInit1
        /usr/local/go/src/runtime/proc.go:6740
runtime.doInit
        /usr/local/go/src/runtime/proc.go:6707
runtime.main
        /usr/local/go/src/runtime/proc.go:249
runtime.goexit
        /usr/local/go/src/runtime/asm_386.s:1363```

@hhrutter
Copy link
Collaborator

Do you think you can share 2 samples to merge in order to reproduce and analyze this?
Would be a big help!
Thank you!

@themajashurka
Copy link
Author

Here is the culprit
I've tried to merge different pdf-s, but this particular causes merge to throw:
pdfcpu merge merged.pdf test.pdf test.pdf

@themajashurka
Copy link
Author

So, to not be misleading, even 0.4.2 gives an error with this test.pdf above:
unexpected panic attack: interface conversion: types.Object is nil, not types.Dict

Originally, I've tried to merge 4 different pdf-s, with 0.5.0 first (without success), but 0.4.2 succeeded.
Here are the 4 pdf-s causing problem for 0.5.0, but not for 0.4.2

@hhrutter
Copy link
Collaborator

The first one was throwing a bug and is fixed with latest commit.
Need to checkout the other 4.

@hhrutter
Copy link
Collaborator

LGTM 👍🏻

@themajashurka
Copy link
Author

themajashurka commented Aug 21, 2023

Well, this was a quick adventure! Like pdfcpu a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants