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(\@data) 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);

In reply to Editing/Replacing Text in a PDF by ikkon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.