Skip to content

Scaling (minimizing content) on PDF #3986

Discussion options

You must be logged in to vote

Aha! All this has nothing to do with downloading or not. I was confused by this distracting buzzword.

Here is what you need to do:

  1. What you are actually doing is making a copy of pages by inserting them into pages of a new PDF where they take 5% less room than before.
  2. When reading an original page, determine its width / height.
  3. Make a same-size page in the output PDF.
  4. Define a smaller rectangle on output page and insert source page into this rectangle. The scaling will take place atuoamtically in this step.
  5. Insert header or footer as desired in target page.
src = pymupdf.open("input.pdf")
doc = pymupdf.open()  # output PDF
for spage in src:  # read source pages
    w, h = spage.rect.br  #…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@Begimkins
Comment options

@JorjMcKie
Comment options

@Begimkins
Comment options

@JorjMcKie
Comment options

Answer selected by Begimkins
@Begimkins
Comment options

@JorjMcKie
Comment options

@Begimkins
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants