Fill programmaticaly a popup note

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

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

spock
User
Posts: 9
Joined: Tue Jul 30, 2013 4:41 pm

Fill programmaticaly a popup note

Post by spock »

Hello,

Is there any possibility to assign programmaticaly a text inside a popup note ?
The popup note is associeted to a custom stamp and called with "OpenPopup" command.

Thanks a lot.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: Fill programmaticaly a popup note

Post by Stefan - PDF-XChange »

Hello spock,

You should be able to do that using JS code to populate the "contents" field of the annotation.

Please take a look at the RunJavaScript method in the Viewer's AX user manual for details on executing JS code.

Regards,
Stefan
spock
User
Posts: 9
Joined: Tue Jul 30, 2013 4:41 pm

Re: Fill programmaticaly a popup note

Post by spock »

Hello Stefan,

Thank for your response.
I'm searching into the JavaScript for Acrobat API Reference, but I don't find how to proceed.
Can you give me a code example ?

Thanks,
Best regards,
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: Fill programmaticaly a popup note

Post by Stefan - PDF-XChange »

Hi spock,

The below is taken from the same manual file ;) and is creating a new annotation:

Code: Select all

var annot = this.addAnnot({
page: 0,
type: "Text",
point: [400,500],
author: "A. C. Robat",
contents: "Call Smith to get help on this paragraph.",
noteIcon: "Help" 
}); 
But also illustrates how the "contents" property works.

Regards,
Stefan
spock
User
Posts: 9
Joined: Tue Jul 30, 2013 4:41 pm

Re: Fill programmaticaly a popup note

Post by spock »

Stefan,

Thank for your response, it's very useful when I create a new stamp.
But I also need to set the contents property for popup notes attached to existing stamps.
How to proceed in this case ?

Thanks,
Regards
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: Fill programmaticaly a popup note

Post by Stefan - PDF-XChange »

Hi Spock,

You will need something like the following:

Code: Select all

var annots = this.getAnnots({ nPage:0 }); 
for (var i = 0; i < annots.length; i++) 
  if (annots[i].type == "Stamp") 
    annots[i].contents = "Your text here";
The above code will get all annotations on the first page of a document, will check which of those are stamps, and for them will add the "Your text here" as a pop-up text.

Regards,
Stefan