65

I have two searchable PDF documents, say even.pdf and odd.pdf which contain even and odd pages of a book, respectively.

I can decompile each PDF to separate files 001.pdf 002.pdf 003.pdf, et cetera. The question is how to merge them?

They are both even and odd sequences numbered 1, 2, 3. If the numbering in the decompile process with pdftk were different, e.g. 1, 3, 5 for even and 2, 4, 6 for odd instead of 1, 2, 3, 4, I could simply merge them.

Can I do this any other way?

Yurij73
  • 1,100

11 Answers11

63

A simple solution would be to use only pdftk in the following way:

pdftk A=odd.pdf B=even.pdf shuffle A Bend-1 output merged.pdf

This also works if odd pages are scanned first and then even:

pdftk A=file.pdf  shuffle A1-X Aend-Y output new-file.pdf 

where X is the last odd page and Y is X+1.

Rohit Gupta
  • 5,096
33

From the PDFtk homepage:

PDFtk has a special feature that we added specifically to solve this problem of arranging scanned pages: shuffle. Say you have two PDFs: even.pdf and odd.pdf. Then you can collate them into a single document like this:

pdftk A=odd.pdf B=even.pdf shuffle A B output collated_pages.pdf

If your even pages are in reverse order, you can reverse its page range:

pdftk A=odd.pdf B=even.pdf shuffle A Bend-1 output collated_pages.pdf

The shuffle feature works by taking one page at a time from each of the input page ranges and assembling them into a new PDF. You specify these ranges after the shuffle keyword, and you can have more than two ranges.

An example of the use of more ranges is:

pdftk A=odd.pdf B=even.pdf shuffle A1 B1 A5-6 B2-3 output out.pdf

in which case the output contains the first page of A (A1), the first page of B (B1), then the fifth page of A, the second of B, the sixth page of A and finally the third page of B.

Melgaard
  • 431
6

Check out Sejda - A New Advanced Online PDF Manipulation Tool

http://sejda.com/

It has the ability to merge docs in different ways, and may be able to accomplish your requirements above - the Alternate and Mix task appears to do what you're asking for.

Alternate and Mix PDF files using Sejda.com

Ben N
  • 42,308
Simon
  • 4,481
4

Of the top of my head, I would combine pdftk with mmv:

  • First burst both files into separate directories, getting even/001.pdf and odd/001.pdf etc.
  • Then use mmv '*.pdf' '#1-a.pdf' on the odd folder, mmv '*.pdf' '#1-b.pdf' on the even folder.
  • Move everything into one folder. The shell expansion * should now sort odd pages before even pages (001-a, 001-b, 002-a, 002-b etc.).
  • Use pdftk as in pdftk *.pdf cat output combined.pdf

Maybe you have to do the last bit in loops for, say, the first thirty pages, then another thirty pages etc., depending on how robust your shell expansion is with many files.

Felix Dombek
  • 2,175
Claudius
  • 9,558
4

I use the free and open source PDF Split and Merge module called PDF SAM Alternate Mix. Github link

Besides being able to merge files it is capable of other interesting operations.

To Do
  • 2,560
2

Using qpdf:

qpdf --empty --collate=1 --pages A.pdf B.pdf -- out.pdf
2

I was facing the same problem. One file containing the odd, one file containing the even pages of a scanned book. I simply used the built in Windows 7/8/8.1 batch rename capability.

1) Split the pages of each pdf back into seperate files for each page such that one folder contains all odd pages as seperated files and a different folder contains all even pages.

2) Bulk/Batch/Mass rename the files of both folders in the same way. Simply select all files in each folder and rename the first one as a and hit enter. In doing so, the files in each of the two folders will be numbered as a(1),a(2),a(3)...

3) In the folder with the odd pages, copy all files and paste them directly into the same folder. In doing so, it creates copies of the files with the odd pages that will look like a(1) - Copy

4) Move these copied files to the folder containing the even files. This sorts them in front of the even page files (as long as the files are sorted by their names).

5) Merge the the files back into one file by simply following the new naming scheme.

In order to merge and split the pdf files I used pdfIll's Pdf Tools which is available for free.

Georg
  • 21
0

PDFSam Basic is free and the merging process is much faster than what I am accustomed to on Adobe Acrobat. (It took about 3 seconds to merge two 200-page, 50MB files, interleaved. Whereas it would've taken at least 10 seconds on Adobe Acrobat, without the interleaving feature.)

The only possible drawback is that you have to install it on your system. Github link

0

If you are scanning documents fronts first and backs second, the GNOME "Document Scanner" app (Simple Scan) can combine the scans via the "Reorder Pages" tool. "Combine Sides" is the option you're looking for:

Simple Scan Reorder Pages Tool

-1

well what you are asking is slightly complicated, but for starters you could try something like Combine PDFs Free or any other page. If you have trouble let me know and i can try help :P

regards cam

-2

I think he is opting for a little bit more flexibility in functionality. That makes your combinepdf option totally useless. Better give Online PDF a try. That will put you in command at least...

Job
  • 1