Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Print Bookmarked Webpages

by eibwen (Friar)
on Aug 01, 2005 at 21:11 UTC ( [id://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:

PrintURI("http://somesite.tld/page.html");

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"...

Replies are listed 'Best First'.
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, http://www.hypernews.org/HyperNews/get/www/html/converters.html 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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 12:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found