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

Add New Page Javascript Button

New Here ,
May 31, 2023 May 31, 2023

I have a security work shift log MSWord file of which a separate file gets filled out by each subsequent shift. My goal is to create a single file for all future shift logs to be contained. I have created a form file and have added a button at the bottom of the form file page which should invoke the following insert new file javascript when clicked on: 

this.insertPages({nPage:this.numPages-1, cPath:"log-template.pdf"});

 However, after exiting the form editor and saving the file, I click on the button and nothing happens. Both the source and the insert (Log-Template) document forms are in the same directory. Please assist. Files are attached...

 

Thanks, David

TOPICS
How to , JavaScript , PDF forms
705
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 ,
May 31, 2023 May 31, 2023

Open the JS Console (Ctrl+J) and you'll see an error message after clicking the button.

The reason is this method require a trusted context to run, such as a folder-level script. If you're the only one who's going to use it, then you can create this script file and install it on your machine and then it would work.

If others need to use it, too, then you would have to do the same on their machines, as well. Oh, and it won't work in Reader, only in Acrobat.

Another option is to create a (hidden) Template page from this file, and then spawn copies from it when new pages are needed. This would not require installing a script file, and would work in 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
Community Expert ,
May 31, 2023 May 31, 2023
LATEST

As noted by Try67, the correct way to add pages to a PDF is to use a Page Template. 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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