Skip to main content
hursey
Known Participant
January 24, 2016
Answered

Insert page from template in Acrobat

  • January 24, 2016
  • 1 reply
  • 1403 views

I have followed a couple tutorials online showing the process of creating a button with which to add a new page (from a template) inside Acrobat. However I am unable to get it to work.

I am creating a button using the action - Java Script: 

var a = this.getTemplate("MyTemplate");

  1. a.spawn

And renaming the template to the one I saved But cannot get the action to work.

Any guidance would be much appreciated.

The info graphic I followed is:

https://acrobatusers.com/tutorials/how-to-build-a-button-that-creates-a-new-page

And others show basically the same procedure.

This topic has been closed for replies.
Correct answer try67

First of all, it needs to be:

a.spawn();

But the error message means there's no template with that name in your file.

1 reply

Inspiring
January 25, 2016

What you posted is:

a.  a.spawn

But it should be just:

a.spawn

After clicking the button, you should see if there are any error messages in the JavaScript console by pressing cmd+J.

hursey
hurseyAuthor
Known Participant
January 25, 2016

Thanks I think that was a typo in my [post...

Here is a copy and paste of the exact Java script (my template is called "add"):

var a = this.getTemplate("add");

a.spawn

Pressing cmd+j after clicking the button with no results gets:

TypeError: a is null

2:Field:Mouse Up

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
January 25, 2016

First of all, it needs to be:

a.spawn();

But the error message means there's no template with that name in your file.