mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.31k stars 9.97k forks source link

[Bug]: Annotation artifacts remain visible in viewer after deleting all annotations. #18915

Open atrinker opened 1 day ago

atrinker commented 1 day ago

Attach (recommended) or Link to PDF file

test.pdf

Web browser and its version

Mozilla Firefox

Operating system and its version

Windows 10

PDF.js version

4.7.76

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

Yes

Is a browser extension

No

Steps to reproduce the problem

  1. Open the attached PDF in the default viewer.
  2. Activate the annotation editor by clicking highlight on the toolbar.
  3. Scroll down to the following pages to load the annotations.
  4. Press Ctrl+A to select all annotations in the PDF.
  5. Press delete to remove all annotations at once.

What is the expected behavior?

All annotations should be removed from the PDF.

What went wrong?

Although the annotations are no longer selectable, some of them still appear visible in the viewer. They only disappear once the annotation editor is closed.

Link to a viewer

No response

Additional context

No response

calixteman commented 1 day ago

This is a tricky bug... When the pdf is rendered we only render the 2 (it depends of the zoom level) first pages, so we're only aware of the annotations we have on those pages. That means we don't have the ids, the properties, ... of the other annotations in the pdf. For example, we can ctrl+a and then change the color of one highlight, it should impact all the highlights of the document. So I think the only right way to fix this would be to get all the editable annotations when the user is selecting all, put them in the storage, and then apply the changes to the data we've in the storage.