2017-02-10 2 views
0

J'essaie d'ajouter plusieurs annotations dans un document pdf via Acrobat javascript. Cependant, seule la première annotation fonctionne si j'inclue les deux. La deuxième annotation ne fonctionne que si je l'inclue séparément.Plus d'une instance d'annotation ne fonctionnant pas dans Acrobat

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" 
}); 

Répondre

0

J'avais oublié de changer le nom de la variable avant la propriété

Solution:

var copy_annot = this.addAnnot({type: "Line"}) 
    copy_annot.setProps({ 
    ... 
});