Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Strange issue with spawning additional pages from template

New Here ,
Feb 03, 2016 Feb 03, 2016

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.

TOPICS
Acrobat SDK and JavaScript , Windows
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 03, 2016 Feb 03, 2016

What version of Adobe Acrobat do you use?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 03, 2016 Feb 03, 2016

Oh, I forgot to mention the Acrobat versions.

Developing/Testing on Acrobat Pro DC 2015.010.20056 (Mac)

Testing on Acrobat Reader DC 2015.010.20056 (Win)

Happens on a friends and clients PC's too, not sure what Versions they have in use.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 03, 2016 Feb 03, 2016

The numPages property for the PDF file returns the number of pages in the PDF.

When specifying a specific page within the file using JavaScript  one needs to use the zero based page number. So the last page of the PDF has an internal page value of "this.numPages - 1"; not "this.numPages;". And that is why you are one off or were you want the pages inserted.

Also as new pages are added the number of pages changes so you may need to allow for this change with each new added page before adding the next page.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 04, 2016 Feb 04, 2016

gkaiseril schrieb:

The numPages property for the PDF file returns the number of pages in the PDF.

When specifying a specific page within the file using JavaScript  one needs to use the zero based page number. So the last page of the PDF has an internal page value of "this.numPages - 1"; not "this.numPages;". And that is why you are one off or were you want the pages inserted.

Also as new pages are added the number of pages changes so you may need to allow for this change with each new added page before adding the next page.

I'm well aware of that. As I've written it does work just fine for the first two pages to be spawned!

When using console.println() to output the variables each time when excetuted, theses values are also correct (number of pages and the estimated position) and still it does one of the random actions mentioned in my opening post.

The function spawn() still randomly does copy, move, delete and empty out page which it is NOT supposed to do.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 04, 2016 Feb 04, 2016

The actual version of Adobe Acrobat and Acrobat Reader has bugs with spawning templates.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 09, 2016 Feb 09, 2016

Bernd Alheit schrieb:

The actual version of Adobe Acrobat and Acrobat Reader has bugs with spawning templates.

hmmm, so I'll have to wait till it got fixed?

There is no work-around / solution for this? My client is not going to be very happy about that and he won't understand it because it was working before.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 09, 2016 Feb 09, 2016

In Adobe Acrobat you can create the template page at the end of the document and move this page.

This will not work in Acrobat Reader.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 12, 2016 Apr 12, 2016

Any news to this issue?

It still doesn't seem to work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 12, 2016 Apr 12, 2016
LATEST

I know that one template related bug I reported was fixed with the latest update to Acrobat DC. Are you sure you are running the latest version? If it's not working, have you reported it to Adobe via the bug report form (Feature Request/Bug Report Form)? Just posting in the forum will in most cases not get Adobe's attention (most of us here are users of Adobe's products, just like you).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines