-   Linux - Newbie (
-   -   Merge pdf files vertically AND horizontally (

alanv 04-13-2011 08:25 PM

Merge pdf files vertically AND horizontally
Hello, I have two questions:

1. Is there an easy way to combine pdf files not only one "after" the other, but also one "next to" the other? For example, If I have one-page files called a1.pdf, a2.pdf, a3.pdf, a4.pdf, b1.pdf, b2.pdf, b3.pdf, b4.pdf, c1.pdf, c2.pdf, c3.pdf, c4.pdf, I want to combined them so that I can scroll down from a to c and scroll right from 1 to 4. That is, I want to merge them in "matrix form". If I zoom out the final file should look like:

a1 a2 a3 a4
b1 b2 b3 b4
c1 c2 c3 c4
(TWELVE pages in total)

Is this possible? I tried Google but found no information.

2. Also, is it possible to just put all of them together in a single page. If I zoom out the page should look like:
(ONE page in total)


Note: I would like to do this for many one-page files

chrism01 04-13-2011 09:08 PM

If you can't find a 'simple' tool to do it, you may have to create your own using Perl, prob this module
If you go this route, I'd also post the qn at; it's where the Perl gurus hang out and you should get some good advice/code.

1gn1t10n 12-21-2012 08:20 AM


My answer may come a bit late for you, however it may benefit others.

1. I don't know any answer to your first question. It looks to me more of a presentation problem :scratch:. It is the PDF viewer's job to arrange pages (ie: one after the other). Pages are usually displayed from top to bottom. Some viewers (like Evince for example) can display a "dual" view, like when reading a book. So you would get

-- ee
a1 a2
b1 b2
if you had only two columns and not four. 'ee' is an empty page that fills the place of the first page, which is odd (a real page in a book is made of an odd, then an even page).

2. One possible answer to your second question is to use PDFjam. It is a shell-script interface to the "pdfpages" LaTeX package. Google for the URL, the forum doesn't allow me to put it here because it's my first post.

The quick fix to your problem is:

$ pdfjam --suffix nup --nup 4x3 --no-landscape a1.pdf a2.pdf a3.pdf [...]
This will arrange your original documents on ONE page of 3 rows x 4 columns. You can experiment with and without landscape (--landscape).

PDFjam's behaviour can be customised through parameters (look at the source code to understand them, the man page is quite light). This is useful for other PDF operations too (join, n-up join, split, n-split, flip, reflect etc.).

Then there is the alternate version of using PDF and PS manipulating libraries in a more generic programming language, as chrism01 suggested. Or the hard-core one where you learn directly PostScript and PDF, edit by hand the documents, and then use Ghostscript to generate the result.

Hope this helps!

alanv 12-22-2012 12:45 AM

Hi 1gn1t10n,

Thank you for taking the time to reply to this old question of mine. I just tried it and it works.

All times are GMT -5. The time now is 09:43 PM.