7

DUPLICATE OF How can I merge PDF files (or PS if not possible) such that every file will begin in a odd page?

I have a serie of documents, each one with an unpredictable number of pages.

Say :

  • a.pdf (1 page : A1)
  • b.pdf (3 pages : B1, B2, B3)
  • c.pdf (4 pages : C1, C2, C3, C4)

I want to merge these input files into one out.pdf, that I'll print double-side. Every first page of the input files must be on a front (right) page.

This means the expected result would be

  |A1
--|B1
B2|B3
--|C1
C2|C3
C4|

with "--" being a blank page.

Currently, I'm using pdftk cat.

There seem to be a solution through heavy scripting, using :

# Get number of pages
pdftk x.pdf dump_data | grep "NumberOfPages"
# If the number of pages is odd, add a blank page to x.pdf
# Loop
# Cat the whole

I was wondering if there might be a more simple an elegant solution ?

For example, is it possible to add page-breaks at the begining of each file ?

Thanks in advance

Community
  • 1
  • 1
Elvex
  • 656
  • 5
  • 22

1 Answers1

0

This can be done with pdfjam (which uses TeX; see TeX.SE); the pdfpages package it uses has an option openright which can probably automatically achieve what you want.

Community
  • 1
  • 1
Martin Schröder
  • 3,546
  • 5
  • 43
  • 77
  • 1
    This is not what `openright` does: > This option puts an empty page before the first logical page. In combination with nup=2x1, nup=2x2, etc., this means that the first page is on the right side. The same effect can be achieved with the pages option, if an empty page is inserted in front of the first page. Either ‘true’ or ‘false’ (or no value, which is equivalent to ‘true’). (Default: openright=false) – sygi Apr 15 '21 at 20:48