Split PDF documents into separate pages using PHP (or possibly perl)
pdf, perl, php, split
Solution
I have used PDF::Reuse. It makes it so easy it is not even funny. Here is the relevant snippet from one of my scripts:
while ( my $line = <$page_list> ) {
chomp $line;
my ($class, $drug, $page) = split ' ', $line;
my $dir = canonpath( catfile $OUTPUT_DIR, $class );
mkdir $dir unless -e $dir;
my $target = canonpath( catfile $dir, "$drug.pdf" );
prFile( $target );
prCompress( 1 );
prDoc( $INPUT_PDF, $page, $page + 1 );
prEnd();
}
Problem
Can anybody point me towards a PHP library or script that would allow me to split a pdf consisting of multiple pages into separate files, each containing 1 page. The PDFLib documentation doesn't appear to allow this and Google hasn't been particularly helpful. I could possibly also use Perl, but it would be very inconvenient to do so.