Merging two a5 pages into a singe a4 page (without using pdfnup)
Solution 1
You can do it with a combination of Ghostscript and pdftk.
Here's how: https://superuser.com/questions/191373/linux-based-tool-to-chop-pdfs-into-multiple-pages/192293#192293 .
The above linked example shows how to split pages into half. Just modify the steps accordingly, using different parameters to...
- ...first move "left" pages to a double-sized canvas, left half;
- ...then move "right" pages to a double-sized canvas, right half;
- ...last, combine the pages with
pdftk
.
Update:
Hint: You'd want to use either of pdftk's multistamp
or multibackground
operations (NOT: its shuffle
operation!) to get the wanted final result.
Solution 2
On Debian/Ubuntu, I managed to merge 2xA5 to 1xA4 for printing, using simple commands, by:
# apt-get install ghostscript pdftk psutils
pdftk A=A5-1.pdf B=A5-2.pdf cat A1 B1 output - \
| pdf2ps -dLanguageLevel=3 - - \
| psnup -2 -Pa5 -pa4 \
| ps2pdf -dCompatibility=1.4 - A4.pdf
Andrea Fiore
Ruby software developer by day, functional programming newbie by night.
Updated on June 14, 2022Comments
-
Andrea Fiore about 2 years
I am using Dompdf to generate A5 pdf documents from a html template and Pdfnup (Part of Pdfjam) to combine them into a nice single A4 sheet, which helps saving some paper when printing :)
# Generate an a5 pdf php dompdf.php mytemplate.html -p 'A5' -f a5doc.pdf # combine two copies of the generated A5 into a single A4 page pdfnup a5doc.pdf a5doc.pdf --nup '2x1'
This works just fine; though the second step forces me to install a huge amount of dependencies (i.e. Tex-Latex, pdftex, ecc.) and would clutter my production server. I am wondering if is there any way to combine the generated documents without actually using Pdfnup. For example, is there any way of doing this with pdftk?
Thank you in advance!
-
Jeff G about 8 yearsThe outputs of your first and second steps are different files, correct? Which pdftk command will combine corresponding pages from separate files to the same page of the output, per step 3?
-
Kurt Pfeifle about 8 years@JeffG: Please comment under the original question. Over there, the instructions are very clear IMHO, if taken together with the illustrations I made. OTOH, your current questions are not clear to me at all. Please try to ask them again, but in a clear way.
-
Jeff G about 8 yearsMy question is not about how to chop a single page into multiple pages (the other question, which yes is very clear!). Instead, I'm asking for clarification about your answer here -- i.e. how to adapt your other answer to combine multiple pages into a single page. In my question here about the "steps", I'm referring to your 3 bullets just above: (1) move left pages to double-sized canvas (2) move right pages similarly, and (3) combine pages with pdftk. In short: would you use
pdftk shuffle
even for the merging the left- and right- halves? How? -
Stefan Höltker about 5 yearsThanks, since Ubuntu 18.? removed pdftk i had to install it manual refer to this fine install script askubuntu.com/a/1046476/617935
-
colidyre almost 5 yearsIt could be helpful to add east/west to rotate the input pdfs, because a5 fits perfectly twice in a4. Here is a solution one could put in .bashrc e.g.:
function pdfa5toa4() {pdftk A=$1 B=$2 cat A1east B1east output - | pdf2ps -dLanguageLevel=3 - - | psnup -2 -Pa5 -pa4 | ps2pdf -dCompatibility=1.4 - $3}
and use with pdfa5toa4 A5-1.pdf A5-2.pdf output.pdf -
mirabilos over 2 yearsSome people need to add ps2pdf (as pdf2pdf) to @colidyre’s answer to fix issues with the PDFs, so
<Midwinter-A5.pdf pdf2ps -dLanguageLevel=3 - - | psnup -q -2 -Pa5 -pa4 | ps2pdf14 - Midwinter-A4.pdf
would do, but a PDF using TrueType fonts suffers from massive quality loss (glyphs jump around). I foundpdfjam --nup 2x1 --landscape --a4paper Midwinter-A5.pdf --outfile Midwinter-A4.pdf
to help… though it of course needs Tₑχ/LᴬTᴇΧ which the OP wants to avoid. Still posting here in case someone else stumbles upon it who, like me, has texlive-full installed anyway.