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!

In reply to Re^5: blank pdf generated using PDF::API2 (Updated) by thanos1983
in thread blank pdf generated using PDF::API2 by lennelei

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.