I'm trying to add multiple annotations in pdf document through Acrobat javascript. However, only the first annotation is working if I include both. The second annotation only works if I include that one separately.
var spans = new Array();
spans[0] = new Object();
spans[0].text = "Links to: ";
spans[0].textSize = 12;
spans[0].textColor = color.red;
spans[1] = new Object();
spans[1].text = "http://www.example.com";
spans[1].textSize = 12;
spans[1].textColor = color.black;
// Now create the annot with spans as it's richContents
var annot = this.addAnnot({
page: 0,
type: "FreeText",
rect: [50, 50, 300, 100],
richContents: spans
});
var copy_annot = this.addAnnot({type: "Line"})
annot.setProps({
page: 0,
points: [[400,490],[430,690]],
strokeColor: color.red,
arrowBegin: "Diamond",
arrowEnd: "OpenArrow"
});
I had forgotten to change the variable name before setting the property
Solution:
var copy_annot = this.addAnnot({type: "Line"})
copy_annot.setProps({
...
});