Split A3 PDF into A4 PDF (down the middle)
This article describes how to create one DIN A4 PDF (with 2 or more pages) out of one DIN A3 PDF. The source A3 PDF is splitted down by the middle. In the output PDF the pages are sorted. See the example PDF files.
Contents |
JAVA GUI EDITION
Well, I've done a JAVA gui edition of this software. You can start it via Java Web Start by clicking the following button.
Please be patient, I am not a developer so this software is, I would say, a rough hack.
If you like the software or want to get the source code, contact us or make a donation! ->
Screenshots
SCRIPTED EDITION
Install the needed packages
At first you have to install the right packages which are needed for the converting script. (Debian example)
- pdfinfo (in package poppler-utils)
- bc (commandline calculator)
- gs (ghostscript)
- pdftk (pdf manipulation tool)
apt-get update apt-get install poppler-utils ghostscript bc
Create the Script
Now you have to create the script, which converts the PDF. I'll name it "convert_pdf.sh".
#!/bin/bash # Submitted change by Sebastian Matthias ERNST - Thanks! # http://www.s-m-ernst.de/ WIDTH=$(pdfinfo $1 | grep -i "page size" | tail -n 1 | awk '{ print $3 }') HEIGHT=$(pdfinfo $1 | grep -i "page size" | tail -n 1 | awk '{ print $5 }') PAGES=$(pdfinfo $1 | grep -i pages | tail -n 1 | awk '{ print $2 }') WIDTH2=`echo "$WIDTH/2" | bc` WIDTH3=$WIDTH2"0" HEIGHTFULL=`echo "$HEIGHT*10" | bc` SIZEFULL="-g"$WIDTH3"x"$HEIGHTFULL echo $WIDTH2 echo $SIZEFULL echo $HEIGHT gs -o left-sections.pdf -sDEVICE=pdfwrite -sPAPERSIZE=a4 $SIZEFULL -c "<</PageOffset [0 0]>> setpagedevice" -f $1 gs -o right-sections.pdf -sDEVICE=pdfwrite -sPAPERSIZE=a4 $SIZEFULL -c "<</PageOffset [-$WIDTH2 0]>> setpagedevice" -f $1 SORT="" PAGE="1" while [ $PAGE -le $PAGES ] do SORT=$SORT"A"$PAGE" B"$PAGE" " PAGE=$[$PAGE+1] done echo $SORT pdftk A=left-sections.pdf B=right-sections.pdf cat $SORT output $1_finish.pdf verbose rm left-sections.pdf rm right-sections.pdf
Test the script
So, time has come to test the script above! :)
./convert_pdf.sh example.pdf
The output should be one PDF with the name "example_finish.pdf" including two DIN A4 pages.