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

PROBLEM

I have a long report that I want to print (sounds simple enough right? Just wait).

BACKGROUND

The report has topic headings, and content related to that that topic (look at the example below for clarification). Now when I bring this page up in a browser, it displays as "one" long page. But if I print this by doing CTRL + P or clinking print, it prints all the listings on separate individual pages.

For example, look a slashdot.com or any other site that has "one" page that holds topic title / information pairs. Now how can we have this page display as "one" long page, BUT if I want to print this "long page" it can print all the stories on each individual page, with stories that take more than one page spread out on more pages but "separated" from others on the original HTML page.

Someone gave me this link that basically does the opposite, it takes a few different pages and consolidates it into one long page but this did'nt help.

As always any input will go a long ways.....

Thanks.....

Replies are listed 'Best First'.
Re: Smart printing
by gellyfish (Monsignor) on Mar 19, 2002 at 21:13 UTC

    You can do this with Cascading Style Sheets, but this is not really a Perl question - I would suggest looking at The W3c site.

    /J\

      I have looked at this BUT Although this property is defined when testing the CSS Style object, Mozilla/Netscape currently do not implement this property.
      WHICH IS EXACTLY WHAT I HAVE TO USE
      Any solution with perl? or any other way?
Re: Smart printing
by HamNRye (Monk) on Mar 19, 2002 at 21:01 UTC

    Couple of questions:

    I'm assuming that this is an HTML page?? Or is it a text report??

    For HTML, you can add a "page-break-before" or after to elements. You could put a break before each heading.

    I'll stop here since it sounds like HTML.

    ~Hammy

Re: Smart printing
by data67 (Monk) on Mar 19, 2002 at 21:50 UTC
    All documents are and should be in HTML format.
    As far as CSS is concerned, i use CSS and it did not know that we can do this with it. I guess i think my problem needed some more intelligence in the program to do this.
      "more intelligence in the program" is exactly what you don't need.

      The problem you are dealing with relates to the printing of HTML pages, generated by a perl script, using Mozilla/IE. The first thing you should do when trying to address any complex problem, is to split it into the smallest possible "sub problems" such that the action of splitting the problem up doesn't change the nature of the problem.

      In your case, the first thing you should ask your self is: "Does the fact that my pages are generated with perl affect the problem?" -- I think you'll find that the answer is no. Mozilla/IE don't care where your HTML page comes from, they'll print it the same if it's served by a CGI, or if it's a file on your HardDrive. So take perl out of the equation: generate a copy of your page that you save to disk, and then tweak it untill you can get Mozilla/IE to print it hte way you want -- IGNORING PERL -- the perl doesn't matter, only the HTML. Once you have the file printing properly, then put the orriginal problem back together: update your perl to generate a page just like the flat html file you have.

        By more intelligence in the program" i ment that we can use perl to:
        » Use line counting when populating the tables, and force extra blank characters at the bottom of the pages.
        » Create a button on the web page for generating a printable version of the page which would create each report on its own page.
        or something along those lines...

        By the way i am fully aware that the browser does not care what kind of language i use to bring that data up......

      This HTML works for me.

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Untitled</title> <style> div.body { page-break-after : always; } </style> </head> <body> <div class=body> Body 1 13:5 3-20-2002 >> P:\20020320\R2003A010.JPG exists, skipping... 13:5 3-20-2002 >> P:\20020320\R2003A017.JPG exists, skipping... 13:5 3-20-2002 >> P:\20020320\R2003A018.JPG exists, skipping... 13:5 3-20-2002 >> P:\20020320\R2003A019.JPG exists, skipping... </div> <div class=body> Body 2 13:5 3-20-2002 >> P:\20020320\R2003C008.JPG exists, skipping... 13:5 3-20-2002 >> P:\20020320\R2003D001.JPG exists, skipping... </div> </body> </html>

      In Opera, IE, and Mozilla, this displayed as one big page and prints as two separate pages.

      Ta-Da!

      ~Hammy
      nothing4sale.org

        In case you missed it, i'll say it again.
        I have to use Netscape for this.