Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Array of Text to PDF

by Pretzelogic (Initiate)
on Apr 13, 2005 at 19:54 UTC ( #447572=perlquestion: print w/replies, xml ) Need Help??
Pretzelogic has asked for the wisdom of the Perl Monks concerning the following question:

I have two questions, hoping someone can help:

I am retrieving data from SQl Server in a array. Prior, while fetching the data, I was printing this data onto a text file. Instead of printing to text file, I'd like to print to PDF. How can I do that? (I can print a line of text using the pdf::api2 module, but I am having difficulties printing from an array)

Now the second question is, the data returned has unique account numbers by summary level. I like these account numbers to be a hyperlinks on the pdf. So if user clicks on account number #12345 - I want to get that value (12345) and run a SP that will give me details about that accountnumber and then output the details onto another pdf page. Once again, I can create the hyperlinks using an annotation object for static text, but what about dynamic text?

Replies are listed 'Best First'.
Re: Array of Text to PDF
by holli (Monsignor) on Apr 13, 2005 at 21:23 UTC
    For creating PDF I happily use FOP and the XSL-FO namespace.
    In a nutshell, XSL-FO is a xml-dialect that describes the visual appearence of a document on paper.
    FOP is a open source tool to translate the XSL-FO to various output formats, including pdf.
    To create the FO-document you basically have two possibilities:
    • create xml from your data and apply a xslt-stylesheet to it
    • create the xsl-fo document directly via print or a templating engine
    I didn't use linking from FO yet, but itrc it should be supported.

    holli, /regexed monk/
Re: Array of Text to PDF
by jZed (Prior) on Apr 13, 2005 at 21:37 UTC
    Personally, I just generate HTML from the database (or pod, or ...), and use HTMLDOC to convert to PDF. That link has a GPL version, so ignore the pricing info.
Re: Array of Text to PDF
by artist (Parson) on Apr 14, 2005 at 06:32 UTC
    When you print from an array, you just have to set different 'y' co-ordinates. Annotation object can also take dynamic text. See the question Hyperlinks in PDF, I recently asked.
Re: Array of Text to PDF
by dragonchild (Archbishop) on Apr 14, 2005 at 13:04 UTC
    (I can print a line of text using the pdf::api2 module, but I am having difficulties printing from an array)

    First off, if you want us to help you, you'll need to give us a little more information. Maybe you're having issues with handling arrays. It happens to the best of us. Next time, posting the smallest snippet that demonstrates the problem will go a long way ...

    You could use PDF::Template for both issues. (Well, you could if Weblinks were containers and not elements. *sighs*)

    use strict; use PDF::Template; my @array = ( 'Line 1', 'Line 2', 'Line 3', 'Line 4', ); my $some_url = "http://..."; my @data = map { { line => $_, url => $some_url . $_, } } @array; my $template = PDF::Template->new( file => 'foo.xml' ); $template->param( LOOPY => \@data, ); $template->write_file( 'foo.pdf' ); -------- foo.xml -------- <pdftemplate> <pagedef> <font name="Courier" h="8"> <loop name="loopy"> <row> <textbox w="100%" text="$line" /> <row> </loop> </font> </pagedef> </pdftemplate>
Re: Array of Text to PDF
by ghenry (Vicar) on Apr 14, 2005 at 07:02 UTC

    What about using PDF::API2?

    Walking the road to enlightenment... I found a penguin and a camel on the way.....
    Fancy a Just ask!!!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://447572]
Approved by ww
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2018-05-25 03:39 GMT
Find Nodes?
    Voting Booth?