Skip to content

show_pdf_page mistake on page rotate #3701

Closed Answered by JorjMcKie
lynamosa asked this question in Looking for help
Discussion options

You must be logged in to vote

Before things get too complicated, you should de-rotate the input pages when necessary.
This problem has been solved multiple times. I have attached a version with the probably simplest solution:

import pymupdf

src = pymupdf.open("test.pdf")
doc = pymupdf.open()  # empty output PDF

width, height = pymupdf.paper_size("a4")  # A4 portrait output page format
r = pymupdf.Rect(0, 0, width, height)

# define the 4 rectangles per page
r1 = r / 2  # top left rect
r2 = r1 + (r1.width, 0, r1.width, 0)  # top right
r3 = r1 + (0, r1.height, 0, r1.height)  # bottom left
r4 = pymupdf.Rect(r1.br, r.br)  # bottom right

# put them in a list
r_tab = [r1, r2, r3, r4]

# now copy input pages to output
for s…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@JorjMcKie
Comment options

Answer selected by JorjMcKie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not a bug not a bug / user error / unable to reproduce
2 participants
Converted from issue

This discussion was converted from issue #3700 on July 18, 2024 20:32.