I needed to split a PDF file into multiple files with one page per file.
#!/usr/bin/perl
use PDF::API2;
$pdf = PDF::API2->new;
$pdf = PDF::API2->open($ARGV[0]);
$pagecount = $pdf->pages;
for(my $i=0; $i< $pagecount; $i++) {
my $newpdf = PDF::API2->new;
$newpdf->importpage($pdf, $i, 1);
print “Saving $ARGV[0].$i\n”;
$newpdf->saveas($ARGV[0] . “.$i”);
}
Excellent stuff, thats handy Aidan.
I suppose I’ll provide the converse…
https://www.cs.tcd.ie/Shane.OConchuir/Misc/MergingPDFs.html
and if you want to convert pdf’s into handout form:
———————————————-
#!/bin/sh
outFile=`echo $1 | sed -e ‘s/\.pdf$//’`
pdftops -level2sep $1 – | psnup -pletter \
-d -6 -b1 -l -m3 | ps2pdf – $outFile”_handout.pdf”
————————————————-
enjoy.
In case you don’t know perl, you can just print each page separate using a pdf-printer.