PDF In-Depth

JavaScript - spawnPageFromTemplate method for templates

January 22, 2000


This code requires Acrobat Exchange. Ok - finally here's a example that proves templates are possible. It uses the JavaScript spawnPageFromTemplate method. If you're too short of time to try this yourself.

To recreate this on your own system, perform the following.

  1. Create a PDF with a front page, and then a subsequent number of pages you wish to use for templates.
  2. Move to the first page you wish to use as a template.
  3. Open the page templates dialog by selecting the "Document", "Page Templates" menuitem.
  4. Add a unique name for the template page. n.b. Remember that the name is case sensitive. You also might want to click the little eyeball, this will hide the templated page from view.
  5. Repeat this for all the pages you wish to use as templates. Be sure to note down the names of the templates, you'll need them later.
  6. Move to the first page of your PDF. This should not be a template page for this example.
  7. Place a number of form field buttons on the page. Give each one a unique name, and add an "OnMouseUp" event, selecting JavaScript as the action.
  8. Ok - here's where you need those template names you were asked to note down.
  9. In the JavaScript editor, type the following,
  10. Now repeat this for each button on your front page.
  11. That's it - you're all finished. Change back to the "hand" tool and when you click a button a new page is spawned. Voila! (you can spawn as many pages as you like).
PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Quick PDF Library

Get products to market faster with this amazing PDF developer SDK. Over 900 functions and an equally...

Download free demo

Five visions of a PDF Day

In the world of PDFs or as we like to say Planet (of) PDF, a year isn't a real PDF year without an intense few days of industry knowledge sharing.

May 15, 2018
Platinum Sponsor

Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.


Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.