abracadabraPDF › Forums › PDF – Général › Incrémenter un numéro automatiquement. – RÉSOLU › Répondre à : Incrémenter un numéro automatiquement. – RÉSOLU
Pour créer vos billets (tickets), ici dans le cas de trois billets par page:
1-Créer un document PageMaster.pdf à partir de InDesign (maquette de 3 billets), avec 3 champs placés là où vous souhaitez voir apparaître les numéros, baptisés Numero_1,Numero_2,Numero_3. Placez ce document dans le répertoire Billeterie.
2-Placez le document joint « Machine à tickets.pdf » dans le répertoire Billeterie.
3-Placez le script ci-dessous « MachineCreationTickets.js » dans le répertoire JavaScript d’Acrobat.
4-Ouvrir « Machine à tickets.pdf » avec Acrobat PRO, choisir le nombre de tickets par page à l’aide du menu déroulant, puis le nombre de tickets total.
5-Presser le bouton « 1-Création tickets » pour générer les pages, répondre OK à l’alerte « Tous les champs de formulaire dotés du même nom… », puis presser « 2-Numérotation » pour numéroter les billets.
C’est fait.
Script « MachineCreationTickets.js »:
//Script à placer dans le répertoire JavaScript de l’application Acrobat
trustedcreationtickets=app.trustedFunction(function()
{
//Calcul du nombre de pages.
NombrePages=Math.ceil(this.getField(« NombreTickets »).value/this.getField(« UnitesParPage »).value);
this.getField(« NombrePages »).value=NombrePages;
UnitesParPage=this.getField(« UnitesParPage »).value;
this.getField(« Commentaires »).value= »Réalisé: »;
onyva=app.alert(« Cette action va lancer la création de « +NombrePages+ » pages soit « +this.getField(« NombreTickets »).value+ » billets.rContinuer? »,2,2);
if(onyva==4)
{
indexpage=1;
while(indexpage {
app.beginPriv();
this.insertPages({
nPage:this.pageNum,
cPath: »PageMaster.pdf »,
nStart:0,
nEnd:0})
app.endPriv();
indexchamp=0
this.getField(« Commentaires »).value=this.getField(« Commentaires »).value+ »rPage « +indexpage+ » créée. »;
indexpage=indexpage+1;
}
}
})
function creationNumeros()
{
rectangle=new Array();
this.getField(« NombrePages »).value=NombrePages;
UnitesParPage=this.getField(« UnitesParPage »).value;
this.getField(« Commentaires »).value= »Réalisé: »;
onyva=app.alert(« Cette action va lancer la création de « +this.getField(« NombreTickets »).value+ » numéros de tickets.rContinuer? »,2,2);
if(onyva==4)
{
indexpage=1;
while(indexpage
indexchamp=0
while(indexchamp
indexchamp=indexchamp+1;
if(indexpage==1)
{
NomChamp= »Numero_ »+indexchamp;
rectangle[indexchamp]=this.getField(NomChamp).rect;
this.getField(« Commentaires »).value=this.getField(« Commentaires »).value+ »rPage « +indexpage+ » suppression de « +NomChamp;
this.removeField(NomChamp);
}
Numero=(indexpage-1)*UnitesParPage+indexchamp;
Marque=Numero;
if(Numero<10000){Marque="0"+Numero;}
if(Numero<1000){Marque="00"+Numero;}
if(Numero<100){Marque="000"+Numero;}
if(Numero<10){Marque="0000"+Numero;}
NouveauNomChamp= »Num »+Numero;
this.addField(NouveauNomChamp, »text »,indexpage,rectangle[indexchamp]);
this.getField(« Commentaires »).value=this.getField(« Commentaires »).value+ »rPage « +indexpage+ » Ajout de « +NouveauNomChamp;
this.getField(NouveauNomChamp).value=Marque;
}
indexpage=indexpage+1;
}
this.getField(« Commentaires »).value=this.getField(« Commentaires »).value+ »rTerminé. »;
}
}
Vous trouverez une page « PageMaster.pdf » dans le post qui suit.
Voilà.
[attachment deleted by admin]