Hi,
I've got a PDF file, and I want to send just one page (p. 45) from that (rather large) pdf document to a friend.
So ... I installed PDF-API2-2.020 and ran the following code based on an example from the docs (which, I think, should create a valid pdf file that contains just that one page):
use strict;
use warnings;
use PDF::API2;
my $pdf = PDF::API2->new();
my $old = PDF::API2->open('C:/_32/Peugeot/Chapter_01_engine.pdf');
my $count = $old->pages();
print "Original document contains 138 pages (according to Adobe)\n";
print "Original document contains $count pages (according to PDF::API2
+)\n";
# Add page 45 from the old PDF as page 1 of the new PDF
my $page = $pdf->importpage($old, 45);
print "\$page: $page\n";
$count = $pdf->pages();
print "New pdf doc contains $count pages\n";
$pdf->saveas('C:/_32/Peugeot/head.pdf');
When I run that script, it ouptuts:
Original document contains 138 pages (according to Adobe)
Original document contains 138 pages (according to PDF::API2)
$page: PDF::API2::Page=HASH(0x321bc24)
New pdf doc contains 1 pages
And it creates a new pdf document (head.pdf) that contains one page.
Unfortunately that one page is blank (though page 45 from the original pdf file contains both text and images).
What's going wrong here ?
I've tried the same thing on both Windows 7 (perl-5.16.0) and debian wheezy (perl-5.18.2), and it's the same result.
UPDATE: When I examine the security details of the original pdf file, I see "Page Extraction: Not Allowed" .... maybe that has something to do with the problem ?
Cheers,
Rob
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.