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: Stream operations can be List or Dict #665

Merged
merged 2 commits into from
Apr 7, 2022
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
16 changes: 12 additions & 4 deletions PyPDF2/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2255,10 +2255,18 @@ def _contentStreamRename(stream, rename, pdf):
return stream
stream = ContentStream(stream, pdf)
for operands, _operator in stream.operations:
for i in range(len(operands)):
op = operands[i]
if isinstance(op, NameObject):
operands[i] = rename.get(op,op)
if isinstance(operands, list):
for i in range(len(operands)):
op = operands[i]
if isinstance(op, NameObject):
operands[i] = rename.get(op,op)
elif isinstance(operands, dict):
for i in operands:
op = operands[i]
if isinstance(op, NameObject):
operands[i] = rename.get(op,op)
else:
raise KeyError ("type of operands is %s" % type (operands))
return stream
_contentStreamRename = staticmethod(_contentStreamRename)

Expand Down