I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2010-07-23 03:05:57.166507-07 by kodo in response to 12828
Re: Adding images
You might want to see the entire script, almost 100% of it is cut n pasted directly from the CPan page. The only differences are the includsion of PDF::Image::GIF and PDF::Image::JPG, the extra two lines of code mentioned above and three lines at the bottom. As mentioned above the script works fine without the one line that actually adds the image to the page. And before you ask the image definately does exist, in the same directory as the script. Thanks for your help...

#!/usr/bin/perl use CGI qw(:all); use PDF::Create; use PDF::Image::GIF; use PDF::Image::JPEG; my $pdf = new PDF::Create('filename' => 'mypdf.pdf', 'Version' => 1.2, 'PageMode' => 'UseNone', 'Author' => 'EPC4U', 'Title' => 'My title', ); my $root = $pdf->new_page('MediaBox' => [ 0, 0, 612, 792 ]); # Add a page which inherits its attributes from $root my $page = $root->new_page; # Prepare 2 fonts my $f1 = $pdf->font('Subtype' => 'Type1', 'Encoding' => 'WinAnsiEncoding', 'BaseFont' => 'Helvetica'); my $f2 = $pdf->font('Subtype' => 'Type1', 'Encoding' => 'WinAnsiEncoding', 'BaseFont' => 'Helvetica-Bold'); # Prepare a Table of Content my $toc = $pdf->new_outline('Title' => 'Document', 'Destination' => $page); $toc->new_outline('Title' => 'Section 1'); my $s2 = $toc->new_outline('Title' => 'Section 2', 'Status' => 'closed'); $s2->new_outline('Title' => 'Subsection 1'); $page->stringc($f2, 40, 306, 426, "PDF::Create"); $page->stringc($f1, 20, 306, 396, "version $PDF::Create::VERSION"); # Add another page my $page2 = $root->new_page; $page2->line(0, 0, 612, 792); $page2->line(0, 792, 612, 0); $toc->new_outline('Title' => 'Section 3'); $pdf->new_outline('Title' => 'Summary'); # Add something to the first page $page->stringc($f1, 20, 306, 300, 'by Fabien Tassin <fta@oleane.net>'); # Add something to the page 2 $page2->stringc($f1, 12, 306, 100, 'Test Content'); my $image1 = new PDF::Image::JPEG('testImage.jpg'); # image( image_id, xpos, ypos, xalign, yalign, xscale, yscale, rotate, xskew, yskew) $page2->image($image1, 100, 100, 1, 2, 1.0, 1.0 ,0, 0, 0); # Add the missing PDF objects and a the footer then close the file $pdf->close; print header; print qq(Done.); exit;
Direct Responses: Write a response