#!/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(\@data) or die $graph->error; my %font = ( Helvetica => { Bold => $pdf->corefont('Helvetica-Bold', -encoding => 'latin1'), Roman => $pdf->corefont('Helvetica', -encoding => 'latin1'), Italic => $pdf->corefont('Helvetica-Oblique', -encoding => 'latin1'), }, Times => { Bold => $pdf->corefont('Times-Bold', -encoding => 'latin1'), Roman => $pdf->corefont('Times', -encoding => 'latin1'), Italic => $pdf->corefont('Times-Italic', -encoding => 'latin1'), }, ); 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 the file after i do ########################################################################################## #open(PDF,"; #close(PDF); #s/Title/Ben is the Man/; #open(OUT, '>out.pdf') || print header('text/html').'can\'t open out file'; #print OUT $_; #close(OUT);