Resizing page - content placement #2282
Answered
by
JorjMcKie
jjennings955
asked this question in
Looking for help
-
Hello, I'm resizing pages by updating the mediabox to have 200 extra pixels of height. This puts the extra height at the top of the page. How do I shift the contents of the page up, so I can have the extra space at the bottom? So right now I have something like this
Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Answered by
JorjMcKie
Mar 11, 2023
Replies: 1 comment 1 reply
-
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) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jjennings955
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can set the MediaBox with negative coordinates, too! For example:
looks like this: