JavaScript for Acrobat -- Appying text font and size changes to auto-generated text boxes
I use multiple tools in Acrobat which generate text box "stamps" onto one or pages of a PDF document when certain conditions are met. These tools are mostly functional, however I am struggling to apply the correct formatting to the text boxes. Certain properties such as text and fill color function correctly, however despite my attempts to code font and size properties into these auto-generated boxes, they will always ignore the coded properties and instead revert to the default font settings.
In this code, for example, none of the text properties are able to overwrite the default document settings. I have other tools which help me to retroactively apply standard color and text size rules to the entire document to address the color issue, however I still have to manually change the font. I would like to be able to have all the correct properties appear as soon as the box is generated:
var stampSample = this.addAnnot({
page: 0,
type: "FreeText",
rect: [250, 25, 560, 100],
contents: "sample text",
fillColor: color.white,
strokeColor: color.white,
textColor: color.black,
textSize: 10,
textFont: "Times-Roman",
readonly: false
I've tried variations on the formatting of the text font name (font.Times, "Times Roman", etc.) with no success. I've had success with color formatting by modifying the richContents of boxes after they are created, however I haven't found a solution to apply that method here.
