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 :). Oct 12, 2014 at 18:40

2 Answers 2


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, 2014 at 9:16
  • Thanks! it works. Saved me so much time.
    – parisa
    Aug 1, 2019 at 21:59
  • Sounds like the pdfnup wrapper script has been removed from the main pdfjam package after v. 3.02. See pdfjam-extras. If you look at the wrapper script, you can see it does just a one line command for pdfjam. You should try pdfjam --suffix nup --nup 2x1 --landscape input.pdf to produce input-nup.pdf which is a 2-up layout of input.pdf. Likewise you could do pdfjam --suffix nup --nup 2x2 input.pdf to make a 4-up layout etc. Mar 10, 2021 at 8:41

The layout you are trying to emulate here is called N-up. There are a few ways of doing this. As in xae's comment, you can do this with pdfjam. See my comment there. For example:

pdfjam --suffix nup --nup 2x2 input.pdf

will produce a 4-up, 2x2 matrix. Alternatively you can pass the --landscape option to orient the matrix as viewed from landscape instead of portrait.

You could also do this going through postscript

pdf2ps input.pdf input.ps
psnup -4 input.ps output.ps
ps2pdf output.ps output.pdf

where -4 means 4-up (2x2)

And if you are directly trying to print this pdf file on linux, I think the CUPS client includes a version of the Berkley LPR print spooler (lpr) with an N-up option. You can use the option with

lpr -o number-up=4 input.pdf

or set it as default

lpoptions -p QueueName -o number-up=4

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.