Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: PDF::Template redesign - I want your ideas!

by eric256 (Parson)
on Dec 02, 2005 at 16:28 UTC ( #513634=note: print w/replies, xml ) Need Help??


in reply to PDF::Template redesign - I want your ideas!

The more I look at the and think about it, the more it seems the template portion should be completly seperate from the PDF generation portion. Is there any real reason to combine those two together? Then HTML, PDF, EXCEL would all use the same template code and the post parse the output in the needed form. Code might look like:

<code> use Simple::Template; #dunno what you would call it but it pulls the *template* portions out use PDF::Template; my $pdf = Simple::Template->new(filename => $filename, processor => PDF::Template->new() ); $pdf->output_file($filename . '.pdf'); <code>

PDF::Template could even automate the calls to Simple::Template. A generic backend template would have the advantage that the user could use HTML::Template (style) or TT or something else to generate the final code to send to the Processor.


___________
Eric Hodges $_='y==QAe=e?y==QG@>@?iy==QVq?f?=a@iG?=QQ=Q?9'; s/(.)/ord($1)-50/eigs;tr/6123457/- \/|\\\_\n/;print;
  • Comment on Re: PDF::Template redesign - I want your ideas!

Replies are listed 'Best First'.
Re^2: PDF::Template redesign - I want your ideas!
by dragonchild (Archbishop) on Dec 02, 2005 at 16:44 UTC
    The problem with this, and I should have posted this initially, is that while the datasource remains the same, the Excel, PDF, and HTML portions have very different look-and-feel requirements. For example, a set of images might be required in the PDF that's different from the HTML and that cannot be displayed in the Excel. The difference might be something as simple as a reversed image (instead of white on black, it's black on white).

    The second issue is headers and footers. HTML and Excel don't have them, but PDF does.

    And, that brings up the general issue of pagination. HTML doesn't paginate the same way PDF does, and Excel is different yet again. (I won't even start with RTF.) You'll end up with a really bad PDF if you attempt to PDF-ize an HTML document.


    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
      The second issue is headers and footers. HTML and Excel don't have them, but PDF does.

      As per my earlier post -- you can utilize the proposed W3 extensions for this. For example, see this fragment taken from CSS Print to put a running page count at the bottom of pages:

      <style> @page { counter-increment: pages; @bottom-center { font-family: Times, Palatino, serif; font-size: 12pt; font-weight: normal; content: "Page " counter(pages); } } </style>

      Sure, a lot of these standards are proposed/preliminary, but I think they offer a good place to start because a group of people have already been thinking about these sorts of challenges.

      -xdg

      Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

      PDF'ing an HTML page almost always ends up badly anyway. Each time I generate a PDF with the same data as used in an HTML page, I end up using TT (well close to every time). Using TT would definitely be my choice here.

      You missed my point.

      Instead of having the template portion (control constructs etc) as part of the module, all the modules should use the same template. Then each module expects different data. So control flow and variable insertion remains the same, yet formating would be independent. So a PDF template might have header and footer tags, while xls has row and colum stuff, regardless they all still use the same loop, if, var code from the basic template. Code reuse 101 ;)


      ___________
      Eric Hodges $_='y==QAe=e?y==QG@>@?iy==QVq?f?=a@iG?=QQ=Q?9'; s/(.)/ord($1)-50/eigs;tr/6123457/- \/|\\\_\n/;print;
        That's why I was thinking about trying to use TT in some fashion. That way, you have the same constructs from TT, but you do still have a separate template file for each output format.

        My criteria for good software:
        1. Does it work?
        2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
      HTML and Excel don't have them, but PDF does.
      Regarding Excel there is not a Header/Footer per se, but you can define rows and columns that repeated on each printed page. That's are pretty much the same.


      holli, /regexed monk/

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://513634]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2021-10-19 14:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (76 votes). Check out past polls.

    Notices?