Saturday, October 14, 2006

Scanning Double-Sided (Duplex) Documents into Acrobat (PDF)

Hey all, I know there haven't been posts in a while. I was using my main server to passthrough for work until we finally got a dedicated IP. Unfortunately that meant my poor Apache server was muted for almost a year. Well I am back with what I think is a good post. On with it.

So I am trying to scan in a double sided manual into Acrobat. I assumed this would be a simple thing but no such luck. So here is how you can do it with a little preprocessing:

  1. Scan all the front sides into a single document in acrobat. Let's call it one.pdf

  2. I really didn't want to reorder the whole thing so I scanned in the back sides backwards so they didn't get out of order. Scan these into another document called two.pdf

  3. If you did scanned them in backwards, you can use Javascript in acrobat to reorder them quickly. In Acrobat go to Advanced - Javascript - Debugger... (Ctrl-J). Copy the following into the box replacing everything else in there.

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

    now highlight the whole thing and press ctrl-enter. This will reorder the pages for you in correct forward order. Save it and exit Acrobat.
  5. Now the tricky part, you need some freeware tools. Download and install pdftk, MSYS and coreutils. Get the Windows versions of each. You will need the coreutils for the seq command in the next section. I put the coreutils in my path, not sure if that was necessary.

  6. Move the pdftk executable, one.pdf and two.pdf into your home dir in your msys install, should be C:msys1.0home\

  7. Launch msys (you should already be in your home directory. Then execute the following commands
    Use pdftk's burst function to get a separated pdf for each page:
    pdftk one.pdf burst output one%d.pdf
    pdftk two.pdf burst output two%d.pdf

    now you have 1...n (say n=75) files named one1.pdf one2.pdf ...one75.pdf, the same for two

  8. Join the first pages:
    pdftk one1.pdf two1.pdf cat output final.pdf

  9. Now merge the rest of the pages:
    for a in $(seq 2 75);do mv final.pdf temporal.pdf;pdftk temporal.pdf one$a.pdf two$a.pdf cat output final.pdf;done

    This takes a while with no output at all, when it's done, it will return to the command prompt. final.pdf will contain your finished document.


Thats it, now your two sided document is merged into one ordered document with a little help from some freeware tools. Credit for the merging process and for the reverse ordering of pages.

Good luck!

2 comments:

  1. I don't know how to put this in. please explain thank you

    Now merge the rest of the pages:
    for a in $(seq 2 75);do mv final.pdf temporal.pdf;pdftk temporal.pdf one$a.pdf two$a.pdf cat output final.pdf;done

    ReplyDelete
  2. I wrote a java program for this task:
    example is included in the zip file
    https://www.dropbox.com/s/hagea1niw2nuy67/ScanPDFReorderPublic.rar

    ReplyDelete