Help > Learning Resources > Tips for creating PDFs > How to duplicate pages in a PDF form using JavaScript

How to duplicate pages in a PDF form using JavaScript

While capturing data in a form in some cases extra pages with designated fields need to be added. For example, more photo fields should be added to the inspection checklist. 

We can suggest to you several ways how to duplicate pages in a PDF form:

1. In the Fluix app, you can copy pages on the go on the iOS device. Here is a separate guide on how to do this.
2. In Adobe Acrobat Pro, you can add JavaScript to the form template.

How the script works

This duplicate function copies a source page and inserts it into a document after another specified page. 

Note: You will need an Adobe Acrobat Pro license. This function is developed by Fluix and won’t be available when working with the document in Adobe Acrobat or any other PDF editor.

Steps to add the script

Step 1: Open your PDF form in Adobe Acrobat, choose the Prepare Form mode and click on the button as shown below:

Step 2: Having clicked on the button, drag it to the designated place in your form and specify its field name in the popup (the name will be shown to you only in the Adobe Acrobat, while it won’t be displayed to the app users in Fluix):

Step 3: Click All Properties to proceed with configuring the actions for this button. 

Step 4: Go to the Actions tab, select Mouse up as a trigger, select Run a JavaScript as an action and click Add to specify the following Javascript: 

var sourcePageIndex = *page number*;
var pageIndex = *page number*;
this.flx_copyPage(sourcePageIndex, pageIndex);


The index value of the pages starts from 0, i.e. the first page of the document = 0, the second one = 1, the third = 2, and so on. If it’s needed to insert the copied page before the first page, the index value should be -1. 

For example, the JavaScript below copies the first page and inserts it after the third page of the document:

Once the JavaScript is created, click OK.

Note: The function may display alerts using a standard app.alert() PDF JavaScript method (NOTE: The function fails silently in case invalid page indices are passed as arguments).

Step 5 (optional): To inform the Fluix app users about the action this button performs, go to the Options tab and select whether you would need to add a Label or Icon to the button.

Step 6: Once done, click Close, ​​save changes to the PDF and upload it to the storage folder that is used in a workflow.

Button in a Form

Users in the Fluix app will be able to add pages with a click of a button:

In case of any questions feel free to contact us at

Was this article helpful?
Thanks for your feedback!
Oops, something went wrong. Please, try again later.
We're sorry about that, please contact our support for help.
0 out of 2 found this helpful

Sign Up to Our Product Newsletter

The latest updates from our Product team, straight
to your inbox