Oct-23-2016, 08:31 AM
Greetings everyone,
I was developing a program to add Metadata to several PDF Files I have using PyPDF2, more specifically with the PdfFileMerger module. when I try to append the pdf file to the PdfFileMerger instance so I can add metadata and write to a new file, I got an error. Have a look at the code below :
I was developing a program to add Metadata to several PDF Files I have using PyPDF2, more specifically with the PdfFileMerger module. when I try to append the pdf file to the PdfFileMerger instance so I can add metadata and write to a new file, I got an error. Have a look at the code below :
from PyPDF2 import PdfFileMerger pdffile = open('Weather2015-2016.pdf','rb') pdfmerge = PdfFileMerger() pdfmerge.append(pdffile) #Already tried to add additional parameters :( bookmark=None, pages=None, import_bookmarks=True) , still not working pdfmerge.addMetadata({'/Title':'Weather Conditions'}) pdffilefinal = open('New_Weather_Conditions.pdf','wb') pdfmerge.write(pdffilefinal) pdffile.close() pdffilefinal.close()Here's the Traceback :
Error:Traceback (most recent call last):
File "PDF_Metadata_change.py", line 5, in <module>
pdfmerge.append(pdffile)
File "build/bdist.linux-i686/egg/PyPDF2/merger.py", line 203, in append
File "build/bdist.linux-i686/egg/PyPDF2/merger.py", line 151, in merge
File "build/bdist.linux-i686/egg/PyPDF2/pdf.py", line 1362, in getOutlines
File "build/bdist.linux-i686/egg/PyPDF2/pdf.py", line 1444, in _buildOutline
File "build/bdist.linux-i686/egg/PyPDF2/pdf.py", line 1425, in _buildDestination
File "build/bdist.linux-i686/egg/PyPDF2/generic.py", line 1059, in __init__
ValueError: need more than 0 values to unpack
I'm using py2.7 on linux