Skip to main content
Participating Frequently
September 13, 2023
Question

Trying to multiplicate pages with Adobe Acrobat and Java

  • September 13, 2023
  • 3 replies
  • 1717 views

Hello adobe Community,

 

I'm trying to implement a simple java script to copy a certain amount of pages from my own document. It should be implemented with a dropdown-menu, but even with a simple button it did not work. I read in "Developing Acrobat Applications Using JavaScript" how to do it and it states:

 

For example, the following code inserts pages 2 through 5 from mySource.pdf at the beginning of the
current document:
this.insertPages({
nPage: -1,
cPath: "/C/temp/mySource.pdf",
nStart: 2,
nEnd: 5
});

 

I changed out cPath with the path of my current document and also with "this.path" (without ""), and on button press, only my alert shows up at the start of this script, but not in the end. What am I doing wrong? 

Kind regards

 

NW

This topic has been closed for replies.

3 replies

try67
Community Expert
Community Expert
September 13, 2023

You can't run this code from a button on its own. The insertPages command requires a special context in which it is allowed to run. Check the JS Console and you should see an error message like this:

 

NotAllowedError: Security settings prevent access to this property or method.
Doc.insertPages:5:Field Button1:Mouse Up

Participating Frequently
September 13, 2023

That's what I just found out right now. How do I fix this issue?

try67
Community Expert
Community Expert
September 13, 2023
Bernd Alheit
Community Expert
Community Expert
September 13, 2023

Use template pages and spawn this pages.

Participating Frequently
September 13, 2023

Is there an easy way to do that? I just want to copy two pages of my script 1/2/3/4/x times depending on a value in the dropdown-menu.

Bernd Alheit
Community Expert
Community Expert
September 13, 2023
Participating Frequently
September 13, 2023

I got a little further, I found out how to open the console and debugger: NotAllowedError. Gotta look into that!