Skip to content

PageObject member function compress_content_streams #2485

Answered by stefan6419846
j-t-1 asked this question in Q&A
Discussion options

You must be logged in to vote

You probably want to use clone_from:

writer = PdfWriter(clone_from="input.pdf")

for page in writer.pages:
    page.compress_content_streams()

writer.write("output.pdf")

While there might be more Pythonic constructs to simplify the loop (for example using list comprehension or map), I think that this just makes the action less obvious.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@j-t-1
Comment options

Answer selected by stefan6419846
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants