Skip to main content
vigneshs53970460
Known Participant
Nov 17, 2016 3:38 PM UTC
Question

Copy a page using JavaScript

Hi,

Is there any way to copy and paste a page using "JavaScript"?

I'm working on a form, where having two pages in the second page. I'm having a button "Copy the page".

When I click it the two pages has to paste as page 3&4.

Note: The "fields" should also be paste not only the content.

Can anyone help with this

This topic is closed to new replies. Start a new post to keep the conversation going.

18 replies

vigneshs53970460
Known Participant
Nov 22, 2016 1:23 PM UTC

No, I am doing this for my end users. So, they do not aware of the acrobat forms and they are asking for the button type.

Creating spawn pages is a good method, but somehow I felt to copy and paste the page using JavaScript instead of creating spawn pages.

Translate
Legend
Nov 22, 2016 12:46 PM UTC

You are probably now aware of all the tools you have to work with. Templates, copying field values (you know the fields; can you copy the cpntents?). Can't think of any others.

Translate
vigneshs53970460
Known Participant
Nov 22, 2016 12:12 PM UTC

So, what is the solution for this?. On page 2, I have to keep a button at the bottom. So, if the user wants the page 2 again, they have to click the button and it should copy the entire page and paste it on page 3.

Can you please assist me with this?

Translate
vigneshs53970460
Known Participant
Nov 22, 2016 7:44 AM UTC

Hi,

When I insert the following script "this.insertPages(this.numPages-1, this.path, 0)" in "Button" field. I am getting this error, but in console window. it's working fine.

"NotAllowedError: Security settings prevent access to this property or method.

Doc.insertPages:1:Field Button3:MouseUp"

Translate
try67
Community Expert
Community Expert
Nov 22, 2016 8:59 AM UTC

Yes, because this method needs to run from a privileged context, which means either from the console window, inside an Action, or from a trusted function in a folder-level script.

Translate
vigneshs53970460
Known Participant
Nov 22, 2016 7:27 AM UTC

It's works fine. Thanks.

Translate
vigneshs53970460
Known Participant
Nov 18, 2016 3:16 PM UTC

I need the exact page.

It's just need to copy the entire page and paste it in next page or last page including all fields and contents.

Translate
try67
Community Expert
Community Expert
Nov 18, 2016 3:32 PM UTC

The script I provided above does that.

Translate
vigneshs53970460
Known Participant
Nov 18, 2016 3:13 PM UTC

Text field value is not showing. See the below screenshot.

Page 1:

Page 2:

Translate
vigneshs53970460
Known Participant
Nov 18, 2016 2:40 PM UTC

If suppose they have entered some value in the 2nd page. it will come not come, when I again spawn from the template.

I need a copy of second page.

Translate
try67
Community Expert
Community Expert
Nov 18, 2016 2:45 PM UTC

You can use the insertPages command to insert a page from a file into itself.

For example, this command will copy the first page of the file and insert it as the last page:

this.insertPages(this.numPages-1, this.path, 0)

Translate
vigneshs53970460
Known Participant
Nov 18, 2016 7:32 AM UTC

Thanks for your answer.

I know this method, but this will not work here because the second page is already a spawn or template page.

Translate
try67
Community Expert
Community Expert
Nov 18, 2016 8:27 AM UTC

So just spawn it again from the Template...

Translate
Inspiring
Nov 17, 2016 6:04 PM UTC

PDFs have a special type page of page called a "template" and this page can spawned or "add"  to an existing PDF. The "template" has to be part of the PDF.

http://www.planetpdf.com/developer/article.asp?ContentID=6466

A Lesson in Tem by Dave Wraight

Translate