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

Duplicate page

Community Beginner ,
Jan 13, 2017 Jan 13, 2017

Hi!

I need to make an action which duplicates page 1, 8 times in a 3 page pdf. I have found some scripts, but I can’t make them work. Can someone help me with some java that will work with action wizard? ( I don’t know much about java scripting, normally I just copy/paste scripts.)

TOPICS
Acrobat SDK and JavaScript
4.2K
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

correct answers 1 Correct answer

Community Expert , Jan 13, 2017 Jan 13, 2017

Sure.

for (var i=1; i<=8; i++) {

    this.insertPages ({

        nPage: -1,

        cPath: this.path,

        nStart: 0

    });

}

Translate
Community Expert ,
Jan 13, 2017 Jan 13, 2017

This code duplicates the first page. Run it 8 times to get 8 copies...

this.insertPages ({

    nPage: -1,

    cPath: this.path,

    nStart: 0

});

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 Beginner ,
Jan 13, 2017 Jan 13, 2017

Thanks
How do I set it to do it 8 times?

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 ,
Jan 13, 2017 Jan 13, 2017

Either duplicate the code eight times (ugly) or use a for-loop from 1 to 8

and put the code in it.

On Fri, Jan 13, 2017 at 3:43 PM, ingerlouiset <forums_noreply@adobe.com>

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 Beginner ,
Jan 13, 2017 Jan 13, 2017

I would prefer not to duplicate the code 8 times... could you you ad the for-loop to the code?

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 ,
Jan 13, 2017 Jan 13, 2017

Sure.

for (var i=1; i<=8; i++) {

    this.insertPages ({

        nPage: -1,

        cPath: this.path,

        nStart: 0

    });

}

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 Beginner ,
Jan 13, 2017 Jan 13, 2017

Thank you SO much

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 Beginner ,
Jan 16, 2017 Jan 16, 2017

Hi again.
Unfortunately, the script only worked twice. The third time I used it, it only made one page instead of 7. I adjusted the script a bit, but it still worked - well at least twice.

for (var i=1; i<=7; i++) { 

    this.insertPages ({  

        nPage: -1,  

        cPath: this.path,  

        nStart: 1  

    });  

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 ,
Jan 16, 2017 Jan 16, 2017

Why did you change the nStart parameter to 1? Do you want to duplicate the second page? If so, then you would need to adjust more things, because after the first run the second page is not the third, so you'll be duplicating the (previously) first page in the next iteration...

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 Beginner ,
Jan 16, 2017 Jan 16, 2017

Yes, it was the second page I needed to duplicate instead.
The strange thing is that the changed script works on a colleagues computer and at home, but not at work.
The script from friday (unchanged) is not working any longer. It's only making one copy of the first page.

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 ,
Jan 16, 2017 Jan 16, 2017

Are you sure you're executing the full code? You need to select it all before running it, if you're using the JS console.

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 Beginner ,
Jan 16, 2017 Jan 16, 2017

Yes I am. I have tried it on several computers, Acrobat DC/XI. For some reason the script is not working on my work station, but on all my colleagues computers. I just have to run a modified script on my computer.

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 ,
Jan 16, 2017 Jan 16, 2017

Are you getting any error messages on the console? What is the script you are running now (after making the adjustment for the now changing source page number)?

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 Beginner ,
Jan 16, 2017 Jan 16, 2017

No error. It just duplicates page 2 one time and that's it.

This is the script:

for (var i=1; i<=7; i++) {

    this.insertPages ({

        nPage: 0,

        cPath: this.path,

        nStart: 1

    });

}

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 Beginner ,
Jan 16, 2017 Jan 16, 2017
LATEST

I have now been working on a different document, with a slightly modified script. one page, duplicated 6 times (then the 6 pages are cropped into 6 different page sizes, haven't mentioned it before) and saved. Exactly like the 8 paged document, only this one was a native one paged document.
I ran it through several times, checking that the pages were cropped into the right sizes. Suddenly the same error: makes only one copy instead of 6 pages.

for (var i=1; i<=6; i++) { 

    this.insertPages ({  

        nPage: -1,  

        cPath: this.path, 

        nStart: 0  

    });  

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