9 Replies Latest reply on Apr 12, 2016 5:45 AM by Karl Heinz Kremer

    Strange issue with spawning additional pages from template


      Hi everybody,


      I hope I'll get or find a solution to my problem I came across and I can't figure out why it does happen.


      For a client I created an Acrobat Form wich has a basic layout of 5 pages and 4 hidden page templates. These, if needed for that case, can be spawned by pushing a button which spawns the needed page before the last 3 pages (in the middle of the document). Does happen on Acrobat Pro and Reader on Mac and Windows

      So I came up with the following script to do so which is the same for all for spawnable pages except the template name:


      // pageSpawn

      var pageCount = 0;

      var pagePos = 0;

      pageCount = this.numPages;

      pagePos = pageCount-3;

      var b = getTemplate("TemplateName");

      b.spawn({nPage: pagePos, bRename: false, bOverlay: false});


      This works like a charme for the first two templates to be spawned. They are in the correct position, all fields are there, the pages after the newly spawned are all fine.

      But now things start to get strange. When the third page is spawned, four things can happen randomly:

      1. the spawned page is in the wrong position, mostly it is spawned before the last two pages instead of three and after the former third to last page

      2. the spawned page is ontop of the third to last page

      3. it copies the third to last page, but the template does not show

      4. the page is spawned before the last two page and the former page in this position is gone


      This can even be replicated by using an pdf with no content on it except page indicators to see what happens. I put up an empty pdf with 4 pages wich just contain 1 headline wich sais "page 1, page 2" and so on.

      I then create an empty page template with the headline "empty" to see where it spawns. Excecuting the script from JavaScript-Debugger and also a created button.

      Same random behavior as in the pdf with content in it. As a note: this does not happen when spawning at the end of the document.


      I've already spent hours searching the internet to find a soulution for this problem or am I missing here on something?

      Hope someone came across this and has a solution or hint where to take a look for me.

      Thanks in advanced.


      If more info is needed, just let me know.