Skip to main content
alexisr96992484
Participant
September 1, 2016
Answered

utilisation de movepage

  • September 1, 2016
  • 5 replies
  • 3057 views

Bonjour

Savez vous pourquoi la fonction movepage fonctionne très bien avec un pdf ouvert depuis adobe pro, mais ne fonctionne pas si on l'ouvre avec reader?

Mon besoin initial est le suivant:

Voilà deux jours que j'essaie en vain d'utiliser correctement la fonction duplicata de modèle

Voici la méthode que j'ai enployée

-> J'ai un document de 21 pages

-> J'ai créé ma page modèle appelée AnnexA1 (que je masque)

-> En page 6 de mon document j'ai un boutton d'action dont l'objectif est de placer en page 7 +n ma page AnnexA1 autant de fois que possible

J'ai donc tenté la ligne de code suivante:

-this.spawnPageFromTemplate("AnnexA1")

Résultat mes annexes se placent en fin de document donc en page 22 + N mais fonctionnent correctement. Il n'y a pas d'interraction entre les champs

J'ai donc tenté la ligne de code suivante:

-this.spawnPageFromTemplate("AnnexA1", pageNum + 1, false, false)

Résultat les annexes se placet bien en page 7 + n mais les champs interragissent entre eux (lorsque je rente "blabla" dans le champs de ma première page duppliquée, ça le reporte dans la seconde, et vis versa)

J'ai tenté les différentes combinaisons de false/true mais rien de mieux visiblement

J'ai alors 'triché' en combinant la première solution, plus en déplaçant ma page avec la fonctino move:

-var placement= pageNum

-this.spawnPageFromTemplate("AnnexA1")

-this.movePage(this.numPages-1,placement)

ça fonctionne? et bien, non, ça fonctionne uniquement avec adobe pro XI

Ce code n'est pas compris par adobe reader XI qui ne prend pas en compte la ligne this.movePage et donc laisse les annexes en fin de document

Quelqu'un aurait une solution?

Merci

This topic has been closed for replies.
Correct answer George_Johnson

Thanks for your answer, but as you can see on my last post, I have used the function described on the Acrobat JavaScript documentation

t.spawn(pageNum+1, true, false)

what is underline is the bRename option avec with "true" normally, the fields are suposed to be renamed. It works well if you create the page at the end of the document. But as soon as I put "PageNum +1" on the option nPage, then it does not works anymore and fields are not renamed


You need to understand how the fields are renamed. The new field names depend on the page number of the newly created page, which in your code is the same. So the renamed fields of the last two pages that were added end up with the same names. So you have to keep track of how many times the template has been spawned and figure out the correct value for the nPage parameter so that the renamed fields don't clash with those on a page that was created by spawning the template previously.

5 replies

JR Boulay
Community Expert
Community Expert
September 4, 2016

Thank you.

Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
Community Expert
September 4, 2016

Do you mean that "JavaScript™ for Acrobat® API Reference - Adobe® Acrobat® DC SDK - May 2015" is not the DC version ?

Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
Community Expert
September 4, 2016

I think it is, yes.

JR Boulay
Community Expert
Community Expert
September 3, 2016

I'm talking about the PDF version of "JavaScript™ for Acrobat® API Reference - Adobe® Acrobat® DC SDK - May 2015" too.

(Which is my bible)

Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
Community Expert
September 3, 2016

I like to use the XI version, and there it's all documented.

JR Boulay
Community Expert
Community Expert
September 4, 2016

???

About createTemplate, getTemplate, etc., I cannot find any difference between

"JavaScript™ for Acrobat® API Reference - Adobe® Acrobat® DC SDK - May 2015"

and

"JavaScript™ for Acrobat® API Reference - Adobe® Acrobat® 11 SDK - October 2012"

Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
Community Expert
September 2, 2016

Note: This method has been superseded by templates, createTemplate, and the Template object

spawn method.

Yes, but there is not any option when using createTemplate, unlike spawnPageFromTemplate

Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
Community Expert
September 2, 2016

What do you mean? What kind of option?

JR Boulay
Community Expert
Community Expert
September 2, 2016

What do you mean? What kind of option?

Sorry, I meant parameters.

createTemplate only provides:

cName and nPage

Other useful parameters provided by spawnPageFromTemplate are missing, as:

cTemplate

bRename

bOverlay

oXObject

.

Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
Community Expert
September 1, 2016

Reader can not edit PDF files. You can't use movePage in it. This is clearly stated in the JS Reference in the form of an "X" in the fourth column under the function's name:

alexisr96992484
Participant
September 1, 2016

OK, then it confirms that I cannot use the movepage function. Thanks.

Now do you have a solution to use the this.spawnPageFromTemplate function it order that

-> the models are created in the page 5 (for example) of my document

-> the fields in the template are not connected. Because with the solution I use, when I duplicate several time the template, the fields are connected: If I Fill something in the duplicated page 1, then it is automatically filled in the second dupplicated page.

It well works with this function

this.spawnPageFromTemplate("AnnexA1")

but the duplicated pages are localized at the end of the document

and with this second function it is well localized:

this.spawnPageFromTemplate("AnnexA1", pageNum + 1, false, false)

but the fields of duplicated pages are linked.......

Many thanks

try67
Community Expert
Community Expert
September 1, 2016

Again, from the JS Reference of "spawnPageFromTemplate":

Note: This method has been superseded by templates, createTemplate, and the Template object

spawn method.