Skip to content

Conversation

@legraina
Copy link

@legraina legraina commented Aug 25, 2025

I have created an eraser button to be able to erase annotations. I have also fix some issues with the pointer type.

  • Eraser:
    • Create an eraser editor: eraser.js
    • Abstract erase and endErase functions in editor.js, as well as an erasable field (false by default)
    • Implemented erase and endErase for ink.js
    • Implement undo/redo logic for the eraser. endErase function return a dictionnary { cmd, undo } with the right functions to use for the eraser undo and cmd.
    • Add an eraser button

MOVED to PR #20213:

  • PointerType:
    • The pointer types fields have been moved to a CurrentPointer object in tools.js. This object is used by eraser.js and ink.js
    • Clear the pointer type when changing mode, instead of at the end of the session. It seems more stable, as the method is not called this way when the user changes pages.
    • Only clear the pointer type when the mode is changed by an event (the user changes the editor type), otherwise, the same pointer type is kept (the document is changed for example).

@timvandermeij
Copy link
Contributor

Could you elaborate a bit about what this patch aims to archieve? "Eraser" is not a concept known in the PDF specification AFAIK, so I would assume this is the equivalent of a Redact annootation, however I don't see it being written to the file like that.

@legraina
Copy link
Author

The goal of this eraser is to remove parts of some annotations, especially the ink annotations. When you write, in particular on a tablet, you may want to erase parts of your writing, it’s where this eraser comes in play, like a real eraser/rubber. Ruber would be a better name ? There is nothing added to the document it-self, as it modifies current annotations.

@legraina
Copy link
Author

@timvandermeij Is there any things I can do to help ?

@calixteman
Copy link
Contributor

@legraina, first, thank you for you patch, I played a bit with it and it looks nice.

I talked about your stuff to the UX/UI team and we're interested by this feature.
Unfortunately, we won't have the time to make a UX/UI design for it but we'll do for sure in a more or less close future.
So before we review your patch, there are few things you should do:

  • the pointer type stuff must be done in a separate patch since it's unrelated to your feature, if I misunderstood something please tell me;
  • for the eraser tool itself, you must add a pref (e.g. similar to enableComment).

If you've your own product based on pdf.js, it'll be up to you to enable/disable the feature and about having the feature in Firefox, you'll have to wait few months or maybe less...

@legraina
Copy link
Author

legraina commented Aug 30, 2025

Hi @calixteman,

Thanks for the update.

I'll will definitly be enabling this option on my side as soon as it's available.
Thanks

@legraina
Copy link
Author

legraina commented Sep 3, 2025

Hi @calixteman,

This PR has been replaced by #20213, #20226, and #20227 (to be merged in this order).

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants