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

Combining an even pages file and an odd pages file into one PDF achieving propper order

New Here ,
Feb 20, 2008 Feb 20, 2008

Copy link to clipboard

Copied

Hello all!

I have several documents that were scanned (in another application) using an autofeed scanner yielding one file for all frontpages (odds) and one file for all backpages (evens). I have these two files in PDF with comments on them. I would like to be able to combine the two files and achieve the right page ordering without doing it manually. Is there any way or script that may do this? I.e. insert page 1 from evens.pdf after page 1 from odds.pdf, page 2 from 2 (or 4 in real document) from evens.pdf after page 2 (3) in odds.pdf and so on?

Any advice on how to achieve this while retaining comments on both documents will be greatly appreciated.

Sincerly;

Santiago
TOPICS
Acrobat SDK and JavaScript

Views

137.1K

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
Enthusiast ,
Feb 20, 2008 Feb 20, 2008

Copy link to clipboard

Copied

This can be easily accomplished through Visual Basic using the InsertPages method.

You can find information about that in the Interapplication Communication API Reference document included with the Acrobat SDK under the section "AcroExch.PDDoc".

You can find all the relevant documentation here:
http://www.adobe.com/devnet/acrobat/?navID=documentation

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 20, 2008 Feb 20, 2008

Copy link to clipboard

Copied

Read this:
http://www.planetpdf.com/developer/article.asp?ContentID=collating_pdfs_using_javascrip&rhs_fa

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 02, 2009 Jun 02, 2009

Copy link to clipboard

Copied

Hi Bernd, thanks for posting this.  Can you explain where to place the script?  Sorry--my first time around with this.  The site says to use the Javascript Debugger...  not just create this as a script?

Thanks

JP

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 02, 2009 Jun 02, 2009

Copy link to clipboard

Copied

You can execute the code in the Javascript Debugger.

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
Enthusiast ,
Feb 20, 2008 Feb 20, 2008

Copy link to clipboard

Copied

Bernd's answer is certainly better for a scripting beginner.

Gotta love German efficiency.

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 20, 2008 Feb 20, 2008

Copy link to clipboard

Copied

Wow!!!!!!!

You guys are amazing!! Sweet deal, really appreciate it! would love to look into the BV scripting, but got a Master's thesis to finish.

Thank you guys so much!

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 13, 2009 Jun 13, 2009

Copy link to clipboard

Copied

There is a simple application I wrote, which provide a solution for that
problem exactly. It is completly free, although you are more than

welcome to donate in the site 🙂

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 ,
Oct 30, 2009 Oct 30, 2009

Copy link to clipboard

Copied

I've attached a script that adds two menu items into the "Tools" menu. "Collate" merges even and odd pages, and "Reverse" will as reverse the order of the pages in a PDF.

To install it, exit Acrobat. Save the script into Acrobat's Javascripts directory (e.g. C:\Program Files\Adobe\Acrobat 8.0\Acrobat\Javascripts ), and restart Acrobat.

I hope you find this script useful!

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 ,
Sep 28, 2011 Sep 28, 2011

Copy link to clipboard

Copied

  1. CollatePages.js (1.9 K)

was downloaded and placed in the following folder:

C:\Program Files (x86)\Adobe\Acrobat 9.0\Acrobat\Javascripts

It worked as described by “JBAITIS”.

Had to open first  the PDF file having ODD pages, in Acrobat9.

Next from “TOOLS”  selected “COLLATE”.

After a brief error message,  the name of the second PDF file having all EVEN pages was selected.

Clicked OK and done!

NB: for “COLLATE” to work you have to open a PDF file first, preferably the odd-pages PDF file.

Thank you “JBAITIS” for a GREAT and essential time-saver program, and thank you all.

Dan

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 ,
Sep 29, 2011 Sep 29, 2011

Copy link to clipboard

Copied

Here is the latest version of this script, compabible with Acrobat X. The functions have been moved into the "Edit" menu because there is no tools menu in Acrobat X. It still maintains compatibility with Acrobat 9. Unfortunately, you'll have to manually copy and paste this into a file because Adobe has disabled the file attachment feature on Jive Forums.

// Complements: Planet PDF (http://www.planetpdf.com/)

// Modified by Jeff Baitis for Acrobat 9 and Acrobat X compatibility

// Improved Collate function with status bar.

// Add a menu item to reverse all pages in the active document

app.addMenuItem({  cName: "Reverse", cParent: "Edit", cExec: "trustedReversePages();",  cEnable: "event.rc = (event.target != null);", nPos: 0 });

// Add a menu item to collate with another document on the filesystem

app.addMenuItem({  cName: "Collate", cParent: "Edit", cExec: "trustedCollatePages();",  cEnable: "event.rc = (event.target != null);", nPos: 0 });

trustedReversePages = app.trustedFunction(function()

{

  app.beginPriv(); // Explicitly raise privileges

  var t = app.thermometer;

  t.duration = this.numPages;

  t.begin();

  for (i = this.numPages - 1; i >= 0; i--)

  {

    t.value = (i-this.numPages)*-1;

    this.movePage(i);

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

  }

  t.end();

  app.endPriv();

})

// Collating pages

/*

  Title: Collate Document

  Purpose: User is prompted to select document to insert/collate.

  Author: Sean Stewart, ARTS PDF, www.artspdf.com

*/

trustedCollatePages = app.trustedFunction(function()

{

  app.beginPriv(); // Explicitly raise privileges

  // 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");

  app.endPriv();

})

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 14, 2011 Dec 14, 2011

Copy link to clipboard

Copied

This js file is exactly what I needed but I'd like to added it the batch processing function.  unfortunately when i copy the script and put it into the js sequence, it appears to run successfully but after i select the file to add, nothing happens.  any ideas?

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 ,
Oct 27, 2012 Oct 27, 2012

Copy link to clipboard

Copied

Wowie wow! This is what I've been pulling my hair out over for ages! Thank you so much for this JavaScript script. It works wonderfully and since I just wrote up a file for myself on installing and using it on a Mac, I thought I'd just copy/paste it here for other Mac users who are using Acrobat Pro X and need to collate their files. Hope this helps other Mac users:

So, for Macintosh users, there are Two Big Steps:

Big Step 1:

The CollatePages.js file has to be placed in

~/Library/Application Support/Adobe/Acrobat/10.0/JavaScripts

folder. To create the file, you can simply copy the script above then paste it into Textedit (make it a plain text file). See important note 2 below for naming it.

Five Important Notes:

  1. If you can't see the Library folder, then in the Finder, use the Option Key to select the Go menu: the home Library folder appears, which will get you into the home library folder that is normally not visible.
  2. At least for Acrobat X Pro, it can be copied and pasted into a file unaltered and it works without a problem. It doesn't really matter what the file is called just be sure to name it as a .js file, not as a .txt file.
  3. Be aware that an upgrade may make the file go away or no longer be read from the 10.0 folder! You can tell it's gone when the Collate & Reverse commands are missing under the Edit menu:CollateCmdAcrobat.png
  4. If installing after an upgrade, then it's likely the folder '10.0' will have changed. The important note is to get the file into the JavaScripts folder that Acrobat Pro reads on startup. I'm saying that here because Acrobat Pro XI is (soon to be) out so it's likely the folder will change.
  5. Last, be sure to enable JavaScripts in Acrobat Pro itself: Under Acrobat -> Preferences, scroll down in the left Categories column to JavaScript (click that). On the right side under JavaScript, be sure the first two items: "Enable Acrobat JavaScript" and "Enable menu items JavaScript execution privileges" are both checked.

Big Step 2:

In Acrobat Pro, you collate two files: The odd pages file needs to be already open and the even pages file is opened using the Collate command (now under Edit in the menubar as the picture in Note 3 above shows). The file that gets added (presumably the even pages) gets interweaved with the first (already open) file starting at the second page.

If you have separate files for each page (either because they were scanned in separately or they were extracted within Acrobat to separate files) then you first need to combine them into one file for odds and evens.

The Reverse command simply reverses the page order of the open file; possibly helpful if a source file has its pages in the opposite order before collating.

Last, you could, if you want to, click on Yes (this was helpful) below.

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 ,
Jan 05, 2015 Jan 05, 2015

Copy link to clipboard

Copied

These instructions were almost prefect, but in order to get it to work with XI,@ I modified the script.  ( changed it from the "Tools" to "Edit" menu. and it shows up under Edit! )

// Complements: Planet PDF (http://www.planetpdf.com/)

// Modified by Christian Sass for Acrobat XI compatibility

// Add a menu item to reverse all pages in the active document

app.addMenuItem({ cName: "Reverse", cParent: "Edit", cExec: "PPReversePages();", cEnable: "event.rc = (event.target != null);", nPos: 0 });

app.addMenuItem({ cName: "Collate", cParent: "Edit", cExec: "trustedCollatePages();", cEnable: "event.rc = (event.target != null);", nPos: 0 });

function PPReversePages()

{

  var t = app.thermometer;

  t.duration = this.numPages;

  t.begin();

  for (i = this.numPages - 1; i >= 0; i--)

  {

  t.value = (i-this.numPages)*-1;

  this.movePage(i);

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

  }

  t.end();

}

// Collating pages

/*

  Title: Collate Document

  Purpose: User is prompted to select document to insert/collate.

  Author: Sean Stewart, ARTS PDF, www.artspdf.com

*/

