Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

miyagawa (1653)

  (email not shown publicly)
AOL IM: bulknews (Add Buddy, Send Message)

Journal of miyagawa (1653)

Tuesday August 01, 2006
09:46 PM

Printing HTML via perl

[ #30506 ]


Suppose I have $url or $path_to_html, how can I print them as HTML rednered (probably using browser engine) via Perl? I imagine that it could be done using OLE/AppleScript thing, or using Mozilla command line option but couldn't find any code on the web nor CPAN.

I want solutions for Win32/IE, Win32/Firefox, MacOSX/Safari and MacOSX/Firefox.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Maybe HTML::HTMLDoc can help you !
    • Thanks. I tested PDF::FromHTML as well and i guess these use the same idea behind. What I really want is to display HTML using real browser engines like IE/Firefox/Safari.

      Thanks for your info anyway.
      • Something like this, you mean?

        use Mac::Glue;
        use Mac::InternetConfig; # GetICHelper
        use Mac::MoreFiles; # %Application
        my($id) = GetICHelper('http');
        my $app_path  = $Application{$id};  # or define path yourself ... this could potentially fail
        my $file_path = '/Users/pudge/Desktop/a.html';
        my $finder = new Mac::Glue 'Finder';
        my $file = $finder->obj(file => $file_path);
        my $app  = $finder->obj(file => $app_path);
        $file->open(using => $app);

        • Thanks! Yeah, this is very close, except you code doesn't look like actually "printing" the HTML document. I'd like to automate the print process as well. Thanks for your code anyway. It's pretty helpful.
          • Aha. Well, let's simplify by assuming Safari, then. Try:
            use Mac::Glue;
            my $file_url = 'file://localhost/Users/pudge/Desktop/a.html';
            my $safari = new Mac::Glue 'Safari';
            my $doc = $safari->make(new => 'document');
            $doc->prop('url')->set(to => $file_url);
          • WWW::Selenium might be what you want. Cross-platform too. Right now the interface is a bit rough, but I'm working on making it easier to use with Test::WWW::Selenium::Catalyst.
  • Here's some python code that might help point you in the right direction. []