From f4f74c7c9415dc96333cf6fd712868edf7fcff33 Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Sat, 9 Jul 2022 10:43:52 +0200 Subject: [PATCH] BUG: Column default for CCITTFaxDecode (#1079) --- PyPDF2/filters.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/PyPDF2/filters.py b/PyPDF2/filters.py index 077143813..a7fbb415a 100644 --- a/PyPDF2/filters.py +++ b/PyPDF2/filters.py @@ -409,8 +409,9 @@ class CCITTFaxDecode: def _get_parameters( parameters: Union[None, ArrayObject, DictionaryObject], rows: int ) -> CCITParameters: + # TABLE 3.9 Optional parameters for the CCITTFaxDecode filter k = 0 - columns = 0 + columns = 1728 if parameters: if isinstance(parameters, ArrayObject): for decode_parm in parameters: @@ -419,8 +420,10 @@ def _get_parameters( if CCITT.K in decode_parm: k = decode_parm[CCITT.K] else: - columns = parameters[CCITT.COLUMNS] # type: ignore - k = parameters[CCITT.K] # type: ignore + if CCITT.COLUMNS in parameters: + columns = parameters[CCITT.COLUMNS] # type: ignore + if CCITT.K in parameters: + k = parameters[CCITT.K] # type: ignore return CCITParameters(k, columns, rows)