Ask questions. Help others.
The HP Community is here for you.
Post new question
Note on archived topics.
This topic has been archived. Information and links in this thread may no longer be available or relevant.
If you have a question create a new topic by clicking here, or click on "Post new question" above and select the appropriate board.
Posts: 8
Member Since: ‎06-17-2009
Message 1 of 8 (33,452 Views)

How to scan front and back and organize the scans for PDF generation.

[ Edited ]

I just recently purchased a HP-6500 All-In-One. I cannot find in the software an option to select front and back for the simplex/ADF scanner. I HP-Digital, Version 12.0 software, however it does not offer the ability scan all the front pages, then all the back pages, and organize them in proper front-to-back sequence. I have written the PERL script below that will do just that, and guide you to the next step to create a searchable PDF file from the software distributed with the printer.


  • The first thing you need is PERL installed on your computer. I used activestate for windows. Just take the defaults when installing. PERL is a powerful scripting language, independant of the platform, though it does support some platform dependencies.


  • Place the following script somewhere on your system where you can find it later. Save as


      #!/bin/perl dadof4 2009Jun16
      if ( $#ARGV == 0 ) {$ext=$ARGV[0];} else {die "\ extension\n";}
       opendir(IN,"./") || die "$!";
       while($name=readdir(IN)) {
        if ($name =~ /(.$ext)$/) {
        $name="$name"; chomp $name;
        push @flist,"$name";
      $bk=($max+1) / 2;
      print "\n";
      for ($a=0; $a<$bk; $a++) {
       print "renaming $flist[$a] duplex$front.$ext\n";
       print "renaming $flist[$max - $a ] duplex$back.$ext\n";
       rename("$flist[$max - $a ]", "duplex$back.$ext");
       $front += 2;
       $back += 2;
      print "\nNow launch \"C:\\Program Files\\HP\\Digital Imaging\\DocProc\\dpe_ocr.exe\"\n";
      print "to import jpg's and select format Adobe Acrobat-PDF image-text for output.\n";


  • Starting with Odd page up; top in first, keeping them in order as they pass through and out of the scanner.


  • Next, turn the stack over, and scan the back of the stack, top in first, until all pages are scanned.


  • So what you have now is a simplex scan session with the sequenced scans containing all the Odd pages for the first half, and all the Even pages the last half of sequence numbers.


  • Now go to a command prompt, and the folder where all your scanned images are located.


  • Type in the command script, using the extension of the new created; sequenced scans created. I use JPG for mine.


  • So from the Windows command prompt, go to the folder containing your scanned images. Mine were in C:\scan_work>


  • Now just run the script you saved earlier passing the extension of the scanned files. i.e. C:\scan_work> jpg


  • What this will do is start renaming all the files from Scan_Doc_99999.jpg to duplex99999.jpg where the ends of the list are rename to a new sequence terminating to the last two Scan_Doc's in the middle of the list.


  • Now using the OCR application distributed with the printer. Run the following program.



"C:\Program Files\HP\Digital Imaging\DocProc\dpe_ocr.exe"


  • It might warn you this is used for debugging, just ignore. The program is initutive, so you will simply import/open your newly sequenced files, and create a Searchable PDF-Image-text document. Note: When marking the files for the OPEN, mark the last in the list first, then using the SHIFT key, mark the first file in the list last. It will naturally order the list for you. )


  • That's pretty much it. Enjoy :-).


HP should support something similar in their software suite, whether it's duplex printing or not, for the benefit of duplex scanning emulation whether the hardware support duplex scanning or not.

Message Edited by DadOf4 on 06-19-2009 03:18 AM
Honor Student
Posts: 3
Member Since: ‎10-24-2009
Message 2 of 8 (32,944 Views)

Re: How to scan front and back and organize the scans for PDF generation.

Thank you for this script. Here is a wish for an improved version:


After scanning all odd pages (1,3,5, ... 25) I wish I could just turn the stack over and go on scanning the even pages as they are ordered now (24, 22, 20, ... 2)

Unfortunately the script expects the even pages ordered the other way around (2,4,6... 24). This means that I have to turn around all 25 pages which takes a lot of time.


I would be very grateful if you changed the script to make this work unnecessary.




Posts: 8
Member Since: ‎06-17-2009
Message 3 of 8 (32,919 Views)

Re: How to scan front and back and organize the scans for PDF generation.

Interesting.  You should not have to re-shuffle anything.  After scanning the odd pages, the even pages should be ready to scan as-is, hence at the end, the pages are back into their original order.


As odd pages exit the ADF, you should have to do nothing more than flipping them face down, stacking them as more pages are scanned.   Then when you are ready for the even pages, they should be in reverse scan sequence.  Simply rescanning and flipping them over face down again as they exit the ADF, should put the pages back into their orginal order.

Honor Student
Posts: 3
Member Since: ‎10-24-2009
Message 4 of 8 (32,906 Views)

Re: How to scan front and back and organize the scans for PDF generation.

[ Edited ]

Since I am not a native speaker (I am from Germany) I am not sure if I understood everything correctly. Could you clarify for me how the pages are ordered with your scanner, after scanning the odd pages? With my scanner  (HP Officejet Pro 8jet Pro 8500 A909a) the pages are ordered as before (just the stack in itself is flipped).


 In case this is the expected behaviour: Should the scanner now scan the even pages beginning with the lowest or highest even page number?

In case it should start with the highest even page number (e.g. 24) everything should be fine. But if I have to start with the lowest number ( e.g. 2) it would mean that I have to flip every page by hand first.


What is the expected sequence of files/pages as input for your script; lets say for a document with 4 pages:

Is it 1-3-2-4 or 1-3-4-2?


My impression is that your script expects the sequence 1-3-2-4, but the sequence of my files is 1-3-4-2.



Message Edited by Kkugel on 10-25-2009 01:13 AM
Posts: 8
Member Since: ‎06-17-2009
Message 5 of 8 (32,894 Views)

Re: How to scan front and back and organize the scans for PDF generation.



After you scan all the odd pages, 1 through the highest odd page...   When the stack is flipped over, the highest even-page should be first, scanning from highest to lowest even page.  There should be no reshuffling of pages for the perl script.


Hope this helps.

Honor Student
Posts: 2
Member Since: ‎08-02-2011
Message 6 of 8 (25,526 Views)

Re: How to scan front and back and organize the scans for PDF generation.

You can also use Pdfsam (, basic version is open source - free to use.

Merge pdf documents with pdfsam(or Split), it's free and open source.

Start Pdfsam - use the standard Plugin "Alternate mix" to merge the 2 scans (first select the odd pages-scanned PDF and second the even pages-scanned PDF). Select "Destination output file" and the "Run" to merge to one complete "duplex" scanned PDF.

Honor Student
Posts: 2
Member Since: ‎02-12-2013
Message 7 of 8 (18,497 Views)

Re: How to scan front and back and organize the scans for PDF generation.

Thanks so much for the great tip! Just what I was looking for.

Top Student
Posts: 4
Member Since: ‎11-21-2013
Message 8 of 8 (15,082 Views)

Re: How to scan front and back and organize the scans for PDF generation.

It's a free web site: .

You scan the front side of pages into a PDF file, then simply turn over the pages and scan the back side to second PDF file, then upload these 2 files into this web site and merge them by clicking "SinglePageScanMerge" button then you get one file contains all pages in order!

This site can also be used for regular PDF files merge ---- just merger one PDF file after another. Or to extract pages from a PDF file.

The limit is 10M for all upload files. 

It's always faster to scan single side pages than double side scanning by the scanner itself. And using software to merge single side scanned pages can extend scanner's life.

† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation