Skip to main content
vigneshs53970460
Known Participant
November 17, 2016
Question

Copy a page using JavaScript

  • November 17, 2016
  • 10 replies
  • 5123 views

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 has been closed for replies.

10 replies

vigneshs53970460
Known Participant
November 22, 2016

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.

Legend
November 22, 2016

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.

vigneshs53970460
Known Participant
November 22, 2016

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?

vigneshs53970460
Known Participant
November 22, 2016

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"

try67
Community Expert
Community Expert
November 22, 2016

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.

vigneshs53970460
Known Participant
November 22, 2016

It's works fine. Thanks.

vigneshs53970460
Known Participant
November 18, 2016

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.

try67
Community Expert
Community Expert
November 18, 2016

The script I provided above does that.

vigneshs53970460
Known Participant
November 18, 2016

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

Page 1:

Page 2:

vigneshs53970460
Known Participant
November 18, 2016

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.

try67
Community Expert
Community Expert
November 18, 2016

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)

vigneshs53970460
Known Participant
November 18, 2016

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.

try67
Community Expert
Community Expert
November 18, 2016

So just spawn it again from the Template...

Inspiring
November 17, 2016

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