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

ENH: Modify page attributes that depend on page orientation after rotating page #633

Closed
thommiano opened this issue Aug 5, 2021 · 1 comment
Labels
is-feature A feature request

Comments

@thommiano
Copy link

thommiano commented Aug 5, 2021

Rotating a page, e.g., using page.RotateClockwise() only updates the /Rotate attribute:

def rotateClockwise(self, angle):
        """
        Rotates a page clockwise by increments of 90 degrees.

        :param int angle: Angle to rotate the page.  Must be an increment
            of 90 deg.
        """
        assert angle % 90 == 0
        self._rotate(angle)
        return self

def rotateCounterClockwise(self, angle):
        """
        Rotates a page counter-clockwise by increments of 90 degrees.

        :param int angle: Angle to rotate the page.  Must be an increment
            of 90 deg.
        """
        assert angle % 90 == 0
        self._rotate(-angle)
        return self

def _rotate(self, angle):
        currentAngle = self.get("/Rotate", 0)
        self[NameObject("/Rotate")] = NumberObject(currentAngle + angle)

The expected behavior is that other attributes that depend on a page's origin should also be updated based on rotation. For example:

  • /mediaBox - The x, y dimensions of the page. If the page is rotated 90 degrees, the values in the mediaBox should swap places
  • /Annots.../Rect - The coordinates of a rectangular bounding box for an annotation. These coordinates are [x0, y0, x1, y1], with the origin being at the bottom left of the page. If the page is rotated, the origin with respect to the annotations according from the users perspective has changed and so should the coordinates.

Notes

I created this issue to capture a more general issue that is happening in more specific cases that haven't been resolved:

@thommiano thommiano changed the title Page rotation does not modify page attributes that depend on page orientation Feature request: Modify page attributes that depend on page orientation after rotating page Aug 6, 2021
@MartinThoma MartinThoma added the is-feature A feature request label Apr 6, 2022
@MartinThoma MartinThoma changed the title Feature request: Modify page attributes that depend on page orientation after rotating page ENH: Modify page attributes that depend on page orientation after rotating page Jun 26, 2022
@pubpub-zz
Copy link
Collaborator

transfer_rotation_to_content() has been developped since. I propose to close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is-feature A feature request
Projects
None yet
Development

No branches or pull requests

3 participants