in reply to Creating PDF files with Perl

And before you ask -- again -- for "sample code" from one of the responders, you might wish to RTFM.

Replies are listed 'Best First'.
Re^2: Creating PDF files with Perl
by Anonymous Monk on May 09, 2011 at 19:52 UTC
    The reason is because all see here is people suggesting with no possible solution based on the person's code, and I see that this person posted some code sample for people to look at it, but come on, the answers here are no different than "Googling" for the topic been asked. Be reasonable, thats all!
      Due to popular demand ^^, here is a hello world example:
      use warnings; use strict; use Template; # create Template object my $ttt = Template->new(); # define template variables for replacement my $replacements = { name => "holli" }; my $template = join ("", <DATA>); # process input template, substituting variables and save it to disk $ttt->process( \$template, $replacements, "output.xml") || die $templa +te->error(); #call fop and translate xml file to pdf system "d:\\fop-1.0\\fop.bat -fo output.xml -pdf output.pdf" __DATA__ <?xml version="1.0" encoding="iso-8859-1"?> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set> <fo:simple-page-master master-name="my-page"> <fo:region-body margin="1in"/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="my-page"> <fo:flow flow-name="xsl-region-body"> <fo:block>Hello, [% name %]!</fo:block> </fo:flow> </fo:page-sequence> </fo:root>
      Instead of running fop via system, you might also look at XML::ApacheFOP.


      holli

      You can lead your users to water, but alas, you cannot drown them.

      I think my prior response was not unreasonable, given the appearance and reappearance of your (boilerplate) request for "sample code."

      Read the documentation for what's suggested here; read the docs that Google turns up.

      Don't ask, thinly disguised as a request for "sample code," that the Monks give you a complete solution. You'll learn a lot more from the docs and the effort to code your own solution.

        The 'boilerplate' in this case appears to be yours and others response to the question.

        If you can't answer the damn question then don't. If you think there's a better alternative to the OP's choice of module, then be prepared to explain why it's a better choice and back up your recommendation with a code example demonstrating how it more easily answers the OP's question. And if that's too much work, then don't stuff the question with pointless answers.

        You assume that the Anonymous Monk responding to your replies is the same Anonymous Monk who posted the question. It may well be, but as it's Anonymous Monk I don't think that's a safe conclusion to jump to. There are pages and pages of 'how not to ask a question' information to be found on PerlMonks, yet there's not one word on 'how to answer a question'. The initial question was fairly asked. It was properly formatted with (IMO) clear questions and a good code example. Yet no one seems to be able to answer it without a "use this module instead" response. This wasn't some vague "what module should I use" question, it was a question about a specific module and a specific piece of code. The OP put far more time and thought into the question than you bothered to put into your response, despite you're accusations that he/she can't be bothered to use Google or rtfm.

        My assumption about the response by Anonymous Monk was that it was intended to make a point about thinly disguised answers that answer nothing at all. But that's just an assumption on my part. Maybe Anonymous Monk really is just a putz who just wants PerlMonks to write his/her code for them.