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

Code to merge two PDFs of scanned book: one of odd pages, the other of the even pages.

New Here ,
Jun 10, 2016 Jun 10, 2016

Copy link to clipboard

Copied

I am looking for an efficient way to merge two PDFs: one with all odd pages scanned from a book, one with all even pages. This question has been posted many times in many different forums.  I am unable to get the Javascript given in the following forum to work.  https://forums.adobe.com/thread/286654.  Generally, answers to this question are not helpful to me because 1) they provide instructions that apply to an earlier version of Adobe (I’m using Adobe Acrobat Pro DC), or 2) they involve purchasing software that I have found to be ineffective. A step by step post to complete code that can do the job and be pasted and saved as a custom command through the command Wizard (see the Jan 13, 2016 11:27 AM post at https://forums.adobe.com/thread/2063936, for an example of a good answer to a different question) would be much appreciated.  Thanks, Carl

TOPICS
Acrobat SDK and JavaScript

Views

13.2K

Translate

Translate

Report

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 , Jun 10, 2016 Jun 10, 2016

You can use a big portion of the script that was posted in the other thread and create a custom command out of it. It actually makes the script easier to understand, because all the "stuff" that is about adding menus and elevating the scripts rights is not necessary anymore.

See here for instructions about how to create a custom command in Acrobat DC:

Create Custom Commands in Adobe Acrobat DC Pro - KHKonsulting LLC

Instead of the sample code from the blog post, you would use this (which is really

...

Votes

Translate

Translate
Community Expert ,
Jun 10, 2016 Jun 10, 2016

Copy link to clipboard

Copied

Well, if you're interested in a tool that is guaranteed to do it, and is compatible with Acrobat DC (although it's not free), check out this one I've developed: Custom-made Adobe Scripts: Acrobat -- Combine Even-Odd Pages

Votes

Translate

Translate

Report

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 ,
Jun 10, 2016 Jun 10, 2016

Copy link to clipboard

Copied

You can use a big portion of the script that was posted in the other thread and create a custom command out of it. It actually makes the script easier to understand, because all the "stuff" that is about adding menus and elevating the scripts rights is not necessary anymore.

See here for instructions about how to create a custom command in Acrobat DC:

Create Custom Commands in Adobe Acrobat DC Pro - KHKonsulting LLC

Instead of the sample code from the blog post, you would use this (which is really just a copy&paste from the original script):

    // create an array to use as the rect parameter in the browse for field

    var arRect = new Array();

    arRect[0] = 0;

    arRect[1] = 0;

    arRect[2] = 0;

    arRect[3] = 0;

    // create a non-visible form field to use as a browse for field

    var f = this.addField("txtFilename", "text", this.numPages - 1, arRect);

    f.delay = true;

    f.fileSelect = true;

    f.delay = false;

    // user prompted to select file to collate the open document with

    app.alert("Select the PDF file to merge with")

    // open the browse for dialog

    f.browseForFileToSubmit();

    var evenDocPath = f.value;

    var q = this.numPages;

    var t = app.thermometer;

    t.duration = q;

    t.begin();

    // insert pages from selected document into open document

    for (var i = 0; i < q; i++) {

        var j = i * 2;

        this.insertPages(j, evenDocPath, i);

        t.value = i;

        t.text = 'Inserting page ' + (i + 1);

    }

    t.end();

    // remove unused field

    this.removeField("txtFilename");

Given the instructions in my blog post, you should be able to create this custom command and run it. For running it, the important part is that you load the "odd" part of the document first, then start the custom command and then select the "even" part of the document.

Votes

Translate

Translate

Report

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 ,
Jun 15, 2016 Jun 15, 2016

Copy link to clipboard

Copied

Hi Karl,

Thanks for making that so incredibly easy, that worked perfectly.

Carl

Votes

Translate

Translate

Report

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 ,
Jul 06, 2016 Jul 06, 2016

Copy link to clipboard

Copied

Hi Karl,

Is there a way to do this with Adobe Acrobat Standard DC?

thanks,

Michelle

Votes

Translate

Translate

Report

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 ,
Jul 07, 2016 Jul 07, 2016

Copy link to clipboard

Copied

All of the solutions described above should work with Acrobat Standard DC. I know that my tool (linked to above) does.

Votes

Translate

Translate

