Merge odd and even page PDFs back into one document
You have two PDFs. One holds pages 1, 3, 5, 7 — the odd ones. The other holds 2, 4, 6, 8. Either a scanner without a duplex feeder made them, or somebody split a document that way before sending it to you.
You want one file that reads 1, 2, 3, 4. So you put both into a merge tool, and what comes back is all the odd pages followed by all the even pages. Which is worse than what you started with, because now it is one file and still wrong.
The operation you need has a name, it is not merging, and it takes about twenty seconds.
Why merging gives you the wrong document
Merging concatenates. It writes every page of the first file, then every page of the second. Odds then evens: 1, 3, 5, 7, 2, 4, 6, 8. That is the correct result for the job merge exists to do — joining a report to its appendix — and it is what Merge PDF will do here too, which is why it is not the tool for this.
What you want is interleaving: take page 1 of the first file, then page 1 of the second, then page 2 of the first, then page 2 of the second, round and round until both run out. Same two files, same pages, entirely different page list. In ordinary speech both are "combining two PDFs", and that collision is the whole reason this is hard to search for.
That operation is Alternate & Mix PDF.
Why the evens are often backwards
If the files came off a sheet-fed scanner, the even file is very likely in reverse order: the backs were photographed starting at the last sheet, so it runs 100, 98, 96 … 2. Nothing about opening it tells you that, because its first page looks like a perfectly ordinary page. Which way the pile was turned between the two passes is what decides it, and the three ways of turning a pile and what each one does to the second file are set out in the post about the scanning itself.
What it means here is that interleaving straight through gives you page 1 followed by the back of the last sheet. The fix is one tick, not a reordering job.
Doing it
- Open Alternate & Mix PDF and add the odd file first, the even file second. Order is the whole instruction: the first file gives page 1 of the result, the second gives page 2.
- If the evens came from flipping a stack as a block, turn on "the second file is back to front". It reads that file from its last page forwards. If you re-fed the sheets one at a time, or the files came from a split rather than a scanner, leave it off.
- Run it. One PDF comes back, and the result note tells you how many pages it has and whether the two files were different lengths.
- Open it and read pages 1 to 4 before you do anything else. They should run front 1, back 1, front 2, back 2. If pages 2 and 4 have swapped places, run it again with the reverse tick the other way round.
The command-line equivalents
If this is a recurring job, or the files are on a server, do it in one line. These are genuinely better than any web tool for a batch, and they are free.
pdftk has interleaving built in, spelled shuffle:
pdftk A=odd.pdf B=even.pdf shuffle A B output out.pdf
For an even file in reverse order, give the handle a reversed range — Bend-1 means "B, from its
last page back to its first":
pdftk A=odd.pdf B=even.pdf shuffle A Bend-1 output out.pdf
qpdf calls it --collate, and is the one to reach for if you have a choice: it is actively
maintained, it is in every package manager, and it reports what it did:
qpdf --empty --collate --pages odd.pdf even.pdf -- out.pdf
qpdf --empty --collate --pages odd.pdf 1-z even.pdf z-1 -- out.pdf
The second line is the reversed case: z is qpdf's word for the last page, so z-1 reads the file
backwards.
The difference that matters between them is maintenance rather than behaviour. The original pdftk is long abandoned and its Java rewrite is what most distributions now ship; qpdf is current and will open files pdftk chokes on. Ghostscript is the third name you will find in old forum threads — it can concatenate, but it cannot interleave, and it re-renders everything it touches, so use it for neither.
When the two files are not the same length
Two files off the same stack should differ by at most one page, because an odd number of sheets leaves the last back blank or missing. Anything more and a sheet was double-fed; that side of paper does not exist and the pass has to be run again. Which single missing image is harmless and which one shifts every pair after it depends on where in the stack it was.
Interleaving does not stop when one file runs out. It keeps taking from whichever files still have
pages, so a file that is three pages short leaves those three pages of the other file sitting in a
run at the end. That is the symptom to look for: a document that reads correctly for two hundred
pages and then has three consecutive fronts stuck on the end. Our tool names both page counts in the
result note when they differ, and qpdf --collate behaves the same way, silently.
What this will not do
It does not accept the words "odd" and "even". It works on two files, not on a page selection
inside one. If what you actually have is a single file and you want every second page out of it,
that is Delete PDF pages, which does take odd and even as page ranges.
Organize PDF pages — the tool for writing a page order by hand — does not accept those
words either, because a set of pages with no order is not an order.
It does not notice blank backs. If your scanner emitted an image for every unprinted side, those
blanks are in the even file and they get interleaved along with everything else. Removing them
afterwards is one range, even, in Delete PDF pages — but working out which pages
are genuinely blank is the harder half of that job.
Only the second file can be reversed. With three or more files — up to ten can take part — the reversed one has to sit in second place.
The result is a new document. Bookmarks and form field definitions from the source files are not carried over; each page keeps its own annotations. For a scan there is nothing to lose. For two halves of a split report there might be, and merging drops outlines for a related reason.
Before you delete the originals
Check three places, which takes under a minute on any document:
- The first four pages. Front 1, back 1, front 2, back 2.
- The last four pages. This is where a length mismatch shows up, and where a reversal that you guessed right at the front would have gone wrong if you had guessed wrong.
- One spread in the middle. Pick a sheet whose two sides you can recognise — a form with a signature block on the back, say — and confirm they are adjacent.
If the pages are right but crooked, Deskew PDF straightens them, and it is worth doing before you compress. If the file is enormous, the PDF inspector will tell you the page size and whether there is a text layer, which is usually enough to explain why.
And if your scan turned out to be a book with two pages on every sheet rather than two files of alternating sides, that is a different job with a different recipe — crop twice, then interleave the halves with this same tool.