Skip to main content
November 1, 2017
Question

Unable to change Font Family when adding free text annotation using javascirpt

  • November 1, 2017
  • 1 reply
  • 658 views

I trying to use an embedded font family to create a comment other than default Helvetica using following javascript. The annotation created always uses Helvetica. Is there a way to set  According to SDK documentation (Acrobat DC SDK Documentation), An arbitrary font can be used, can anyone help anything wrong with the script? or what is the rightway to set the font family?

var annot = this.addAnnot({

page : this.doc.pageNum,

type : "FreeText",

rect : [500,430,600,440],

strokeColor : color.blue,

width : 0.5,

lock : true,

      textFont : "GDT"

});

var spans = [];

spans.push({

textFont : "GDT",

text : "d",

textColor : color.blue,

textSize :8

}

);

   

annot.richContents = spans;

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
November 2, 2017

First of all, you should remove the textFont property from the Span object. It doesn't exist there, only at the Annotation level.

Second of all, are you sure you're using the correct font name? The best way to know the right name is to create a text field (or an annotation), apply the font you want to use manually and then use a script to print out its name.

For example, if you have a field called Text1, assign this font as its text font and then run this code:

console.println(this.getField("Text1").textFont);

The output of that is what you should use in your code. It's not always what you expect it to be...