Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Handle indirect objects as parameters for CCITTFaxDecode #2307

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions pypdf/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,23 +558,24 @@ class CCITTFaxDecode:

@staticmethod
def _get_parameters(
parameters: Union[None, ArrayObject, DictionaryObject], rows: int
parameters: Union[None, ArrayObject, DictionaryObject, IndirectObject], rows: int
) -> CCITParameters:
# TABLE 3.9 Optional parameters for the CCITTFaxDecode filter
k = 0
columns = 1728
if parameters:
if isinstance(parameters, ArrayObject):
for decode_parm in parameters:
parameters_unwrapped = cast(Union[ArrayObject, DictionaryObject], parameters.get_object())
if isinstance(parameters_unwrapped, ArrayObject):
for decode_parm in parameters_unwrapped:
if CCITT.COLUMNS in decode_parm:
columns = decode_parm[CCITT.COLUMNS]
if CCITT.K in decode_parm:
k = decode_parm[CCITT.K]
else:
if CCITT.COLUMNS in parameters:
columns = parameters[CCITT.COLUMNS] # type: ignore
if CCITT.K in parameters:
k = parameters[CCITT.K] # type: ignore
if CCITT.COLUMNS in parameters_unwrapped:
columns = parameters_unwrapped[CCITT.COLUMNS] # type: ignore
if CCITT.K in parameters_unwrapped:
k = parameters_unwrapped[CCITT.K] # type: ignore

return CCITParameters(k, columns, rows)

Expand Down
Loading