Yes. You need to add the page numbers via form fields. Make sure that you have a unique form field name for every page number you want to add (otherwise it gets a bit more complicated).
So let's assume you have a 3 page document, where pages 2 and 3 will get converted to page templates. To make sure that your field names are unique, either do not use the bRename parameter in the spawn call, or set it to true (see http://livedocs.adobe.com/acrobat_sdk/11/Acrobat11_HTMLHelp/JS_API_AcroJS.89.1221.html for more information).
Now add text fields to each page and name them e.g. "PageNumber_P1", "PageNumber_P2" and "PageNumber_P3". Create a custom calculation script for each of these fields, and use the following code:
event.target.value = event.target.page + 1;
Make the fields read-only so that nobody can modify your page numbers.
There is one problem - when a page gets spawned, it's fields are not recalculated, so we need to force the recalculation after we spawn the page, so add the following line to the code from the tutorial - after you spawn the page:
this.calculateNow();
This should do the trick.
Karl Heinz Kremer
PDF Acrobatics Without a Net
PDF Software Development, Training and More...
http://www.khkonsulting.com