By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,460 Members | 1,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,460 IT Pros & Developers. It's quick & easy.

Use Firefox's Javascript w/o the browser?

P: 2
Hi all, I'm trying to use Firefox to as an html renderer for reports. All I really want it to do is display a print dialog so I can select the printer I want to print to, and then print the HTML. I can make IE do this with perl and OLE, but IE's print engine kinda sucks (and blows, at the same time). Anyone know if this is even vaguely feasible? I though maybe I could get away with just making the 'window' invisible, small or at least closing the darn thing from a script after I'm done printing. I haven't found a way to make it not show, or be so small as to be unnoticable, and closing the window doesn't work reliable with tabs :(. It'd make a great report printer for my scripting needs if I could just get it to integrate nicely.

Oh, here's the perl code to make IE do what I want it to do, in case anyone can use it. For me, IE's too tempermental...

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings 'all';
  5. use Win32::OLE;
  6. use Win32::OLE::Const 'Microsoft Internet Controls';
  7. use Win32::OLE::Variant;
  9. # From Vc7/PlatformSDK/Include/MsHtmHst.h :
  10. use constant PRINT_DONTBOTHERUSER    => 0x01;
  11. use constant PRINT_WAITFORCOMPLETION => 0x02;
  13. my $file = "C:\\FixReportBase\\realtest\\pg_0001.htm";
  14. my $do_not_prompt = 0;
  16. my $nCmdID      = OLECMDID_PRINT;
  18. my $pvaIn       = PRINT_WAITFORCOMPLETION;
  19. my $pvaOut      = 0;
  21. if ($do_not_prompt) {
  23.   $pvaIn       |= PRINT_DONTBOTHERUSER;
  24. }
  26. my $IE = Win32::OLE->new('InternetExplorer.Application') or die;
  27. #$IE->{'Visible'} = 1;
  28. $IE->Navigate( $file );
  29. sleep 1 while $IE->{Busy};
  31. $IE->ExecWB($nCmdID, $nCmdExecOpt, Variant(VT_I2,$pvaIn), $pvaOut);
  33. $IE->Quit();
Jun 19 '07 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 15k+
P: 16,027
Welcome to TSDN!

I'm sorry I don't think this is possible using standard Javascript. You can only do this kind of stuff in IE using JScript/ActiveX. Firefox is too safe for that!
Jun 20 '07 #2

P: 2
Figures, I guess I should be glad though since I browse with Firefox :). I'm looking into other ways of doing what I want to do. In the meantime I've wimped out. I printed my HTML to postscript using a postscript printer redirected to a file printer, and I'm using that as a makeshift template for my reports. I still like the idea of generating HTML reports I can print from my script using Firefox. There's XPCOM, which looks like Gecko's take on COM, but it may be beyond my current abilities and time constraints (I just started a new job, and don't have as much time to play with this sort of stuff as I used to). If I can figure out a way to do it, I'll post it to, wish me luck :).
Jun 22 '07 #3

Expert Mod 15k+
P: 16,027
Good luck. I don't have much experience in this kind of stuff. Hopefully, someone can help you or you manage to figure something out yourself.
Jun 22 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.