Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Trying to multiplicate pages with Adobe Acrobat and Java

New Here ,
Sep 13, 2023 Sep 13, 2023

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

TOPICS
JavaScript , PDF
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 13, 2023 Sep 13, 2023

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 13, 2023 Sep 13, 2023

Use template pages and spawn this pages.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 13, 2023 Sep 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 13, 2023 Sep 13, 2023
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 13, 2023 Sep 13, 2023

Thanks! Will look into that.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 13, 2023 Sep 13, 2023

Might it be easier to duplicate the pages 4 times each and make them hidden until 2/3/4 is chosen?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 13, 2023 Sep 13, 2023

It's easier, but won't work in Reader...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 13, 2023 Sep 13, 2023

Dang! Pretty difficult to do something which looks so easy on paper. Thank you both for your replies!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 14, 2023 Sep 14, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 14, 2023 Sep 14, 2023
LATEST

Have you defined the template pages?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 13, 2023 Sep 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 13, 2023 Sep 13, 2023

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 13, 2023 Sep 13, 2023
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 13, 2023 Sep 13, 2023

Thanks! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines