どせいたんさき。

ナスダヨー

pdfjam で複数ページの pdf ファイルをタイル状に並べる

目的

(n×m) ページの pdf ファイルを n × m のタイル状に並べた pdf を作成したい.

解決方法

pdfjam を利用する.

sudo apt-get install pdfjam


たとえば 4 ページの pdf ファイルを 2×2 のタイルに並べた pdf ファイルは以下のコマンドで作成できる.

pdfjam input.pdf --nup 2x2 -o output2x2.pdf

内部的には LaTeX を使用して pdf ファイルをタイルに並べているようだ.そんなわけで並べる順番は左上を起点にして Z 字を書くようなジグザグになる.逆 N 字のようなジグザグで配置することはできないと思われる.他にもいろいろとオプションがある.便利そうなものを抜粋する.

--quiet  (or -q)
        Suppress verbose commentary on progress.
--batch
        Run pdfjam sequentially on each input file in turn, and
        produce a separate output file for each input, rather
        than the default behaviour (which is a single run of
        pdfjam on all of the input files, producing a single
        output document).  For the location of output
        files, see '--outfile'.  The --batch option cannot be
        used in the case of input fron stdin.
--outfile PATH  (or -o PATH)
        Specifies where the output file(s) will go.  If PATH is an
        existing directory, pdfjam will attempt to write its
        output PDF file(s) there, with name(s) derived from the
        input file name(s) and the --suffix option (see below).
        Otherwise the output file will be PATH.  If '/dev/stdin'
        is the only or last input file, PATH cannot be a directory.
--suffix STRING
        Specifies a suffix for output file names, to be used when
        --outfile is either (a) a directory, or
                            (b) not specified in a --batch call.
        A good STRING should be descriptive: for example,
                 --suffix 'rotated'
        would append the text '-rotated' to the name of the input
        file in order to make the output file name, as in
        'myfile-rotated.pdf'.  The STRING must not have zero
        length.
--landscape
--no-landscape
        Specify landscape page orientation (or not) in the
        output PDF file.
--twoside
--no-twoside
        Specify (or not) the 'twoside' document class option.
--paper PAPERSPEC  (or simply --PAPERSPEC)
        Specify a LaTeX paper size, for example
        '--paper a4paper' or simply '--a4paper' for ISO A4 paper.
        If the LaTeX 'geometry' package is installed, a wider range
        of paper sizes is available.  For details see documentation
        for LaTeX and/or the 'geometry' package.
--papersize '{WIDTH,HEIGHT}'
        Specify a custom paper size, e.g.,
            --papersize '{10in,18cm}'
        (Note the braces, and the comma!)
        If the 'geometry' package is not found, this has no effect.
--KEY VALUE
        Specify options to '\includepdfmerge', in the LaTeX
        'pdfpages' package.  Here KEY is the name of any of the
        many options for '\includepdfmerge', and VALUE is a
        corresponding value.  Examples are
            --nup 2x1     (for 2-up side-by-side imposition)
            --scale 0.7   (to scale all input pages to 70% size)
            --offset '1cm 0.5cm'
                          (to offset all pages -- note the quotes!)
            --frame true  (to put a frame round each input page)
            --trim '1cm 2cm 1cm 2cm' --clip true
                          (to trim those amounts from left, bottom,
                           right and top, respectively, of input
                           pages)