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
  • 2
    there is no such thing as a page break in pdf – yms Aug 06 '13 at 15:54
  • Well at least that door is closed, thanks. – Elvex Aug 06 '13 at 16:22
  • @yms: He wants to insert empty pages. – Martin Schröder Aug 08 '13 at 12:38
  • 1
    it seems to me that you are in this same case:http://stackoverflow.com/questions/9820830/how-to-merge-pdf-filesor-ps-if-not-possible-such-that-every-file-will-begin-in/9827598#9827598 – Dingo Aug 08 '13 at 18:16
  • A slightly more efficient solution would be to replace your `If the number of pages is odd, add a blank page to x.pdf` with `If the number of pages is odd, insert blankpage.pdf in the list of PDF files after x.pdf`. That way you don't have to alter x.pdf and don't have to process it an extra time. – L. Scott Johnson Jul 20 '22 at 11:59

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
  • 4,176
  • 7
  • 47
  • 81
  • 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