Report

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 ,
Jul 07, 2016 Jul 07, 2016

Copy link to clipboard

Copied

Actions (and because of that I assume custom commands) are a Pro only feature, so you would not have access to the same simple setup I outlined. For the Standard version, you would have to use the original approach described here: Combining an even pages file and an odd pages file into one PDF achieving propper order

I just tested the script from that thread, and it works with Adobe Acrobat DC - you end up with two new menu items in the "Edit" menu. You want to use the "Collate" menu with the "odd" document already loaded in Acrobat. It will then prompt you to select the "even" document and combine the two.

Votes

Translate

Translate

Report

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 ,
Feb 23, 2017 Feb 23, 2017

Copy link to clipboard

Copied

I don't know if I'm just not doing this correctly or if it just doesn't work this way in my version, but it doesn't seem to be working for me in Acrobat Pro XI.  Also I'm looking for a slightly more complicated collation method.  Basically I need to combine page 1 from document 1, with pages 2 and 3 from document 2, and so on to the end of the documents.

Votes

Translate

Translate

Report

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 ,
Feb 23, 2017 Feb 23, 2017

Copy link to clipboard

Copied

What problems are you running into with Acrobat XI Pro? Which script are you using? You will have to modify the script to get the behavior you want. With a little background in JavaScript, it should not be a problem to adjust the script.

Votes

Translate

Translate

Report

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 ,
Feb 23, 2017 Feb 23, 2017

Copy link to clipboard

Copied

Actually, I got it to work now, action created, its my first time using javascript in a pdf. And I misworded the original, I need page 1 from doc 1 and pages 1&2 from doc 2, and so on.

Votes

Translate

Translate

Report

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 ,
Jul 30, 2021 Jul 30, 2021

Copy link to clipboard

Copied

Thank you so much for this answer; definitely saves me a lot of time (I had to manually sort through the odd and even pages before). Confirming that this solution still works for Adobe Acrobat Pro DC in 2021.

Votes

Translate

Translate

Report

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 ,
Aug 28, 2021 Aug 28, 2021

Copy link to clipboard

Copied

@Karl Heinz Kremer  this script is still running strong in 2021.  Your process worked flawlessly and is greatly appreciated--that's 78 pages I didn't have to spend time manually rearranging.  Thank you.
Software: Acrobat Pro DC

Votes

Translate

Translate

Report

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 ,
Jan 03, 2022 Jan 03, 2022

Copy link to clipboard

Copied

just incredible! thank you Karl!

Votes

Translate

Translate

Report

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 ,
Dec 06, 2022 Dec 06, 2022

Copy link to clipboard

Copied

Hi Karl,

 

I've been searching (unsuccesfully so far) to find a way to merge two documents, but collate them such that each page from Document B is inserted just after a certain page in Document A. Perhaps after every page that has the word "Apple" on it from Document A.

 

For example:

A1 (has the word "Apple")

B1

A2

A3

A4 (has the word "Apple")

B2

A5 (has the word "Apple")

B3

A6

A7 (has the word "Apple")

B4

 

I'm sure there is a way to make this happen, I'm just very rusty with coding. If you have any tips for me to look into, I would be appreciative!

 

thank you!

Katie

Votes

Translate

Translate

Report

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 ,
Dec 06, 2022 Dec 06, 2022

Copy link to clipboard

Copied

LATEST

The two things are quite different and will require different approaches. The latter is much more complicated, of course.

 

Votes

Translate

Translate

Report

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
Explorer ,
Aug 20, 2018 Aug 20, 2018

Copy link to clipboard

Copied

One small point, which is obvious (but an idiot like me missed it): both documents need to have the same number of pages. If you didn't scan the last page because it was blank, the script will hang forever.

Votes

Translate

Translate

Report

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 ,
Jun 28, 2019 Jun 28, 2019

Copy link to clipboard

Copied

It is not working for me.

It is only inserting the first page of the document 2 in the document 1, nothing more.

Can you help me, Karl Heinz Kremer ?

Does anyone else know what the problem is?

Votes

Translate

Translate

Report

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 ,
Jul 01, 2019 Jul 01, 2019

Copy link to clipboard

Copied

It worked for everybody else, so I would assume there is something wrong with your code. Are you getting any errors on the JavaScript console?

Votes

Translate

Translate

Report

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