-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
PdfReadError: Multiple definitions in dictionary at byte 0x30b for key /Type #244
Comments
+1. Same here but pdf = PdfFileReader(fobj, strict=False) Solve this problem. https://github.com/mstamy2/PyPDF2/blob/0900101f836345723f8ab4086bf77da32de8fc38/PyPDF2/pdf.py#L1048 |
For me, @lambdalisue's solution didn't work. I instead had to do:
|
Could someone clarify this if this is a "bug" or not? I ran into this when using stapler, but don't know how to view what's going on. For example:
I'm just trying to understand what to do about the errors, if there are unintended side effects, if this will be "fixed" at some point... for what it's worth, before figuring out I could use |
+1 for having this issue and fixed by |
+1 |
Thanks for the tip; it worked! |
+1. I used the provided example in Sample_Code/basic_merging.py, and then pared it down to two PDF files which were each just called with append(fileobj), and it still didn't work. The workaround of PdfFileMerger(strict=False) solves the problem (modulo a bunch of warning messages). It would help to have the basic_merging example mention strict=False since it looks like that's needed for many (maybe all?) real-world PDF files. |
I tripped over this. If its all the same to the outcomes then it would be good if this fix was the default. |
Thanks! |
Hello, |
A PDF file is a (constrained) PostScript program. The error (or warning) means that the program attempted to redefine an internal dictionary variable. The fact that this often happens while merging would suggest that both the merged documents wanted to use the same variable name, resulting in this conflict when you combine them. There isn't really anything you can do (especially on the Python side) to reconcile this in a document which somebody else created. |
from autocad as described: py-pdf/pypdf#244
Through i add the param 'strict', it still print "Multiple definitions in dictionary at byte 0x51d16 for key /MediaBox", and some txt may messy code, how can i solve it? |
a) Strict shall be set you should open a new issue providing those details |
When attempting to merge multiple PDF documents, the merger.write("foo.pdf") line chokes with the error shown in the title... I was attempting to merge a few files with the following:
The output is as follows:
The text was updated successfully, but these errors were encountered: