abracadabraPDF › Forums › PDF – Général › Personnalisation d’un bouton permettant d’importer une pièce jointe › Répondre à : Personnalisation d’un bouton permettant d’importer une pièce jointe
26 juin 2020 à 17:29
#63970

Maître des clés
bonjour,
On peut aussi compter le nombre de pièces jointes déjà en place.
Code:
var nbPJ=0;
this.syncAnnotScan();
var annots=this.getAnnots();
if (annots!=null) {
for (var i=0; i if (annots.type== »FileAttachment » && annots.attachIcon== »Paperclip » && annots.author.substr(0,2)== »PJ ») {
annots.delay=true;
annots.setProps({
author: « PJ « +(nbPJ+1)+ » OK ! »,
point: [500+(nbPJ*5), 310+(nbPJ*5)]
});
annots.delay=false;
nbPJ++;
}
}
}
if (nbPJ==5) {
app.alert(« Il y a déjà 5 pièces jointes importées »);
} else {
var annot = this.addAnnot({
page: this.pageNum,
type: « FileAttachment »,
author: « PJ « +(nbPJ+1)+ » OK ! »,
contents: « Double-clic pour ouvrir ou supprimer pour effacer »,
attachIcon: « Paperclip »,
point: [500+(nbPJ*5), 310+(nbPJ*5)],
strokeColor: color.blue,
});
}
this.syncAnnotScan();
var annots=this.getAnnots();
if (annots!=null) {
for (var i=0; i
annots.delay=true;
annots.setProps({
author: « PJ « +(nbPJ+1)+ » OK ! »,
point: [500+(nbPJ*5), 310+(nbPJ*5)]
});
annots.delay=false;
nbPJ++;
}
}
}
if (nbPJ==5) {
app.alert(« Il y a déjà 5 pièces jointes importées »);
} else {
var annot = this.addAnnot({
page: this.pageNum,
type: « FileAttachment »,
author: « PJ « +(nbPJ+1)+ » OK ! »,
contents: « Double-clic pour ouvrir ou supprimer pour effacer »,
attachIcon: « Paperclip »,
point: [500+(nbPJ*5), 310+(nbPJ*5)],
strokeColor: color.blue,
});
}
Et il faut penser à les repositionner si une ou plusieurs ont été supprimées.
@+
:bonjour: