Skip to content

The coordinates are in millimeters in PyMuPDF #797

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

You must be logged in to vote

A rectangle must be given as rect = fitz.Rect(x0, y0, x1, y1) where (x0, y0) is the top-left point and (x1, y1) the bottom-right one. If you have the the top-left only plus the width / height, the calculation is therefore rect = fitz.Rect(x0, y0, x0 + width, y0 + height).
So in your case rect = fitz.Rect(24, 88, 24+77, 88+7). Then simply do this to convert the whole thing to pixels:

>>> rect = fitz.Rect(24, 88, 24+77, 88+7)
>>> rect = rect / 25.4 * 72
>>> rect
Rect(68.03149606299213, 249.4488188976378, 286.2992125984252, 269.29133858267716)
>>> 

Replies: 5 comments 6 replies

Comment options

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

Comment options

You must be logged in to vote
5 replies
@JorjMcKie
Comment options

@JorjMcKie
Comment options

@Sv9t
Comment options

@JorjMcKie
Comment options

@JorjMcKie
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Sv9t
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
2 participants