Skip to content

Annot.set_rotation(0) followed by Annot.update() throws AttributeError #5033

Closed

Description

@secrawford

Description of the bug

I have an Annot instance that I would like to remove rotation from. Trying to set the rotation of the Annot to zero then calling Annot.update() throws an AttributeError, stating that "'Annot' object has no attribute 'setRect'. Did you mean: 'set_rect'?" The offending line appears as 1838 of src/init.py of the latest revision of the main branch.

How to reproduce the bug

Issue can be reproduced by running the following code. Real use differs, but this replicates the error simply.

import pymupdf
doc = pymupdf.open()
doc.insert_page(0)
pg = doc[0]
annot = pg.add_line_annot((0, 0), (1, 1))
annot.set_rotation(90)
annot.update()
annot.set_rotation(0)
annot.update()

The first annot.update() call will return or print "cannot set rect: code=4: Line annotations have no Rect property". This behavior is expected.
The second annot.update() call should return or print similarly but instead terminates with the "setRect" error as described. This behavior is not expected.

PyMuPDF version

1.27.1

Operating system

Windows

Python version

3.11

Activity

  1. JorjMcKie commented on Jun 24, 2026

    @JorjMcKie
    Collaborator

    Thanks for submitting this.
    This is a piece of code that hasn't been touched since the changing our naming standards from "CamelCase" to "snake_case".

  2. added a commit that references this issue on Jun 26, 2026
  3. julian-smith-artifex-com commented on Jun 29, 2026

    @julian-smith-artifex-com
    Collaborator

    Fixed in pymupdf-1.28.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions