Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

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

Closed
vkovenko opened this issue Aug 2, 2023 · 2 comments
Closed

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

vkovenko opened this issue Aug 2, 2023 · 2 comments

Comments

@vkovenko
Copy link

vkovenko commented Aug 2, 2023

Greetings! I wonder if it's possible to resize pdf along with all the content relevant to it (images, text, svg elements, etc.).
Assume that I need to make my pdf 2 times bigger. Any option of how to achieve it using fitz library?

@JorjMcKie
Copy link
Collaborator

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.

@JorjMcKie
Copy link
Collaborator

Let me transfer this to Discussions.

@pymupdf pymupdf locked and limited conversation to collaborators Aug 2, 2023
@JorjMcKie JorjMcKie converted this issue into discussion #2578 Aug 2, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants