Before I ask the question, can I explain the ultimate goal in case there is an easier alternative.

I'm trying to create a PDF page of labels. Not the normal lines of text print. Rather, each label has a QR code on the right, (generated via GD) and a line of text along the bottom.

There is also a generic image to the right of QR code(An arrow with "Find your photos here") The label format is 3 wide x 8 deep

I am using PDF::AP12, and - by experimenting - have managed to =more or less= lay the lines of text where the bottom of labels will be.

This morning, I thought I would double check the layout, so created a Photoshop graphic (A4 @72dpi). IN THEORY, I can load the graphic, and then print text on top. (This would also be handy to learn for when I import the QR graphics. However ...

With text, I used:

$text = $page->text(); # Adds some text to page $text->font($font, 8); $across=12; $up=36; for ($x=0; $x<3; $x++){ # Across in 183dpi steps $new_across=$across+(183*$x); for ($y=0; $y<8; $y++){ # Up in 96dpi steps $new_up=$up+(98*$y); $text->translate($new_across, $new_up); $text->text('http://www. ###/abcde/122345'); $pdf->save

But now (lifted from CPAN docs) I have: $jpg=$pdf->image_jpeg('Path\To\label_layout.jpg');

What the heck do I do with the $jpg variable to add it to the PDF file??? I tried $jpg->translate(0,0) ... but that threw an error. So how do I position the graphic as well?


In reply to Add images to PDF using pdf::ap12 by cristofayre

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.