Skip to content
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

transfer_rotation_to_content and annotations #2784

Closed
kwang-yong-hyun opened this issue Aug 2, 2024 · 1 comment
Closed

transfer_rotation_to_content and annotations #2784

kwang-yong-hyun opened this issue Aug 2, 2024 · 1 comment

Comments

@kwang-yong-hyun
Copy link

Explanation

I'm trying to create an N-up function.

If there are vertically long pages in the pdf document, first rotate them 90 degrees and then use "merge_translated_page".

1

page.rotate(90)

2

"transfer_rotation_to_content" was applied to fix rotated pages.

page.transfer_rotation_to_content()

3

The angle of the content has been fixed, but the annotation has returned to its original angle.

There is something similar in "merge_translated_page".

new_page.merge_translated_page(page, margin_left ,paper_height - (margin_top + page_height))

4

I asked Chatgpt how to move annotations and found the answer.

annotations = page.get("/Annots")

if annotations:
for annotation in annotations:
annotation_obj = annotation.get_object()
rect = annotation_obj.get("/Rect")
if rect:
rect[0] = FloatObject(rect[0] +(margin_left))
rect[1] = FloatObject(rect[1] +paper_height - (margin_top + page_height))
rect[2] = FloatObject(rect[2] +(margin_left))
rect[3] = FloatObject(rect[3] +paper_height - (margin_top + page_height))

        annotation_obj.update({
            "/Rect": ArrayObject(rect)
        })

5

Looking at these things, I think that "pypdf" is fully capable of changing the location of annotations.

In the next update I hope that the annotations will also be moved along with the contents.

@stefan6419846
Copy link
Collaborator

This is a duplicate of #2592, thus I am going to close this issue in favor of the original report.

@stefan6419846 stefan6419846 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants