Skip to content

Commit

Permalink
BUG: Add overwriteWarnings parameter PdfFileMerger (#243)
Browse files Browse the repository at this point in the history
This helps users who run into issue #67
  • Loading branch information
andrecp committed Apr 16, 2022
1 parent c138f21 commit bf3c9c9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions PyPDF2/merger.py
Expand Up @@ -67,16 +67,20 @@ class PdfFileMerger(object):
:param bool strict: Determines whether user should be warned of all
problems and also causes some correctable problems to be fatal.
Defaults to ``True``.
:param bool overwriteWarnings: Determines whether to override Python's
``warnings.py`` module with a custom implementation (defaults to
``True``).
"""

def __init__(self, strict=True):
def __init__(self, strict=True, overwriteWarnings=True):
self.inputs = []
self.pages = []
self.output = PdfFileWriter()
self.bookmarks = []
self.named_dests = []
self.id_count = 0
self.strict = strict
self.overwriteWarnings = overwriteWarnings

def merge(self, position, fileobj, bookmark=None, pages=None, import_bookmarks=True):
"""
Expand Down Expand Up @@ -132,7 +136,7 @@ def merge(self, position, fileobj, bookmark=None, pages=None, import_bookmarks=T

# Create a new PdfFileReader instance using the stream
# (either file or BytesIO or StringIO) created above
pdfr = PdfFileReader(fileobj, strict=self.strict)
pdfr = PdfFileReader(fileobj, strict=self.strict, overwriteWarnings=self.overwriteWarnings)
if decryption_key is not None:
pdfr._decryption_key = decryption_key

Expand Down

0 comments on commit bf3c9c9

Please sign in to comment.