Skip to content

Commit

Permalink
adapted code to the latest version of PyPDF2 (>3.0.0)
Browse files Browse the repository at this point in the history
- updated some PyPDF2 2.x constructions that were missed, they were detected by pylint
  • Loading branch information
g-raffy committed Nov 8, 2023
1 parent f9fe46a commit fe9b5ad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/pymusco/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import abc
# sudo port install py27-pypdf2
import PyPDF2
# from PyPDF2 import PdfFileMerger, PdfReader
from PIL import Image
import json

Expand Down
6 changes: 3 additions & 3 deletions src/pymusco/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,12 @@ def add_bookmarks(pdf_in_filename, bookmarks_tree, pdf_out_filename=None):
[2] http://stackoverflow.com/questions/18855907/adding-bookmarks-using-pypdf2
[3] http://stackoverflow.com/questions/3009935/looking-for-a-good-python-tree-data-structure
"""
pdf_out = PyPDF2.PdfFileMerger()
pdf_out = PyPDF2.PdfMerger()

# read `pdf_in` into `pdf_out`, using PyPDF2.PdfFileMerger()
# read `pdf_in` into `pdf_out`, using PyPDF2.PdfMerger()
# with open(pdf_in_filename, 'rb') as inputStream:
inputStream = open(pdf_in_filename, 'rb')
pdf_out.append(inputStream, import_bookmarks=False)
pdf_out.append(inputStream, import_outline=False)

# copy/preserve existing metainfo
pdf_in = PyPDF2.PdfReader(pdf_in_filename)
Expand Down

0 comments on commit fe9b5ad

Please sign in to comment.