#!/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;
It works. Slowly. You can see I am re-instancing a whole new pdf object for each one page I want. So, it the pdf has 110 pages, I have to re-instance 110 times, one for each page.
I can't figure out another way right now with CAM::PDF.
I really wish the documentation were a little bit better for these modules, PDF::API2 and CAM::PDF- and what's with the naming all the methods different? like numPages() and pages()- the interface is an inconsistency from hell- I don't care how much they worked on this- the messy api is unforgiveable.
In reply to Re^2: PDF::API2 importpage problem
by leocharre
in thread PDF::API2 importpage problem
by leocharre
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |