Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
I got a little further, I found out how to open the console and debugger: NotAllowedError. Gotta look into that!
Copy link to clipboard
Copied
Use template pages and spawn this pages.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Look at the documentation:
https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#template
Copy link to clipboard
Copied
Thanks! Will look into that.
Copy link to clipboard
Copied
Might it be easier to duplicate the pages 4 times each and make them hidden until 2/3/4 is chosen?
Copy link to clipboard
Copied
It's easier, but won't work in Reader...
Copy link to clipboard
Copied
Dang! Pretty difficult to do something which looks so easy on paper. Thank you both for your replies!
Copy link to clipboard
Copied
I've tried the code from the documentation,
var a = this.templates;
for (i = 0; i < a.length; i++)
a[i].spawn(this.numPages, false, false);
but a is always null. Nothing works with templatesand spawning them for me. I also tried spawnPageFromTemplate but this didn't work either.
Copy link to clipboard
Copied
Have you defined the template pages?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
That's what I just found out right now. How do I fix this issue?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks!