There are of course many ways to print stuff, but I would go the
PDF route. This has the added benefit, that you can easily view the
documents online, in addition to getting nice looking printouts.
Other options would for example be to use TeX, or to generate
PostScript directly, but unless you like things with a somewhat higher
geek factor, generating PDF using one the CPAN modules will probably be
easier... :)
For creating PDF from Perl I personally like PDF::API2, but
there are other modules, too...
Update: Maybe you could tell a bit more about what features
you need, in particular whether you want automatic layout of
tables, paragraph wrapping, etc. The above mentioned approach
using PDF:API2 is rather low-level, i.e. you'd essentially have to make
most layouting decisions yourself, like what column widths to use, how
long a line of text can be to fit in the available space, and so on.
For many purposes this is okay, but if you're thinking of something
more high-level, using a proper batch typesetting system would be the
way to go. On the Perl side, this would involve writing out the desired
content plus the proper markup. As there are many sophisticated
templating systems for Perl, it is of course well-suited for this
task. I already mentioned TeX (typically used in combination
with the macro package LaTeX). It is one of the oldest and
probably the most well-known tool for the purpose (there also is a
variant which directly generates PDF output). A more
exotic, less well-known batch typesetter is Lout1 (which I was a
big fan of some time ago, when I had to produce more documents than I
have to now). Most of these approaches have a rather steep learning
curve, though, but once you get the hang of it, those tools may help a
lot to produce professionally looking output. Or, put differently, it's
a matter of saving time now vs. saving time later. :)
BTW, my personal experience with creating nice looking
printouts from HTML is, that it soon becomes quite a PITA, for anything
non-trivial... (current browsers just aren't ready for prime time in
this regard, IMHO) — but YMMV, and it ultimately depends on how
'nice' your printouts are supposed to be.
___
1 just in case anyone is
interested... and 'cos it's somewhat hard to find: current version
3.36, also see
here.
| [reply] |
My first idea was to generate a pdf and print this.
Did you look into anything else? Plain text? HTML? Excel? or another spreadheet?
Is there an easier way?
Always ;-)
You will need to be a trifle more forthcoming with information. Some databases, e.g., Oracle, have report-generating features. These may be adequate. What operating system? Is the output of a plain text file adequate? If so, format may be adequate.
There are several modules for creating PDF (see PDF); I'd tend to use PDF::API2 or PDF::CreateSimple.
However, my preference would be to generate HTML. This is for a couple of reasons, one is that if this is only going to be done once or twice, it may be easier to fix minor errors by directly editing the HTML, instead of editing the program, re-running the report generation, etc.
emc
Information about American English usage here and here.
Any New York City or Connecticut area jobs? I'm currently unemployed.
| [reply] |
I'll also mention Excel ... the advantages are that:
- There's a good package on CPAN to create the spreadsheets that gives you an easy way to do your headings & such.
- A spreadsheet is more flexible than a PDF--the users may reuse the data, or extend the spreadsheet if needed.
...roboticus
| [reply] |
I can only give advice based upon my own experience.Using the various PDF-modules on CPAN is far from easy. Not only is the API rather complicated, there are almost no simple higher level routines to --for instance-- print a whole paragraph, nicely formatted, or even to add a paragraph to a page with automatic page-breaks and page numbering and the like. That being said, there are a few modules which have a very specific functionality, such as PDF::ReportWriter which makes so-called business-reports, which are perhaps exactly what you are looking for. I used this module some-time ago, but as I needed additional functionality, I abandoned it and now write my reports on basis of Template::Toolkit-templates which output LaTex files rendered into PDF. It is totally flexible but it requires you to learn both the Template Toolkit language as well as LaTex!
CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
| [reply] |
You may be interested in PDF::Template if you want to go down the PDF route. It looks pretty interesting though I have not used it myself.
Cheers
Martin | [reply] |
Based on your need to display "headlines, texts, and tables", you might consider Perl6::Form. | [reply] |
If you consider an alternate route, consider the Perl format construct. | [reply] [d/l] |