Combine multiple PDF files into one (arranged in a matrix)

imagemagickimagespdfplotting

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…).

Best Answer

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.

Related Question