Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Print Bookmarked Webpages

by eibwen (Friar)
on Aug 01, 2005 at 21:11 UTC ( #480038=perlquestion: print w/ replies, xml ) Need Help??
eibwen has asked for the wisdom of the Perl Monks concerning the following question:

I've done a bit of preliminary research, but I figured I'd request confirmation before I go waste a ream...

I need to print the websites bookmarked in a particular folder of my firefox bookmarks. Netscape::Bookmarks seems to be able to parse the bookmarks, but I'm having trouble finding an apt printing module. Ideally I'd like to be able to do something like the following:


At this point I should note that I have access to both Windows and Linux, but the printer is currently hooked up to the Windows box. My research thus far has been with regard to printing on Windows, but Linux alternatives are welcome as well.

  • Win32::Printer::Direct will print a file, but a URI? I imagine I could rig an LWP::Simple to create a stream; however I'd like to print the website, not the raw HTML, et all.
  • Printer is cross platform, but seems a bit more raw

I did find a few other modules as well, but I guess the real question is how to print a website as a browser renders, as opposed to the raw HTML?

UPDATE: LWP::Simple::getprint($url) and LWP::Simple::getstore($file) appear to offer the functionality I was looking for. While using getstore($file) appears simple enough, how would I use getprint($url) and print the resultant stream?

UPDATE: LWP::Simple merely solves the problem of obtaining a stream; however I have yet to figure out how to render HTML and send the rendered stream to the printer...

UPDATE: Thanks to Re: Win32::OLE printing I managed to figure out how to get Internet Explorer to print without intervention; however I still can't figure out how to get the URLs from my bookmarks list. Netscape::Bookmarks::Category seemed promising, but I can't figure out how to change from the root category to the one I want. URI::Bookmarks::tree_root() appears to be able to change the root to a folder -- but I can't seem to figure out how to represent that folder as a "node"...

Comment on Print Bookmarked Webpages
Select or Download Code
Re: Print Bookmarked Webpages
by Joost (Canon) on Aug 01, 2005 at 21:29 UTC
    I think I'd go for either a HTML to postscript/pdf converter, has a few options. Or I'd try to convince my browser to print the document for me via perl automation - if you want to use IE, you might be able to do this via the Win32 modules. IIRC there was some kind of interface for mozilla via perl, but I can't seem to find it right now.

    I must say that the direct HTML -> pdf/ps route has been less than satisfactory for me right now (I only tried a few options, mostly java ones, YMMV), mostly because the HTML rendering turns out much uglier than the print-output of mozilla/IE, so I'd suggest you try printing via a mature graphical browser first.

Re: Print Bookmarked Webpages
by Joost (Canon) on Aug 03, 2005 at 14:08 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://480038]
Approved by friedo
Front-paged by GrandFather
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2014-08-21 09:08 GMT
Find Nodes?
    Voting Booth?

    The best computer themed movie is:

    Results (128 votes), past polls