Maybe you wanna get familiar with PDF::API2::Lite first, I've faced a similar situation with PDF::API2 so I used PDF::API2::Lite and familiarized myself with it and when I read the PDF::API documentation it became less arcane, here are the steps for PDF::API::Lite:
  1. call the 'new' method.
  2. create an image object.
  3. define page height and width for the image object.
  4. define the image coordinates for the image object.
  5. call the 'saveas' and pass it 'filename.pdf'.
Here is my code example, for the methods 'new' and 'saveas', if you call them outside the loop, you get a multiple-page pdf file, if you call them from within the loop you got different pdf files for every image.
#!/usr/local/bin/perl use strict; use warnings; use File::Find; use PDF::API2::Lite; my $dir = "."; #my $pdf = PDF::API2::Lite->new; in case you want one pdf file find(\&find_convert, "$dir"); sub find_convert{ if(/.*\.jpg/){ my $image = $File::Find::name; print "$image\n"; convert(); } } sub convert{ #the are repeated for every match my $image=$_; my $pdf = PDF::API2::Lite->new; my $imageObject=$pdf->image_jpeg("$image"); $pdf->page($imageObject->width, $imageObject->height); $pdf->image($imageObject,0,0); $pdf->saveas("$image.pdf"); }; #$pdf->saveas("$image.pdf"); images are included in the same file...
Here are some examples using PDF::API2:
  1. PDF Concatenation and Extraction Tool.
  2. http://www.as220.org/shawn/PGP/examples/example12-4.txt.
  3. http://rick.measham.id.au/pdf-api2/.


Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.

In reply to Re: Perl to PDF by biohisham
in thread Perl to PDF by CColin

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.