Skip to content

Scaling (resizing) of PDF with all the content #2578

Closed Answered by JorjMcKie
vkovenko asked this question in Q&A
Discussion options

You must be logged in to vote

You mean you want to increase the dimension of each page? No problem:

src = fitz.open("input.pdf")
doc = fitz.open()  # new output PDF
for page in src:
    w, h = page.rect.br  # extract input page widht and height
    newpage = doc.new_page(width=2*w, height=2*h)
    newpage.show_pdf_page(newpage.rect, src, page.number)
doc.ez_save("output.pdf")

The output will show the original pages stretched by a factor of 2.

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by vkovenko
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2577 on August 02, 2023 13:48.