#!/usr/bin/perl use strict; use CAM::PDF; my $file_in = $ARGV[0]; my $prepend = $ARGV[1]; $prepend ||= 'out'; my $pdf = CAM::PDF->new($file_in); my $count = $pdf->numPages; undef $pdf; for my $i ( 0 .. ( $count - 1 )){ my $_i = ($i+1); my $file_out = sprintf "%s_page_%04d.pdf", $file_in, $_i; # make sure it's not there unlink $file_out; my $pdf = CAM::PDF->new($file_in); $pdf->extractPages($_i); $pdf->cleansave; $pdf->output($file_out); print STDERR "saved $file_out\n"; } exit;