Lock Comments

This Forum is for the use of End Users requiring help and assistance for Tracker Software's PDF-Tools.

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

Post Reply
dasy2k1
User
Posts: 42
Joined: Mon Feb 15, 2016 10:55 am

Lock Comments

Post by dasy2k1 » Mon Dec 14, 2020 6:46 pm

Is there a way to change the locked flag to yes on all comments using a PDF tools script?

as in Select all comments and lock them.

We have lots of documents that various comments get added to as they age (they are digitally signed before so the comments cant be flattened much as we wish this was possible (would be super good if you could have a signature that allowed all changes but flagged as Document has been changed since signing when this happened))

At the moment there is a real risk of important comments being accidentally moved or deleted when people are using the document on screen.

marking the comments as locked from the properties panel is what we are using at the moment to help prevent this problem but it would be much easier if there was a simple script i could get end users to run that simply locks all comments in a document in one hit

User avatar
TrackerSupp-Daniel
Site Admin
Posts: 4272
Joined: Wed Jan 03, 2018 6:52 pm

Re: Lock Comments

Post by TrackerSupp-Daniel » Wed Dec 16, 2020 9:50 pm

Hi, dasy2k1

You should be able to lock comments in bulk by using JavaScript, which PDF-Tools does not yet support, but will be in a near future update. In the meantime, you can run it through the JS console in the PDF-Xchange Editor instead (Ctrl_J).

I am afraid that I do not have a sample of the JS code required to do this, but if you are familiar with JS, you could likely create it with some ease, and research in the Adobe JS API reference manual, here: https://www.adobe.com/content/dam/acom/ ... erence.pdf

Kind regards,
Daniel McIntyre
Support Technician
Tracker Software Products (Canada) LTD

Support: <Support@tracker-software.com>
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623

User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 1999
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Lock Comments

Post by Vasyl-Tracker Dev Team » Thu Dec 17, 2020 6:42 pm

There is a simple Java script you want:

Code: Select all

var pagesNum = this.numPages;
for (var i = 0; i < pagesNum; i++)
{
	var al = this.getAnnots(i);
	if (al != null)
	{
		var alen = al.length;	
		for (var j = 0; j < alen; j++)
		{
			var a = al[j];
			a.lock = true;
			a.readOnly = true;
		}
	}
}
Also in UI you may use the Comments pane: in the Menu/View/Panes/Comments click the Comments and Properties items to show the corresponding panes(Ctl+M and Ctl+`), then in Comments pane press the Ctrl+A to select all. Then in Properties pane switch the Locked to yes..
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.

dasy2k1
User
Posts: 42
Joined: Mon Feb 15, 2016 10:55 am

Re: Lock Comments

Post by dasy2k1 » Wed Jan 13, 2021 11:25 am

Thanks for the update,
Hopefully the PDF tools will have a Custom JS action soon. plenty of things i can think of that this would be super useful for.

User avatar
TrackerSupp-Daniel
Site Admin
Posts: 4272
Joined: Wed Jan 03, 2018 6:52 pm

Lock Comments

Post by TrackerSupp-Daniel » Wed Jan 13, 2021 8:40 pm

:)
Daniel McIntyre
Support Technician
Tracker Software Products (Canada) LTD

Support: <Support@tracker-software.com>
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623

dasy2k1
User
Posts: 42
Joined: Mon Feb 15, 2016 10:55 am

Re: Lock Comments

Post by dasy2k1 » Thu Jan 21, 2021 12:23 pm

one more question, is there a flatten selected annotation JS

i have found flattenPages() which can accept a page number as the input to flatten all annotations on a selected page,

but is there one that will allow passing the annotation id as in your script above. something along the lines of flatten(a)

would certainly be useful but cant quite find it in the API

User avatar
TrackerSupp-Daniel
Site Admin
Posts: 4272
Joined: Wed Jan 03, 2018 6:52 pm

Re: Lock Comments

Post by TrackerSupp-Daniel » Fri Jan 22, 2021 9:56 pm

Hi, dasy2k1

From what I can locate in the JS API manual, there does not appear to be a function to flatten a specific annot by ID, only the flattenpages function. If this is possible, I am afraid that I do not know how it would be done.

Kind regards,
Daniel McIntyre
Support Technician
Tracker Software Products (Canada) LTD

Support: <Support@tracker-software.com>
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623

Post Reply