PyPDF2, merge.append(...) problem - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: PyPDF2, merge.append(...) problem (/thread-610.html) |
PyPDF2, merge.append(...) problem - peterkl - Oct-23-2016 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 : 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 : I'm using py2.7 on linux
RE: PyPDF2, merge.append(...) problem - peterkl - Oct-23-2016 Just found that the script is actually working with other PDF files, the problem was then in the PDF File, even so I do not understand why, because it has content on its pages and it's not corrupted. |