Skip to content
Discussion options

You must be logged in to vote

You can set the MediaBox with negative coordinates, too! For example:

doc=fitz.open()
page=doc.new_page()
cb=page.cropbox
page.draw_rect(page.rect,color=(1,0,0))
Point(0.0, 0.0)
page.set_mediabox(cb+(0,-200,0,0))
print(doc.xref_object(4))
<<
  /Type /Page
  /MediaBox [ 0 -200 595 842 ]   # this is legal!
  /Rotate 0
  /Resources 3 0 R
  /Parent 2 0 R
  /Contents [ 5 0 R ]
>>
doc.save("x.pdf")
page.cropbox
Rect(0.0, 0.0, 595.0, 1042.0)

looks like this:

Replies: 1 comment 1 reply

Comment options

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

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