Skip to content

Getting wrong coordinates after croping page #1272

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

You must be logged in to vote
>>> import fitz
>>> doc=fitz.open()
>>> page=doc.new_page()
>>> page.rect
Rect(0.0, 0.0, 595.0, 842.0)
>>> page.cropbox
Rect(0.0, 0.0, 595.0, 842.0)
>>> page.set_cropbox((100,100,400,400))
>>> page.cropbox
Rect(100.0, 100.0, 400.0, 400.0)
>>> doc.xref_get_key(page.xref, "CropBox")
('array', '[100 442 400 742]')
>>> print(doc.xref_object(page.xref))
<<
  /Type /Page
  /MediaBox [ 0 0 595 842 ]
  /Rotate 0
  /Resources 3 0 R
  /Parent 2 0 R
  /CropBox [ 100 442 400 742 ]  % <== this is what pypdf, etc return
>>
>>> page.rect
Rect(0.0, 0.0, 300.0, 300.0)
>>> 

Replies: 4 comments

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
Answer selected by JorjMcKie
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
not a bug not a bug / user error / unable to reproduce
2 participants
Converted from issue

This discussion was converted from issue #1271 on September 19, 2021 08:46.