Salir
  • Comunidad global
    • Idioma:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

Give a number page to a template

Nuevo aquí ,
May 09, 2018 May 09, 2018

Hi everyone !

i'am usign acrobat DC (15) on windows.

I have pages spawning when a button is clicked. I would like to display dynamically the page number of a spawned page. In other words, my document has initailly 1 page ( with 8 templates), when the user decides to spawn a page or more, i have a little "blank space" where i would like to display page number.

i am a newbie !!!

thx for evertyhing 😃

TEMAS
Acrobat SDK y JavaScript , Windows
1.6K
Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Community Expert ,
May 09, 2018 May 09, 2018

Add text fields for the page numbers to the templates.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Nuevo aquí ,
May 09, 2018 May 09, 2018

thx !

but the pages could be spawned in any order, so inside the first page, the number of page should change, et depending on which pages will be spawned, the number should also appear in the pages spawned.

For example,

First page : 1/1

then,template page A and template page B are spawned ( the order could change)

so

the firest page 1/3

and template page A : page 2/3

and template page B : page 3/3

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Community Expert ,
May 09, 2018 May 09, 2018

After spawning the page you must set the value of the text field.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Nuevo aquí ,
May 09, 2018 May 09, 2018

can i have a little bit of code ?=) thx

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Comprometido ,
May 09, 2018 May 09, 2018

Post the code for your button and we will update it with what's missing

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Nuevo aquí ,
May 09, 2018 May 09, 2018

here it is :

// get the value from the dropdown control

var sel = this.getField("liste_qualif").value;

// determine the template name

var templateName = "";

switch (sel) {

  case 1: templateName = "CRI";

    break;

  case 2: templateName = "FI";

    break;

  case 3: templateName = "FTI de FTI";

    break;

    case 4: templateName = "FTI";

    break;

    case 5: templateName = "IRI";

    break;

    case 6: templateName = "MCCI";

    break;

    case 7: templateName = "SFI";

    break;

    case 8: templateName = "STI";

    break;

    case 9: templateName = "TRI";

    break;

}

// if we have a template name, spawn the template

if (templateName != "") {

  var t = this.getTemplate(templateName);

  t.spawn();

}

//pop up for the user

var message = app.alert("Vous avez sélectionné une qualification d'instructeur \n\n"+"La page concernant la qualification vient d'apparaître à la fin du document",1);

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Comprometido ,
May 09, 2018 May 09, 2018

Add a field at the bottom of each pages and each template.

Put this in the calulate script:

event.value = "Page "+this.pageNum+" / "+this.numPages

by the way, you do not have to put your alert inside a variable to trigger it ;o)

//pop up for the user

var message = app.alert("Vous avez sélectionné une qualification d'instructeur \n\n"+"La page concernant la qualification vient d'apparaître à la fin du document",1)

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Comprometido ,
May 09, 2018 May 09, 2018

Also, I think the switch statement is not necessary.  You could use those abreviations directly as export values right from your dropdown menu.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Nuevo aquí ,
May 09, 2018 May 09, 2018

thx !!!! for the tips and advice ... 😃

however, i ve putted this code in a the main page and 2 templates ( just to try if it works ) ... some problems appear :

The " this.pageNum" does'nt seem to work, because it's blocked at 0, and instead of incrementing the total number of page, it decreases.

For example, page 1 : 0/1,

after spawning a page : page template A : 0/1 AND page 1 : 0/2

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Nuevo aquí ,
May 09, 2018 May 09, 2018

actually, only the last decreases of "1"

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Nuevo aquí ,
May 09, 2018 May 09, 2018

you can find my file here : 00Formlic_Interactif_js_v5.pdf - Google Drive

you need to select : either TRI or STI in the dropdown list and then validate with the button just on the right. It's in french ...

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Comprometido ,
May 09, 2018 May 09, 2018

I'm french also, lol

pageNum is 0-based also so you have to give it an increment

event.value = "Page "+(this.pageNum+1)+" / "+this.numPages

and since this script is a calculate script (and the spawning of a template doesn't trigger the calculate event), you need to trigger it manually.

put this:

this.calculateNow()

right after the spawn() function in the button

Othewise, it would have triggered as soon as you enter whatever in whaterver field.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Nuevo aquí ,
May 11, 2018 May 11, 2018

Thx !!! ( j'étais en jour off, c'est pour a que j'ai mis du temps à répondre ) ...

Now the total amount of page is OK 😃

but ... i have still a little problem, it's still block at 0 for the current page, the number doesnt incremente ?

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Nuevo aquí ,
May 11, 2018 May 11, 2018

i need to find a scirpt, which allow to take into consideration whatever order the pages will be spawed and give the the right number

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Community Expert ,
May 11, 2018 May 11, 2018

Bonjour.

Une réponse claire et en français se trouve ici : https://abracadabrapdf.net/forum/index.php/topic,3224.msg18951.html#msg18951

Enjoy.


Acrobate du PDF, InDesigner et Photoshopographe
Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Nuevo aquí ,
May 11, 2018 May 11, 2018

Merci !

Mais cela ne marche que pour les pages ayant été DUPLIQUEES et SPAWNED ( simultanément) =(

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Comprometido ,
May 11, 2018 May 11, 2018

What do you mean by "take into consideration whatever order the pages will be spawed"?  Doesn't spawned pages append to the end of the document?  Therefore, their order in the document is the same as the order they were spawned?

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Nuevo aquí ,
May 11, 2018 May 11, 2018

Yes, i meant that ...

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Comprometido ,
May 11, 2018 May 11, 2018

The script I wrote, And the link provided by @JR_Boulay , they do just that.

My script:

this.pageNum() method returns the position of the page in the document as a 0-Based index.  Therefore, this.pageNum()+1 is the number of the page.

@JR_Boulay's script:

the "page" property of the field object (event.target.page) as described in the post returnes the same thing but will return an array of integer if there is more than one occurence of the same field, based on the order they were created.

I tested my script in your document.  It works fine except for some reason, the calculateNow() method doesn't trigger fast enough for the fields to update.  It updates as soon as a value is commited anywhere in the document (because it is a calulate script)

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Comprometido ,
May 11, 2018 May 11, 2018

Try the solution posted by JR_Boulay.  But for that to work, the field of your main page must be different from the on in your templates.  Whenever I change the script in "Text27", it changes acoordingly in P1.TRI.Text27.      Since both scripts are slightly different, you need to independant fields.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Community Expert ,
May 14, 2018 May 14, 2018
MÁS RECIENTES

I use a trick: I never spawn/add one page somewhere in a document: first I delete all pages and I re-spawn all pages in their final order, starting by the end. This is usefull for small documents, less than 50 pages, since you never have to manage a relative pages order.

the calculateNow() method doesn't trigger fast enough

Add this script at the beginning of the script:

this.calculate = false;

And add this one at the end :

this.calculate = true;

this.calculateNow();


Acrobate du PDF, InDesigner et Photoshopographe
Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines