Turn off and on existing annotations

The PDF-XChange Viewer for End Users
+++ FREE +++

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

tim126
User
Posts: 82
Joined: Thu Oct 02, 2014 1:48 am

Turn off and on existing annotations

Post by tim126 »

I have made some annotations on a pdf file under the viewer.
Can I turn off the existing annotations if I want to get back the original pdf file without the annotations?
Can I turn on the annotations again?

What if the annotations were added under other pdf editors, such as Okular, Adobe Acrobat, Foxit, ...


Thanks.
User avatar
Paul - Tracker Supp
Site Admin
Posts: 6902
Joined: Wed Mar 25, 2009 10:37 pm
Location: Chemainus, Canada

Re: Turn off and on existing annotations

Post by Paul - Tracker Supp »

Hi Tim,

thanks for the post. Comments in a PDF have a flag that can be set to hide them. In the Viewer and the Editor it is possible to hide all comments or show all comments.

Comments --> Show Comments --> Hide All Comments
Comments --> Show Comments --> Show All Comments


This is a filter, it will show/hide the comments but it does not change the flag. The upshot of this is that yes you can change the way comments are shown or not, it doesn't matter what application created the comments but the show/hide will only be what you see in our Editor/Viewer, open the file in another PDF application and the comment visibility will be as per the flag.

It is possible to use JavaScript to set the flag either way. The following script has two functions, one to set all annotations to hidden and one to set all annotations to shown. Use then as you need, you can from this proabably write your own version that sets specific annotations if you are so motivated. :-D

Code: Select all

//use this to set all annots to shown
function ShowAllAnnots()
{
 var pn = this.numPages;
 for (i = 0; i < pn; i++)
 {
  var aa = this.getAnnots(i);
  var an = aa.length;
  for (j = 0; j < an; j++) 
  {
      var a = aa[j];
      a.hidden = false; 
  } 
 }
};
ShowAllAnnots()


//use this to set all annots to hidden
function HideAllAnnots()
{
 var pn = this.numPages;
 for (i = 0; i < pn; i++)
 {
  var aa = this.getAnnots(i);
  var an = aa.length;
  for (j = 0; j < an; j++) 
  {
      var a = aa[j];
      a.hidden = true; 
  } 
 }
};
HideAllAnnots()
This did prompt us to think of adding to the Editor the ability to set show/hide in the properties on any given annotation. Look for that in a future build.

Thanks for the post, it has helped us improve the Editor.

I hope this helps.
Best regards

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
tim126
User
Posts: 82
Joined: Thu Oct 02, 2014 1:48 am

Re: Turn off and on existing annotations

Post by tim126 »

where do you run the code?

Is it possible to remove the annotations from a pdf file, or permantly hide the annotations away from nonauthorized people, so that I can send it to others and don't worry that they will find out and see my messy annotations.
Paul - Tracker Supp wrote:Hi Tim,

thanks for the post. Comments in a PDF have a flag that can be set to hide them. In the Viewer and the Editor it is possible to hide all comments or show all comments.

Comments --> Show Comments --> Hide All Comments
Comments --> Show Comments --> Show All Comments


This is a filter, it will show/hide the comments but it does not change the flag. The upshot of this is that yes you can change the way comments are shown or not, it doesn't matter what application created the comments but the show/hide will only be what you see in our Editor/Viewer, open the file in another PDF application and the comment visibility will be as per the flag.

It is possible to use JavaScript to set the flag either way. The following script has two functions, one to set all annotations to hidden and one to set all annotations to shown. Use then as you need, you can from this proabably write your own version that sets specific annotations if you are so motivated. :-D

Code: Select all

//use this to set all annots to shown
function ShowAllAnnots()
{
 var pn = this.numPages;
 for (i = 0; i < pn; i++)
 {
  var aa = this.getAnnots(i);
  var an = aa.length;
  for (j = 0; j < an; j++) 
  {
      var a = aa[j];
      a.hidden = false; 
  } 
 }
};
ShowAllAnnots()


//use this to set all annots to hidden
function HideAllAnnots()
{
 var pn = this.numPages;
 for (i = 0; i < pn; i++)
 {
  var aa = this.getAnnots(i);
  var an = aa.length;
  for (j = 0; j < an; j++) 
  {
      var a = aa[j];
      a.hidden = true; 
  } 
 }
};
HideAllAnnots()
This did prompt us to think of adding to the Editor the ability to set show/hide in the properties on any given annotation. Look for that in a future build.

Thanks for the post, it has helped us improve the Editor.

I hope this helps.
User avatar
Paul - Tracker Supp
Site Admin
Posts: 6902
Joined: Wed Mar 25, 2009 10:37 pm
Location: Chemainus, Canada

Re: Turn off and on existing annotations

Post by Paul - Tracker Supp »

If you hit CTRL+J in either the Viewer or Editor it will launch the JavaScript Console where you can run the code:

Code: Select all

//use this to set all annots to hidden
function HideAllAnnots()
{
var pn = this.numPages;
for (i = 0; i < pn; i++)
{
  var aa = this.getAnnots(i);
  var an = aa.length;
  for (j = 0; j < an; j++) 
  {
      var a = aa[j];
      a.hidden = true; 
  } 
}
};
HideAllAnnots()
This will set the flag to hide all annotations. Do understand that this can be changed by users who know how to set the flags to show. It sounds to me that you may be better off making a copy of your PDF and simply removing all the annotations to get a version for your recipient that doesn't have them.

CTRL+M will open the 'Comments Pane' where you can organize and select any/all comments and delete them.

I hope that helps.
Best regards

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com