Open edi-w opened 3 years ago
Hi, I'm currently preparing a new version in a fork. It seems to work for me
Can you give me your feed back with my proposed version ?(not yet released but attached in here)
pypdf4-1.27.0PPzz_1-py2.py3-none-any.whl.zip
thanks,
Hi,
I tried that but get this:
merger.append(filepath)
File "C:\Users*\AppData\Local\Programs\Python\Python37\lib\site-packages\pypdf\merger.py", line 146, in append self.merge(None, fileobj, bookmark, pages, import_bookmarks) File "C:\Users*\AppData\Local\Programs\Python\Python37\lib\site-packages\pypdf\merger.py", line 116, in merge self._copy_bookmarks(fileobj.root_object["/Outlines"], bkmark, srcpages) File "C:\Users*\AppData\Local\Programs\Python\Python37\lib\site-packages\pypdf\merger.py", line 171, in _copy_bookmarks self._copybookmarks(cur, bkmark1, srcpages) File "C:\Users*\AppData\Local\Programs\Python\Python37\lib\site-packages\pypdf\merger.py", line 171, in _copy_bookmarks self._copybookmarks(cur, bkmark1, srcpages) File "C:\Users*\AppData\Local\Programs\Python\Python37\lib\site-packages\pypdf\merger.py", line 171, in _copy_bookmarks self._copybookmarks(cur, bkmark1, srcpages) File "C:\Users*\AppData\Local\Programs\Python\Python37\lib\site-packages\pypdf\merger.py", line 160, in _copy_bookmarks if Destination("", node).pageref.idnum in srcpages: File "C:\Users*\AppData\Local\Programs\Python\Python37\lib\site-packages\pypdf\generic.py", line 2205, in init pdf.get_named_destinations()[page_or_dest_or_array].get_dest_array() UnboundLocalError: local variable 'pdf' referenced before assignment
I've just made a test similar to yours successfully. Your trouble may be linked with the content of your pdf file. Is it possible to have a copy? Thks
Thanks, I tried and it worked as expected with those files. However, if I append the attached file, I get the following error:
Traceback (most recent call last):
File "pdflistmerge.py", line 13, in
Hi Edi-w, I have to appologize, I've seen your problem just after posting the message, that's why I deleted it. This should work now: pypdf4-1.27.0PPzz_1-py2.py3-none-any.whl.zip
Hi, as far as I can tell, that seems to be working exactly as expected. Thanks!
When merging pdf files, the bookmarks from sourcefiles are inherited correctly but they don't point to any page. Also bookmarks that are created while appending files to the merger don't have a destination. I'm using python 3.7.6.
Example:
merger = PdfFileMerger()
merger.append(PdfFileReader(filepath,'rb'),bookmark='test',pages=None,import_bookmarks=True)
merger.write(open(outfile, 'wb'))