I am trying to use PDF::API2 to create variable "postcards". Ultimately I need to create a card with variable png images (with transparencies so it all needs to be 24 bit) over a jpg background. This will be driven by a csv file for data creating 1 card per record. I already have the data upload portion done, I'm just trying to write a pdf file.
#!/usr/bin/perl # process_pdf.cgi use PDF::API2; my $pdf = PDF::API2->new(-file => "font_test.pdf"); $pdf->mediabox(647,435); $pdf->trimbox(9,9,629,417); my $page = $pdf->page; my $fnt = $pdf->corefont('Arial',-encode => 'latin1'); my $jpeg = $pdf->image_jpeg('../html/font_test/Beach/background.jpg'); @imgs=( $pdf->image_png('../html/font_test/Beach/B.png'), $pdf->image_png('../html/font_test/Beach/I.png'), $pdf->image_png('../html/font_test/Beach/L.png')); my $txt = $page->text; $txt->textstart; $txt->font($fnt, 12); $txt->translate(200,100); $txt->text("Bill OConnell"); $txt->translate(200,120); $txt->text("Stay Late!"); $txt->translate(200,140); $txt->text("Work hard!"); $txt->textend; foreach my $img (@imgs) { $page=$pdf->page; $page->mediabox($img->width,$img->height); $gfx=$page->gfx; $gfx->image($img,0,0,1); } $page->mediabox($jpeg->width,$jpeg->height); $gfx=$page->gfx; $gfx->image($jpeg,0,0,1); $pdf->save; $pdf->end( );
This currently creates a 4 page pdf document (the L is missing?) and the imgs array png's are excessively large. I am having a very difficult time finding in depth documentation on this module. Any suggestions or pointers in regards to module usage would be appreciated - and I'm in no way opposed to using a different approach, although HTML::HTMLDoc would not install on my system -seems like it has some compatibility issues with my kernel 2.6.24 since this was listed in all of the "failed" installs Thanks, Bill

In reply to PDF::API2 question in images by ndnalibi

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.