Hello all,
I'm trying to use PDF API2 to output in landscape and to rotate the text and image accordingly. I have somehow gotten the text to rotate 90% but I can't do the same for the image (it doesn't show on the page). Here's my code:
my $pdf=PDF::API2->new;
my $font = $pdf->corefont('Helvetica');
my $page = $pdf->page();
$page->mediabox('A4');
$page->rotate(90); # to landscape
my $content = $page->text();
$content->font($font,12);
$content->transform(
-rotate => 90,
-translate => [100,500],
);
$content->text("This text should appear on the left half of the A4
+ Landscape page");
my $photo = $page->gfx;
my $photo_file = $pdf->image_jpeg("image.jpg");
$photo->save;
# does not rotate correctly because I don't quite understand the t
+ranslate part
$photo->transform(
-rotate => 90,
-translate => [my $_x = 0, my $_y = 0],
);
$photo->image($photo_file, 50, 360, 200, 200);
$photo->restore;
$pdf->saveas("test.pdf");
$pdf->end;
I would like to print the rotated text and image on the left half of the landscape page and then to repeat the same text and image on the right half of the landscape page.
Could anyone help shed some light?
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, 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, 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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|