Hey all,
First time poster on this forum. This is also posted over at comp.lang.perl.modules. I really need some help here with my deadline looming like a very large axe over my head.
Situation: Using PDF::API2 to open a PDF created from a Microsoft Word Document and replace certain keywords in the stream with values created from already run perl scripts. What happens is that some of the values are replaced while others are not. With the ones that are replaced, all the characters stack up on one another. I Data:
umped the stream and saw Tj tags in the middle of my key words. Will that keep the substitution from happening?
Qustion is: Why is this happening and how can I fix this problem? I use code that looks a lot like this:
my $letter = PDF::API2->open( 'coverletter.pdf' );
if ( !$letter ) {
$i->{'error'}->setError('Failed to load page pdf object');
return '';
}
# Blank pdf object.
my $pdf = PDF::API2->new();
if ( !$pdf) {
$i->{'error'}->setError('Failed to load page pdf object');
return '';
}
my $page = $pdf->importpage( $letter, 1, 0 );
$page->cropbox(5,5,594,774);
$page->mediabox(5,5,594,774);
# Break open the contents.
my $stream = PDF::API2::unfilter( $page->{'Contents'}->{' val'}->[0]->{'Filter'}, $page->{'Contents'}->{' val'}->[0]->{' stream'}
);
$stream =~ s/foo/$bar/g;
What am I doing wrong here?
Also, I need to put two .png chart images into the pdf document. How can I achieve this?
And lastly.. Is it more benificial to use Excel as the template to create a pdf document to keep this thing from happening?
All help is greatly appreciated.
Thank you,
Eric