I have a pdf with something like presentations slides and multiple slides per page. How can I use ghostscript to split the file so that there is one slide per page?
Splitting single page into two pages with ghostscript
5.1k Views Asked by howard AtThere are 3 best solutions below

The answer of KenS is the one which should be accepted by @howardh. KenS uses a very clever PostScript language program to achieve the result. (Always keep in mind what KenS said: his solution will work well only 'if all the 'subpages' (ie slides) are the same size and location on the PDF page and that all the PDF pages are the same size).
However, for completeness' sake, let me link to a few other previous answers (some of which are illustrated), which solved similar problems:
- Convert PDF 2 sides per page to 1 side per page (SuperUser.com)
- How can I split a PDF's pages down the middle? (SuperUser.com)
- Cropping a PDF using Ghostscript 9.01 (StackOverflow.com)
- PDF - Remove White Margins (StackOverflow.com)
- Split one PDF page into two (StackOverflow.com)
- Freeware to split a pdf's pages down the middle? (SuperUser.com)
These answers also use PostScript code, but only as 'snippets' which are passed to Ghostscript on the commandline. (If you are not PostScript-savvy, these may be more easy to modify and adapt for cases where the 'subpages' are not of the same size and location on PDF pages, and where PDF pages are of different sizes.)

I would like to propose one solution, that actually
1) splits one PS or PDF page to many separate pages and
2) then merges *.pdf to multipage pdf.
But this solution don't process margins.
This script works in Linux BASH:
INPUT="input.ps" ;
RESOLUTION=72 ;
WHOLE_WIDTH=598 ; # current size of portrait A4
WHOLE_HEIGHT=843 ;
COLOUMNS=2 ; # split vertically
ROWS=1 ; # split horizontally
PAGE_WIDTH=$((WHOLE_WIDTH/COLOUMNS)) ;
PAGE_HEIGHT=$((WHOLE_HEIGHT/ROWS)) ;
# Split:
for x in `seq 1 ${COLOUMNS}` ; do
for y in `seq 1 ${ROWS}` ; do
gs -dBATCH -dNOPAUSE -dSAFER \
-o gramps_tmp_${x},${y}.pdf \
-r${RESOLUTION} \
-sDEVICE=pdfwrite \
-g${PAGE_WIDTH}x${PAGE_HEIGHT} \
-c "<</PageOffset [$(((x - 1)*(0 - PAGE_WIDTH))) \
$(((y - 1)*(0 - PAGE_HEIGHT)))]>> setpagedevice" \
-f "$INPUT" ;
done ;
done ;
# Merge:
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=singleCombinedPdfFile.pdf -dBATCH gramps_tmp_*.pdf ;
But we may arrange pages in desired order:
ORDERED="tmp_1,1.pdf tmp_1,2.pdf" ;
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=singleCombinedMultipagePdfFile.pdf -dBATCH ${ORDERED};
A long time ago I wrote some code for someone on comp.lang.postscript to do this, again it was for PowerPoint slides. This PostScript code assumes that all the 'subpages' (ie slides) are the same size and location on the PDF page and that all the PDF pages are the same size. Save the following as a file called pdf_slice.ps and follow the usage as described in the comments.