Multiple definitions in dictionary error message
Brought to you by:
logari81
Hi,
When trying to combine a number of PDF documents and save, I get an error message saying "multiple definitions in dictionary". I've used pdfshuffler for a number of years and I've never seen this issue. I'm running on Ubuntu 14.04 64, which has version 0.6.0 by default.
Any ideas what could be causing this?
Thanks
Paul
Could you run pdfshuffler in a terminal and post here the whole output of the program when the error occurs?
I was running in a terminal. There were no error messages. The above mentioned message came up as a message in a window.
A bit of digging around I see this problem was found previously:
https://bugzilla.redhat.com/show_bug.cgi?id=728320
And it seems to be a problem with pyPdf. A solution to fix it is shown here:
https://bugs.launchpad.net/pypdf/+bug/242755
yes, I assumed this would be a pypdf issue, since pypdf is quite unmaintained.
In the yet to be released version 0.7 of pdfshuffler:
http://svn.gna.org/viewcvs/pdfshuffler/trunk/
the program will by default try to use pypdf2 if it is installed on your system.
It would be interesting to see if the bug you are experiencing also occurs with pypdf2 or not.
Unfortunately pypdf2 is not in the standard repositories. I could install it manually...
Will look forward to seeing 0.7 in the future.
Out of interest would the poppler library work instead of pypdf, I think it's quite active?
pypdf2 is available in debian, so maybe you can use a package from debian.
In any case if you want to test pypdf2 you have to replace the line
in pdfshuffler.py, with:
Regarding poppler, it is already used in pdfshuffler but its function is to render pdf files, not to manipulate them.
PyPDF2 is available as python-pypdf2 on Ubuntu 15.04.
I tried the manual change to pdfshuffler.py described above. The problem was not solved but the error message is now "Multiple definitions in dictionary at byte 0x306 for key /Type".
Mint 17.1 x64 || Linux 3.13.0-37-generic || gcc 4.8.2 || pyPdf 1.13-1
Within the file /usr/share/pyshared/pyPdf/generic.py, at lines 523-526:
FROM:
TO:
Indentation before "data[key] = value" is required, otherwise you get "IndentationError: expected an indented block".
Last edit: lawn owner 2015-08-20
Thanks, that worked for me too on Fedora 23.
I'm on Mint 18, using python 2.7.11, pyPdf 1.13-3. If you cannot find the file /usr/share/pyshared/pyPdf/generic.py, try to search in /usr/lib/python2.7/dist-packages/pyPdf/generic.py same line number.
Today I've got the same problem. Try to run on terminal and got no messages. I'm under ubuntu 16.04.
Some pdfs it processes ok; others not. Unfortunetly I can't send these files because they have private information.
Update: I've applied these patch suggested above and it seems fix the bugs . In my station (ubuntu 16.04) I've followed these steps
1) edit the file with sudo privileges: sudo vi /usr/lib/python2.7/dist-packages/pyPdf/generic.py
2) go to line 523.
3) fix the code at this way:
Last edit: gwarah 2017-02-07
Using pdfshuffler 0.6.0 at least once per month under Ubuntu 16.10 for 4 pages dcuments, I never encountered this bug
my pdfshuffler is also 0.6.0 but my ubuntu is 16.04. So, please, could you try to join these 2 pdf that cause the program fail and post the results?
please, run by a terminal and post the messages here, too.
Tks a lot.
Last edit: gwarah 2017-02-05
see an important update in my last post above. It seems it's a bug.
Here is a one-liner to fix the bug.
(For the directory, put your location of the generic.py file. This script also creates a backup generic.py.bak, in case you want to get back to previous bugged state for whatever reason.)
In terminal, copy and paste this and don't forget to change your directory, because it is different in some distros!! Do a search for pyPdf and you will find the directory of generic.py
As far as I heard, this has been fixed in later Python versions, but Ubuntu keeps using the old 2.7 version, which works otherwise fine, if not counting for this peculiarity.
Last edit: DoodleDude 2018-01-15
Experianced the same issue with pdfshuffler on chromebook with debian stretch in crostini
Operating System: Debian GNU/Linux 9 (stretch)
Kernel: Linux 4.19.26-03278-g71dc68f9c9d0
Architecture: x86-64
python-pypdf2 1.26.0-2
pdfshuffler 0.6.0-8
I commented out similar lines in /usr/lib/python2.7/dist-packages/PyPDF2/generic.py which seems to have resolved the issue.