Can I change properties of selected annotation

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

TatianaS
User
Posts: 103
Joined: Mon Mar 18, 2013 4:26 pm

Can I change properties of selected annotation

Post by TatianaS »

hello, I am wandering if there is a way of changing properties of selected annotation, for instance I want to change color of HighLight or change font of the Text annotation. I use DoDocumentVerb(iActiveDocID, '', 'GetSelectedAnnot', '', DataOut, 0) to get annotation, but how can I change properties of it?
Thanks
TatianaS
User
Posts: 103
Joined: Mon Mar 18, 2013 4:26 pm

Re: Can I change properties of selected annotation

Post by TatianaS »

I tried running this js on selected Typewriter annotation, but no font change happening. Do I do something wrong here?
var annots=this.getAnnots(0);
if(annots!=null){
for(var i=0;i<annots.length;i++){
var ann = annots;
ann.setProps({textFont :"font.Arial", textSize: 20});
}
}
Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: Can I change properties of selected annotation

Post by Walter-Tracker Supp »

I checked with another developer and was told:
If text-comment has already the rich-text then this script does not work in acrobat also.. this script changes the "default appearance" format for plain tetx and if comment already has the rich-text then the new "default appearance" format will be ignored..
This script should set properties:

Code: Select all

var annots=this.getAnnots();
if(annots!=null){
for(var i=0;i < annots.length;i++){
var ann = annots[i];
var c = ann.contents;
ann.richContents = new Array();
ann.setProps({textFont :"Arial", textSize: 20});
ann.contents = c;
}
}
TatianaS
User
Posts: 103
Joined: Mon Mar 18, 2013 4:26 pm

Re: Can I change properties of selected annotation

Post by TatianaS »

Thanks, That kind of worked. The text changed, but the "rect" aria is the same size, which cause that there is not enough space if I will change to the bigger font. Is there some properties I can set to readjust the aria of the annotation.
Thank you.
Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: Can I change properties of selected annotation

Post by Walter-Tracker Supp »

My best suggestion would be to get the current rect property, expand it as necessary, and then set it with the other properties.

Example to get properties and display them in the console (you can do this interactively in the end user viewer by popping up the javascript console with Ctrl-J).

Code: Select all

var annots=this.getAnnots(0);
if(annots!=null){
for(var i=0;i<annots.length;i++){
var ann = annots[i];
var p = ann.getProps();
for ( o in p ) console.println( o + " : " + p[o] );
}
}
Instead of the loop "for ( o in p ) ..." you can get the rect property like this:

Code: Select all

var rect = p["rect"];
console.println(rect);
TatianaS
User
Posts: 103
Joined: Mon Mar 18, 2013 4:26 pm

Re: Can I change properties of selected annotation

Post by TatianaS »

Hi, when I run this example of js on my Typewriter annotation, I get TextFont as undefined. I also tried to get richContents, but with the same result on the text font. Is there some other way I can get this property?


var annots=this.getAnnots(0);
if(annots!=null){
for(var i=0;i<annots.length;i++){
var ann = annots;
var p = ann.getProps();
for ( o in p ) console.println( o + " : " + p[o] );
}
}
Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: Can I change properties of selected annotation

Post by Walter-Tracker Supp »

While you can set those properties using the code listed above, getting those properties is not implemented currently. Sorry.