PDF::API2 is packaged by Active State.

This works :
use strict; use warnings; use PDF::API2; # Create a pdf object. my $pdf = PDF::API2->new(-file => "test.pdf"); # Create a media box in pdf object. $pdf->mediabox(595,842); # Create font objects. my $fnt = $pdf->corefont('Verdana',-encode => 'latin1'); my $boldfont=$pdf->corefont('Verdana-Bold',-encode => 'latin1'); # Set the font size. my $font_size=8; # Create a page object. my $page = $pdf->page(0); # Create a text object on the page. my $txt = $page->text; $txt->font($boldfont,$font_size); $txt->translate(20,800); $txt->text("A Heading here."); $txt->font($fnt, $font_size); $txt->translate(100,750); $txt->font($fnt, $font_size); $txt->text("A small piece of text here."); # Read a large piece of text from a file and put it in a paragraph on +the PDF document. open(FH, "<largetext.txt") or die "$!\n"; my @fred=<FH>; close FH; $txt->paragraph(join("\n", @fred), -x=>30, -y=>720, -w=>500, -h=>800); # Save the PDF and destroy the object. $pdf->save; $pdf->end( );
...but it has a few problems. It requires that you know (or calculate) the size of the paragraph, and it seems to ignore some formatting, such as multiple spaces and newlines. It also requires that you put your own page breaks in. With a bit of work, it could be made to do what you want.

In reply to Re: Text to PDF by leighsharpe
in thread Text to PDF by drodinthe559

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.