trustedCollatePages = app.trustedFunction(function()

{

  app.beginPriv(); // Explicitly raise privileges

  // 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;

  // insert pages from selected document into open document

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

      var j = i*2;

      this.insertPages(j, evenDocPath, i);

  }

  // remove unused field

  this.removeField("txtFilename");

  app.endPriv();

})

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 ,
Apr 22, 2015 Apr 22, 2015

Copy link to clipboard

Copied

Is there a way to get just the Collate part of the script as an Action in the Action Wizard? I've tried copying and pasting parts into a new action without success. I do not need the reverse function. Thanks.

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
Guest
Jun 17, 2015 Jun 17, 2015

Copy link to clipboard

Copied

Hi sastian, I know this is old, but can you tell me *where* to put this javascript?

I can run the reorder function by putting it in Actions, but the combine/coallate function doesn't work in Actions for whatever reason.  And anyway, having the buttons under "edit" would work much better overall.  (I hate the Acrobat XI design!)

I tried copying the whole thing into a txt file and renamed it reorder.js and copied to the JSCache folder under Users Roaming (etc), but that didn't work at all.

Thanks!

--d

Edit:  Nevermind.  I figured out how to run the java console, struggled with how to run the script (why is there no run command?????), and discovered that the following is the path to have this script run (permanently, under Edit) in Acrobat.  I still don't understand why Adobe insists on giving us these STUPID headaches!

C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\Javascripts

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 ,
Mar 05, 2013 Mar 05, 2013

Copy link to clipboard

Copied

Thank you for this, but unfortunately I cannot get it to work with Acrobat XI Standard. I can't believe that Adobe still hasn't made this a feature.

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
LEGEND ,
Mar 05, 2013 Mar 05, 2013

Copy link to clipboard

Copied

Did you look at the Planet PDF solution? For Acrobat X and XI you need to install the per

  

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 ,
Mar 05, 2013 Mar 05, 2013

Copy link to clipboard

Copied

Thank you, GKaiseril! Yes, I looked at the Planet PDF solution but was unable to get it to work. The link you gave says that the new location for the JS is going to be Users\(username)\AppData\Roaming\Adobe\Acrobat\Privileged\10.0\JavaScripts, however, after C:\Users\Mark\AppData\Roaming\Adobe\Acrobat I have no folder called "Priviledged". I turned on "Hidden Items". Maybe this is because I have Windows 8, I'm not sure. I can get to C:\Users\Mark\AppData\Roaming\Adobe\Acrobat\11.0 but there's no "Priviledged" folder there either. Nor is there any "JavaScripts" folder. I don't know where to go from here.

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
LEGEND ,
Mar 06, 2013 Mar 06, 2013

Copy link to clipboard

Copied

You can run the code using the JavaScript console for a one time use.

Open the odd pages PDF.

Open the JavaScript Console, "Ctrl + J.

Copy and paste the revised script to the console window.

Select all the text in the console window.

Use the Ctrl + Numeric Keypad Enter key to run the code.

You should now have the new menu options until you restart Acrobat.

I would move the code to add the menu items to after the creation of the trusted functions.

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 ,
Mar 06, 2013 Mar 06, 2013

Copy link to clipboard

Copied

Thank you again, GKaiseril. This is a bit frustrating. Ctrl+J does not open the JavaScript Console. I took a look at http://acrobatusers.com/tutorials/javascript_console and it says that you can also get there using Advanced>JavaScript>Debugger, but I can't find the "Advanced" menu item either. I'm running Adobe Acrobat XI v11.0.2 if that helps. Any other ideas?

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
LEGEND ,
Mar 06, 2013 Mar 06, 2013

Copy link to clipboard

Copied

Almost all the menu items moved to the TOOLS button in Acrobat X. So JavaScript options are there for you.

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 ,
Mar 06, 2013 Mar 06, 2013

Copy link to clipboard

Copied

I found the Tools button, but there is nothing there relating to JavaScript. I have "content editing", "pages", "interactive objects", "forms", "text recognition" and "protection". I've clicked on all of them and there is nothing. I also found a Common Tools button but there is nothing there either.

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
LEGEND ,
Mar 06, 2013 Mar 06, 2013

Copy link to clipboard

Copied

Above those tools, and below the Tools button, is a little icon. I can't describe it, but you should be able to find it. Click on it and you'll see you can turn on a whole lot more options (it will list Content Editing, Pages, etc. with a tick).

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 ,
Mar 06, 2013 Mar 06, 2013

Copy link to clipboard

Copied

Thank you again. I'm getting close to giving up here, however. I found the JavaScript button which has a button "Set document actions". When I press it I get a box that says, "When this happens..." with options like "Document will close" and "Document will save." I opened up a couple of them and pasted in the JS and tried to run it, but nothing happened.

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