PhosphoricX has asked for the wisdom of the Perl Monks concerning the following question:

Oh wise monk brothers and sisters,

I would like to create a PDF file from a list of strings I have generated. The list is as follows:
@text = ( "text 0x000000FF 0x00009283", " text2 0x0000000FF 0x00000002", " text3 0x000000101 0x00000064", ... and so forth );
I would like text to print out on a page in my PDF file as:
text 0x000000FF 0x00009283 text2 0x0000000FF 0x00000002 text3 0x000000101 0x00000064
My problem is that PDF::API2 has very poor documentation. I attemped to combine all the lines into a string and use the text->paragraph method. However, the newline characters are not recognised. I'm thinking that you could determine the height of each line and use that to translate the next line to the appropriate point. The text should also span multiple pages as needed. Unfortunately, I've run into quite a lot of difficulties due my inexperience with this module.

Update: I should also mention, that the first page will consist of a graphic

Replies are listed 'Best First'.
Re: Multiple Page Text using PDF::API2
by dragonchild (Archbishop) on Apr 01, 2004 at 13:22 UTC
    Use PDF::Template. If that's all you want to do, the following will work:
    my $template = PDF::Template->new( filename => 'my_template.xml', ); my @params = map { { VALUE => $_ } } @text; $template->params( VALUES => \@params ); $template->write_file( 'outputfile.pdf' ); -------- # This is the contents of my_template.xml -------- <pdftemplate h="8"> <pagedef> <font face="Time-Roman"> <loop name="VALUES"> <row><textbox w="100%" justify="left" text="$VALUE" /></row> </loop> </font> <pagedef> </pdftemplate>

    Try that and see if it works. Note - you will need to install PDFLite from http://www.pdflib.com. (They have both free and commercial versions of PDFLib. PDF::Template will work with both.)

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

Re: Multiple Page Text using PDF::API2
by CandymanCID (Initiate) on Apr 01, 2004 at 14:30 UTC
    Im not an expert by any means on this subject, as a matter of fact Im just starting. However the first module I learned how to use was Acrobat::FDF available from adobes site, and it has fairly good documentation, cause even my noob behind figured it out.