I'm writing some simple report generator/printers, and I used HTML to generate the reports, and now I'm trying to print them from my script. I found this nice little chunk of code to that will make Internet Explorer print my html page:

#!/usr/bin/perl use strict; use warnings 'all'; use Win32::OLE; use Win32::OLE::Const 'Microsoft Internet Controls'; use Win32::OLE::Variant; # From Vc7/PlatformSDK/Include/MsHtmHst.h : use constant PRINT_DONTBOTHERUSER => 0x01; use constant PRINT_WAITFORCOMPLETION => 0x02; my $file = "C:\\FixReportBase\\realtest\\pg_0001.htm"; my $do_not_prompt = 0; my $nCmdID = OLECMDID_PRINT; my $nCmdExecOpt = OLECMDEXECOPT_PROMPTUSER; my $pvaIn = PRINT_WAITFORCOMPLETION; my $pvaOut = 0; if ($do_not_prompt) { $nCmdExecOpt = OLECMDEXECOPT_DONTPROMPTUSER; $pvaIn |= PRINT_DONTBOTHERUSER; } my $IE = Win32::OLE->new('InternetExplorer.Application') or die; #$IE->{'Visible'} = 1; $IE->Navigate( $file ); sleep 1 while $IE->{Busy}; $IE->ExecWB($nCmdID, $nCmdExecOpt, Variant(VT_I2,$pvaIn), $pvaOut); $IE->Quit();
It works nicely trouble is IE's print engine sucks, and messes up the format of my report. I can foobar the HTML to make the report print nicely in IE, but I'm much rather just use Gecko/Firefox. Anyone know some way to get Firefox to print my HTML from perl (or offer up the print dialog for printing the HTML)? If all else really fails I can use javascript in my HTML to for a print and then call Firefox on it via System, but that's a pretty ugly hack, since it splashes a Firefox window on the screen ;/.

In reply to Firefox equivalent to Win32:OLE? by rsilvergun

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.