Skip to content

[Bug]: Editing the comment of an existing annotation adds a new Popup without /Rect on every save #22124

Description

@AlexAndBear

Attach (recommended) or Link to PDF file

https://github.com/mozilla/pdf.js/blob/master/test/pdfs/highlight_popup.pdf (from the PDF.js test corpus)


Web browser and its version

Chromium 153

Operating system and its version

macOS 26.5

PDF.js version

6.4.299

Is the bug present in the latest PDF.js version?

Yes

Is a browser extension

No


Steps to reproduce the problem

  1. Enable comments (enableComment: true) and open highlight_popup.pdf (a Highlight 24R with its Popup 25R).
  2. Click the comment button of the highlight, then "Edit comment", change the text and save the comment.
  3. Save (download) the document. Repeat steps 2–3 with the saved file a few times.

What is the expected behavior?

The highlight's existing Popup is reused (or replaced), so the page keeps one Popup for the comment.

What went wrong?

Every edit adds a new Popup annotation without /Rect to the page and points the highlight's /Popup to it; the previous Popups stay in /Annots. page.getAnnotations() of the saved files:

original      24R Highlight (popupRef 25R), 25R Popup
after edit 1  24R Highlight (popupRef 32R), 25R Popup, 32R Popup (no /Rect)
after edit 2  24R Highlight (popupRef 34R), 25R Popup, 32R Popup (no /Rect), 34R Popup (no /Rect)
after edit 3  24R Highlight (popupRef 36R), 25R Popup, 32R Popup (no /Rect), 34R Popup (no /Rect), 36R Popup (no /Rect)

/Rect is required for annotations, so stricter readers may complain, and the orphaned Popups pile up with every edit. The UI still shows a single comment.

Link to a viewer

No response

Additional context

No response

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions