ok I will try to be as detailed as possible, I have to create a PDF from
variables posted from Flash. getting the variables is easy, and putting
them in a PDF however was challenging when first started is now for the
most part under control. the tricky part it, the layout for the pdf is
designed using Adobe Indesign, I use perl to open the pdf and to place
variables in the template (PDF::API2), but the designer makes the text
in Indesign and wants me to replace his text holders with the variables
posted from flash. Right now I have been trying to just replace text,
and nothing works this is the code i have thus far.
#!/usr/bin/perl
use PDF::API2;
use GD::Graph::bars;
use GD::Graph;
use GD;
use strict;
use constant mm => 25.4/72;
use constant in => 1/72;
use constant pt => 1;
$pdf = PDF::API2->open('InDesignTemp.pdf');
my @data = (
["Jan-01","Feb-01","Mar-01"],
[21,25,33]
);
my $graph = new GD::Graph::bars;
$graph->set(
x_label => 'Month',
y_label => 'Revenue ($1,000s)',
title => 'Monthly Online Sales for 2001',
bar_spacing => 10
)
or warn $graph->error;
$graph->plot([EMAIL PROTECTED]) or die $graph->error;
my %font = (
Helvetica => {
Bold => $pdf->corefont('Helvetica-Bold', -encoding => 'lat
+in1'),
Roman => $pdf->corefont('Helvetica', -encoding => 'lati
+n1'),
Italic => $pdf->corefont('Helvetica-Oblique', -encoding => 'lat
+in1'),
},
Times => {
Bold => $pdf->corefont('Times-Bold', -encoding => 'lati
+n1'),
Roman => $pdf->corefont('Times', -encoding => 'la
+tin1'),
Italic => $pdf->corefont('Times-Italic', -encoding => 'lat
+in1'),
},
);
my $page = $pdf->openpage(1);
s/Title/Ben is the Man/;
my $headline_text = $page->text;
$headline_text->font( $font{'Helvetica'}{'Bold'}, 18/pt );
$headline_text->fillcolor( 'white' );
$headline_text->translate( 50/mm, 130/mm );
$headline_text->text_right( 'this is my new stuff' );
my $photo = $page->gfx;
open(GRAPH,">images/graph1.jpeg") || die "Cannot open graph1.jpg: $!\n
+";
binmode GRAPH;
print GRAPH $graph->gd->jpeg(100);
close GRAPH;
$photo_file=$pdf->image_jpeg("images/graph1.jpeg");
$photo->image($photo_file, 60/mm, 70/mm, 85/mm, 75/mm);
$pdf->saveas("Build3.pdf");
######################################################################
+###################
####this part I was using to to replace the text however it corrupts t
+he file after i do
######################################################################
+####################
#open(PDF,"<Build3.pdf") || print header('text/html').'can\'t open PDF
+ file';
#binmode PDF;
#undef $/;
#$_ = <PDF>;
#close(PDF);
#s/Title/Ben is the Man/;
#open(OUT, '>out.pdf') || print header('text/html').'can\'t open out f
+ile';
#print OUT $_;
#close(OUT);
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs