Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Line Printing Control

by rir (Vicar)
on Feb 12, 2003 at 16:45 UTC ( [id://234735]=perlquestion: print w/replies, xml ) Need Help??

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

I am looking for input on tools to use for the printing of hard copy, i.e. invoices, ledgers, etc. This is initially on linux/unix from Perl 5.

I have tried TeX to this purpose but the printing process was, to put it mildly, too weighty.

My tentative plan is to have printers known to the software system. Output will be prefaced by a print control clause. A filter will translate this to control sequences, postscript, or such based on printer type. Conceptually a form is printed on the page, then the data is printed on the page. For dumber line printers this may require laying out the page in memory first. My model will fit well with HP's PCL on laser printers..

My knowledge of printing systems is rather limited and retro. This seems like it should be well trod ground. I'd like to follow a marked path but haven't found one.

Thanks for any advice.

Replies are listed 'Best First'.
Re: Line Printing Control
by Corion (Patriarch) on Feb 12, 2003 at 16:59 UTC

    I wouldn't go the way of PCL but rather the way of Postscript, together with any template toolkit that isn't HTML specific (that leaves TT2 from what I see, but I don't know whether one couldn't abuse HTML::Template). This should take care of the layout side.

    For the printing process, either have Postscript capable printers (you most likely already have, as you are under Linux), or use Ghostscript on any box to handle the ugly details of converting Postscript to something printable on your printer of choice.

    I personally would turn to TeX for the superior layout quality (and ease of producing PDFs), but Postscript should be as readable as (La)TeX, if not more.

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
      To what degree and in what ways are template toolkits made HTML (or other language) specific? I know that, despite its name, CGI::FastTemplate is completely content-agnostic and I've used it to generate TeX output without having to resort to abuse.

        I haven't worked with any of the template toolkits, but I imagine that the HTML oriented toolkits might implement automagic HTML entity quoting, which would get in the way or at least be inconvenient. Also, such toolkits might expect to be able to parse their templates with HTML::Parser, or expect their templates to be valid XML / XHTML, except for their own special tags. Some toolkits even bear HTML in their name, which suggests that they cater specifically to HTML output (HTML::Template and HTML::Mason).

        But as I said, I didn't work with any of the toolkits, so this remains to be evaluated by the actual user.

        perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
Re: Line Printing Control
by Fletch (Bishop) on Feb 12, 2003 at 17:52 UTC

    Look at LaTeX if you truly just looked at TeX. It's a somewhat higher level system (sort of C to TeX's assembler) and might be more suited to your needs.

    Also consider that you don't have to generate the complete (La)?TeX output each time. You could use a templating system to seperate the actual output presentation from its generation.

Re: Line Printing Control
by Arrowhead (Monk) on Feb 12, 2003 at 18:44 UTC

    There are other typesetting systems you could also look at:

    • good old troff. Nowadays there are really nice tutorials coming with groff, and I got the book "Unix text processing" for free ages ago.
    • Lout. Similar functionality to TeX but much simpler to learn.
    • PostScript, if you first get some nice functions to turn it into something more high-level.
    • XML + XSLT -> XSL-FO, for example using Apache FOP. XSL-FO is the modern-day equivalent to TeX and Lout and, like everything these days, uses XML syntax.

    Once you figure out what high-level concepts you'd want to use (headings, paragraphs, tables?, font changes, etc.), you'll find that those have all got direct mappings into roff and Lout (and TeX) constructs. If you go for PostScript or PCL, you'll have to implement them yourself.

Re: Line Printing Control
by Willard B. Trophy (Hermit) on Feb 12, 2003 at 22:24 UTC

    Depends on what you are aiming to output. Plain text monospaced output? There are always Perl formats ...

    Arrowhead touched on troff. It's a good lightweight system, with excellent typographic control. The excellent tutorial book Unix Text Processing is available for free download from http://www.alltel.net/~kollar/utp/.

    You might want to look at PDF. If you need to create simple PDFs from scratch, PDFlib is your (admittedly low -level) friend.

    If you are getting forms in as PDF blanks (it happens), I've seen clever things demonstrated with PDF::API2.

    Most workflows accept PDF as a native file format. Good luck!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://234735]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-26 07:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found