Having a set of PDF files, lets say: in-01.pdf, in-02.pdf, in-03.pdf, ... I would like to combine all of them into a single one, forming an M x N matrix.

The command montage allows for doing so (M and N should be integers):

montage -mode concatenate -tile NxM in-*.pdf out.pdf

The problem is the size of the resulting PDF is huge, while I would expect it to be (maybe just) a little bigger than the sum of all the input PDF sizes. I think montage is first converting the input PDFs to images and then creating the output PDF out of those images (so for example, the text in the original PDFs is not showed as text in the output PDF, but as an image with lower quality and bigger size).

I guess there should be a way to do it (LATEX, for example, allows to insert a PDF image in another PDF without the need to convert it to an image first).

I am looking for a command line alternative using free software tools under GNU/Linux systems.

NOTE: we can asume those PDF files have all the same exact dimension (width and height). They are auto-generated PDF images normally consisting of a plot/graph (simple shapes line lines and rectangles) and a few text (title, labels...).

  • 1
    You are correct about what montage does :). – Michał Górny Oct 12 '14 at 18:40

You could use the utility program pdfnup from the pdfjam suite.

pdfnup in.pdf --nup 3x3

should output the file in-nup.pdf with the pages of in.pdf arranged in a series of pages with a 3x3 matrix from the origin pdf.

You should merge all of you pdf files in an only one, also you must want to specify a paper size for the output file, see the pdfjam docs fot the details.

  • 1
    In case you have a prefix in all input files (i.e. in-), then you may want to use pdfnup in-*.pdf --nup 3x3 --outfile out.pdf to avoid having an output file with the same prefix. Also, notice how you don't really need to merge all input files into one (you can simply use the * wildcard). You may want to add that to your answer. – Peque Oct 13 '14 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.