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
Can I change properties of selected annotation
Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
-
- User
- Posts: 103
- Joined: Mon Mar 18, 2013 4:26 pm
-
- User
- Posts: 103
- Joined: Mon Mar 18, 2013 4:26 pm
Re: Can I change properties of selected annotation
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});
}
}
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});
}
}
-
- User
- Posts: 381
- Joined: Mon Jun 13, 2011 5:10 pm
Re: Can I change properties of selected annotation
I checked with another developer and was told:
This script should set properties: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..
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;
}
}
-
- User
- Posts: 103
- Joined: Mon Mar 18, 2013 4:26 pm
Re: Can I change properties of selected annotation
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.
Thank you.
-
- User
- Posts: 381
- Joined: Mon Jun 13, 2011 5:10 pm
Re: Can I change properties of selected annotation
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).
Instead of the loop "for ( o in p ) ..." you can get the rect property like this:
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] );
}
}
Code: Select all
var rect = p["rect"];
console.println(rect);
-
- User
- Posts: 103
- Joined: Mon Mar 18, 2013 4:26 pm
Re: Can I change properties of selected annotation
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] );
}
}
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] );
}
}
-
- User
- Posts: 381
- Joined: Mon Jun 13, 2011 5:10 pm
Re: Can I change properties of selected annotation
While you can set those properties using the code listed above, getting those properties is not implemented currently. Sorry.