Split A3 PDF into A4 PDF (down the middle)

From n0r1sk software solutions
Revision as of 07:57, 22 August 2012 by Mario (talk | contribs)
Jump to: navigation, search

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.

You can use this software for example to split a music sheet with DIN A3 pages to get splitted DIN A4 pages for easier printing! The program works with many A3 pages and also with mixed A3 & A4 pages in one PDF.

Version road map/progress



Well, I've done a JAVA gui edition of this software. You can start it via Java Web Start by clicking the following button.

The latest version can now handle pdf documents that have mixed A4 and A3 pages inside like the example below. Also the output is now more usable.

{{#widget:Iframe |url=http://www.n0r1sk.com/_NON_WIKI_CONTENT/A3to2A4.html |width=99% |height=50 |border=0 }}

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/flattr this! (see left menu)



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".

<source lang=bash>

  1. !/bin/bash
  1. Submitted change by Sebastian Matthias ERNST - Thanks!
  2. 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"


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" "


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 </source>

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.

Example Files

last edit 22.08.2012 by Mario