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

I would like to send a series of formated reports to the users browser. When they print them, which is why the reports are being sent, I would like the user to get reports printed on separate pages. That way I can send 15-20 (which is normal) or more per request and still have the user be able to print individual pages. Is this even possible? My favorite would be to have each report appear in it's own little window. You know, like a cascading series of windows when you open multiple files. But how?

The reports are just HTML formatted to STDOUT. Nothing fancy. I was just wondering if PERL allows us to append a control character to tell the printer to give us a newpage. Something like a formfeed, only to the local printer.

Uncle Ron

Replies are listed 'Best First'.
Re: controlling a printer(physical one)
by Your Mother (Archbishop) on Jul 30, 2005 at 06:18 UTC

    This is kind of a mix of questions. You could easily pop-up 15-20 new windows with a report in each by mixing Perl with JavaScript but your users would--and probably should--hate you for it.

    You can exercise a fair amount of control over how HTML is printed via CSS (eg, in your head something like <link rel="stylesheet" type="text/css" media="print" href="/css/printer.css" />). Google for "css print break" to dig deeper; but as anyone will tell you, HTML is still HTML and you will not get the same results on two different browsers or printers.

    If you're serious about making it look right, investigate the PDF modules on the CPAN (I don't know them enough to recommend one). Then your clients can select page or report ranges to print, if you allow for it, and they will get exactly what you think you're sending them.

      Thanks, for your thoughts and time. That's where I ended up going (htmlgoodies.com) and got an answer that works just fine.

      You're right, of course, about HTML, but this is a case where it's not so critical that I need PDF accuracy. I'm going to investigate that too.

      UR

Re: controlling a printer(physical one)
by sk (Curate) on Jul 30, 2005 at 05:41 UTC
      Thank-you, I had found a similar discusion too. Although it was located at www.htmlgoodies.com. They say the same deal and it works great. Thanks again for your thoughts and time. UR.
Re: controlling a printer(physical one)
by holli (Abbot) on Jul 30, 2005 at 09:02 UTC
    I agree with Your_Mother that using PDF is the way to go here. I want to introduce you to FOP, an easy to use xml-fo to pdf renderer.


    holli, /regexed monk/
      Whoa! Thanks for that. I guess I'll start looking into creating PDF documents. This particular problem doesn't need that kind of accuracy (see Mother), but I've got requests for things that do.

      I appreciate your pointing me in the right direction.

      UR