-
Notifications
You must be signed in to change notification settings - Fork 1.4k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mergeRotatedTranslatedPage doubt #558
Comments
What do you mean by that? |
I too have some problems understanding how excatcly this function works. When I am trying to center a landscape page which I rotated to portrait on a bigger page I am absolutley unable to do it as I have no idea what way I need to translate it. I tried to understand the translation matrix that is applied but I was unable to grasp the concept fully. |
I do not know the origin of the PDF that you use, per do you make a recommendation, use the gs command to clean inconsistent info containing the PDF before using py-pdf2
|
Test.pdf |
The rotation with from PyPDF2 import Transformation, PdfReader, PdfWriter
reader = PdfReader("box.pdf")
page = reader.pages[0]
x1, y1, x2, y2 = page.cropbox
assert x1 == 0
assert y1 == 0
op = Transformation().rotate(rotation=180).translate(tx=x2, ty=y2)
page.add_transformation(op)
print(page.cropbox)
print(page.mediabox)
writer = PdfWriter()
writer.add_page(page)
with open("output.pdf", "wb") as fp:
writer.write(fp) The center point of the coordinates is in the bottom-left corner. That means if you want to flip the image by 180 degrees, the content would go from the upper-right quadrant to the lower-left one. You can see that those are just simple coordinate transformations. PyPDF2 does not care for this operation where the actual content is. It also doesn't care about the mediabox / cropbox / trimbox. It just applies the transformation to the coordinate system. Did that clarify the topic? |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Hello everyone
I can't understand what the process is like when applying page1.mergeRotatedTranslatedPage (page2, ...)
Assuming the two pages of equal size
The following works well:
This works fine
more or less it comes out as I want but not as well as I wish
Could someone please explain this to me?
Thank you
The text was updated successfully, but these errors were encountered: