Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

Destroy Annotations by Javascript

Avatar

Former Community Member

Hi, I have a piece of Javascript (pretty much copied from Acrobat manual) that's attached to the Click event of a Button, and it removes all the annotations on a PDF form.

The script is like this:

var oObj = event.target;

var annots = oObj.getAnnots({ nPage:0 });

for (var i = 0; i < annots.length; i++) {

  annots[i].destroy();

  }

It works fine when the form is a stand-alone PDF.  But when I put the form in the WorkSpace and get it routed in a workflow, it doesn't remove the annotations at all.

(The form is referenced by a Document variable in the Process, and it's the input/outpt of the User Tasks.)

What do I need to do to get it to work in WorkSpace?

thanks

2 Replies

Avatar

Level 5

Tried this out using a pdf in a process flow. Added the button with your code to the form and then opened it in workspace. Added some comments and then was able to remove all comments from the list using the button. The only thing I can think of is that comments can only be used on static pdf forms. Goto File->Form Properties->Defaults and make sure PDF render format is Static PDF Form.

Otherwise see if you can see any exception being thrown in either the acrobat javascript console or try..catch. Maybe uploading/publish a sample somewhere to see if there is something else.

Avatar

Former Community Member

thanks.  it's working now.  there was a scripting bug.