Page 1 of 1

JS property 'strokeColor' not working

Posted: Fri Jan 12, 2018 3:00 pm
by MartinCS
Hi Tracker-Team,

my purpose is to create an annotation via JavaScript with the following code:

Code: Select all

var annot = this.addAnnot({
type: "FreeText",
author: "John Doe",
width: 0,
page: 0,
strokeColor: ['RGB',0,0,0],
fillColor: color.transparent,
textFont: "Arial",
textSize: 7.09,
rect: [28.39,115.87,510.28,124.72],
rotate: 0,
contents: "sample text",
alignment: 0,
readOnly: true});
But the property 'strokeColor' can't not be set. It's always red regardless which value I set, e.g.

Code: Select all

strokeColor: ['RGB',0,1,0],
I'm able to reproduce this issue in the standalone Editor via the JavaScript Console as well;
12-01-_2018_15-57-20.jpg
I hope you guys can help!

// Martin

Re: JS property 'strokeColor' not working

Posted: Mon Jan 15, 2018 9:29 am
by Sasha - Tracker Dev Team
Hello Martin,

You can try this code in the Acrobat - works the same as in the Editor. The thing is that the stroke color is a color of the annotation's border (that has a 0 width in this case).

Cheers,
Alex

Re: JS property 'strokeColor' not working  SOLVED

Posted: Mon Jan 15, 2018 9:47 am
by Sasha - Tracker Dev Team
If you want to set the color of the text inside of the annotations, use something like this:

Code: Select all

var spans = new Array();
spans[0] = new Object();
spans[0].text = "sample text";
spans[0].fontFamily = ["Arial"];
spans[0].textColor = color.black;
spans[0].textSize = 7.09;
   
var annot = this.addAnnot({
type: "FreeText",
author: "John Doe",
width: 0,
page: 0,
strokeColor: ['RGB',0,0,0],
fillColor: color.transparent,
rect: [28.39,115.87,510.28,124.72],
rotate: 0,
richContents: spans,
alignment: 0,
readOnly: true});
Cheers,
Alex

Re: JS property 'strokeColor' not working

Posted: Mon Jan 15, 2018 10:02 am
by MartinCS
Hi Alex,

I wasn't aware of the propety 'textColor'. It's working now!

Again thank you for help! It is most appreciated.

// Martin

Re: JS property 'strokeColor' not working

Posted: Mon Jan 15, 2018 10:08 am
by Tracker Supp-Stefan
:D