Tool to hide/show annotations  SOLVED

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: Daniel - PDF-XChange, PDF-XChange Support, Vasyl - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Mathew
User
Posts: 567
Joined: Thu Jun 19, 2014 7:30 pm

Tool to hide/show annotations  SOLVED

Post by Mathew »

I was having trouble with the redaction tool eliminating annotations (comments and stamps) that I want to keep, so made this tool to temporarily hide the annotations on the page. I've found it to also be useful if I have a lot of comments on a page and I want to temporarily get some out of the way.
isolateAnnots v0.3.1.zip
To install, unzip the file and put the .js file into the Javascripts folder
You can also run the script from the Javascript console to temporarily add the button.

Use:
The script adds a button to the Add-on toolbar to toggle hiding/restoring annotations.
image.png
It works by moving the annotations off the visible area of the page (by the dimensions of the crop box).

If you have annotations selected, it will only isolate (hide) the selected annotations, otherwise it will isolate all annotations on that page EXCEPT for redaction annotations. It adds a temporary hidden Text annotation to the page with the data for which annotations were moved, and how far. If you accidentally delete this, the script will not be able to restore the annotation positions. You can see this annotation in the Comments pane by changing Options... > Show > Show Comments with Hidden Flag

To bring annotations back, press the toolbar button (or select Tools > Hide/Restore Annots) again.

Options:
  • By default it adds 50 pt to the x and y dimensions of the crop box to the move distance. To add more padding to the distance it temporarily moves the annotations, edit [ 50, 50 ] line 34:

    Code: Select all

    const ISOLATE_DIST = [ 50, 50 ]; // additional pts to move annotations past crop box
  • To prevent it from also moving locked annotations, change line 35 to false:

    Code: Select all

    const ISOLATE_LOCKED = false;	// false to leave locked comments alone
Limitations:
  • It adds a text item to the page with the data on moved items. If this gets deleted, the tool will not restore the item positions - you'll need to do it manually.
  • It adds a rather long list of undos. Because of the inconsistent way that PDFX-Change adds undos during Javascripts, undo may not undo everything correctly (ie the added text item with data will not add an undo for its creation, but when it's deleted after everything is moved back, that's added to the undos.)
  • There's no dialog to change options, it's just a toggle, so may be a bit opaque. It should add a comment on the JavaScript console each time you run it describing what it tried to do.
  • Annotations that extend off the page may not get completely hidden - I may update in future to also check the bounds of all annotations.
Let me know if you see a problem - I'll try to fix. :)
You do not have the required permissions to view the files attached to this post.
Last edited by Mathew on Fri Jun 14, 2024 10:35 pm, edited 3 times in total.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11009
Joined: Wed Jan 03, 2018 6:52 pm

Tool to hide/show annotations

Post by Daniel - PDF-XChange »

:)
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Mathew
User
Posts: 567
Joined: Thu Jun 19, 2014 7:30 pm

Re: Tool to hide/show annotations

Post by Mathew »

Slight update to the tool to make it less likely to lose the locations of the annotations, and added a dialog to notify that the annotations were moved or restored. Also updated in the post above.
isolateAnnots v0.3.1.zip
You do not have the required permissions to view the files attached to this post.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11009
Joined: Wed Jan 03, 2018 6:52 pm

Re: Tool to hide/show annotations

Post by Daniel - PDF-XChange »

Hello, Mathew

Thank you once again for all the effort you put into these tasks, it is greatly appreciated!

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com