in reply to Re^4: blank pdf generated using PDF::API2 (Updated)
in thread blank pdf generated using PDF::API2

Hello lennelei,

How many pages of the old file you to keep? Hold on, are you trying to split the old file into sets of new pdfs of 10 pages each? If so try something like this.

#!/usr/bin/perl use strict; use warnings; use PDF::API2; use Data::Dumper; my $file = 'test.pdf'; my $oldpdf = PDF::API2->open($file); my @steps = map { 10 * $_ } 1 .. 10; # print Dumper \@steps; if ($oldpdf->pages() > 100) { my $num = 0; my $last_Step = 1; for my $step (@steps) { my $newpdf = PDF::API2->new(); for my $page_nb ($last_Step .. $step) { $newpdf->import_page($oldpdf, $page_nb, $num); } $num++; $newpdf->saveas("pdf/$num"."_"."$file"); $last_Step = $step; } } __END__ $ ll pdf/ total 5736 drwxrwxr-x 2 tinyos tinyos 4096 Jul 21 12:49 ./ drwxrwxr-x 8 tinyos tinyos 4096 Jul 21 12:48 ../ -rw-rw-r-- 1 tinyos tinyos 980911 Jul 21 12:49 10_test.pdf -rw-rw-r-- 1 tinyos tinyos 274610 Jul 21 12:49 1_test.pdf -rw-rw-r-- 1 tinyos tinyos 508740 Jul 21 12:49 2_test.pdf -rw-rw-r-- 1 tinyos tinyos 340428 Jul 21 12:49 3_test.pdf -rw-rw-r-- 1 tinyos tinyos 355785 Jul 21 12:49 4_test.pdf -rw-rw-r-- 1 tinyos tinyos 216205 Jul 21 12:49 5_test.pdf -rw-rw-r-- 1 tinyos tinyos 505735 Jul 21 12:49 6_test.pdf -rw-rw-r-- 1 tinyos tinyos 248888 Jul 21 12:49 7_test.pdf -rw-rw-r-- 1 tinyos tinyos 1027594 Jul 21 12:49 8_test.pdf -rw-rw-r-- 1 tinyos tinyos 1387582 Jul 21 12:49 9_test.pdf

Unless if I miss understood. :) Give us a description step by step what you are trying to achieve. You have a file with 100 pages and you want to create a new pdf, of how many pages of the original file?

Seeking for Perl wisdom...on the process of learning...not there...yet!