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

First post to Perl Monks so hopefully I'm doing this right.

I have an application where I build an HTML web-page via several perl scripts in Windows. At the end of the last script I want to display the page in a browser and then have the print command of the browser put out a hardcopy for the user. Having the user hit "OK" is fine.

I can display the web-page in the browser via the script but am looking for some way to automagically go into the print dialog. The users of this app may not be aware of how to print from their browser.

I've been googling but apparently my google-fu is weak. I have found a number of references to setting up kiosk mode in Chrome (the preferred browser) but can't seem to get that working.

I'm wondering if someone out there is Perl land might have a way to feed the newly created HTML into an "HTML engine" and then allow me to print to the default printer?

OR

Know of someway that will let me accomplish the same thing.


TIA
Bill W
  • Comment on Possible to print a formatted HTML page?

Replies are listed 'Best First'.
Re: Possible to print a formatted HTML page?
by thomas895 (Deacon) on Aug 05, 2013 at 03:36 UTC

    That's easy. You only have to add the following to your HTML output:

    <script type="text/javascript"> window.print(); </script>

    Put it wherever on the page, maybe at the bottom before the </body> tag.
    Not really Perl, though. I'm surprised you didn't find this while searching -- maybe you used the wrong keywords?

    ~Thomas~ 
    "Excuse me for butting in, but I'm interrupt-driven..."
      WORKS GREAT! NO idea why this didn't turn up in my day of searching. THANKS!
      Bill W
Re: Possible to print a formatted HTML page?
by Mr. Muskrat (Canon) on Aug 07, 2013 at 17:42 UTC

    "I've been googling but apparently my google-fu is weak."

    Really? The first two results when doing a Google search for javascript print would have given you the same answer.