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
8 octobre 2020 à 06:34
#63986

Maître des clés
bonjour,
J’imagine que si tu ajoutes ta pièce jointe en page 2, c’est que ton document comporte au mois 3 pages…
Je te rappelle que la numérotation des pages se fait basée sur 0 (la page 0 est la première page).
Voici ton script « remanié » où j’ai supprimé des lignes inutiles (à mon avis, mais je ne connais pas ton document entièrement).
Code:
var nbPJ=0;
this.syncAnnotScan();
var annots=this.getAnnots();
if (annots!=null) {
for (var i=0; i if (annots.type== »FileAttachment » && annots.author==event.target.name) nbPJ++;
}
}
if (nbPJ==2) {
app.alert(« You can attach maximum 2 files. Please merge your documents if necessary. »);
this.getField(« attach_A »).display=display.hidden;
this.getField(« attached_A »).display=display.visible;
} else {
var annot=this.addAnnot({
page: 2,
type: « FileAttachment »,
author: event.target.name,
contents: « Double-clic to open »,
attachIcon: « PushPin »,
point: [-500,0],
strokeColor: color.red,
});
if (this.getField(« files_field_A »).value== » ») this.getField(« files_field_A »).value=annot.attachment.name;
else this.getField(« files_field_A »).value=this.getField(« files_field_A »).value+ »n »+annot.attachment.name;
}
this.syncAnnotScan();
var annots=this.getAnnots();
if (annots!=null) {
for (var i=0; i
}
}
if (nbPJ==2) {
app.alert(« You can attach maximum 2 files. Please merge your documents if necessary. »);
this.getField(« attach_A »).display=display.hidden;
this.getField(« attached_A »).display=display.visible;
} else {
var annot=this.addAnnot({
page: 2,
type: « FileAttachment »,
author: event.target.name,
contents: « Double-clic to open »,
attachIcon: « PushPin »,
point: [-500,0],
strokeColor: color.red,
});
if (this.getField(« files_field_A »).value== » ») this.getField(« files_field_A »).value=annot.attachment.name;
else this.getField(« files_field_A »).value=this.getField(« files_field_A »).value+ »n »+annot.attachment.name;
}
@+
:bonjour: