Hello ,
I am trying to extract some pages from the pdf using PDF:API2 importpage function.
When I view the output pdf( generated via above method )
using acrobat reader it works for most but for some
pdf and for some pages it gives the error "An
unrecognised token was found" or "Illegal operation q
inside a text object" .
The importpage function do not return any error it
is only when we view the output pdf document using
acrobat reader it shows an error .
Please help.
Here is the code am using :
use strict;
use warnings;
use PDF::API2 ;
my $pdfFlname= "./pdf/1405460.pdf" ;
my $pdf ;
eval { $pdf = PDF::API2->open( $pdfFlname ) ; } ;
if( $@ ) {
print "error in opening the pdf $@ \n" ;
exit ;
}
my $noOfPages = $pdf->pages;
print "noofpage=" . $noOfPages . "\n" ;
if ( $noOfPages > 24 ) {
$noOfPages = 5 ;
}
#my $preview_pdf = PDF::API2->new( -file => 'out_104665.pdf' );
my $preview_pdf = PDF::API2->new();
my $i = 1 ;
while ( $i <= $noOfPages ) {
$preview_pdf->importpage($pdf,$i) ;
$i = $i + 1;
}
$preview_pdf->saveas("./out_pdf_api2/out_1405460_new.pdf") ;
print "done.." ;
Thanks and Regards
Sona.
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.