views:

1316

answers:

4

I want to print styled html pages with their images from a script. Can anyone suggest an open-source solution?

I'm using linux (Ubuntu 8.04) but would be also be interested in solutions for other operating systems.

A: 

I´m not sure if this code works with mono, but it should work with Windows and the "real" .NET Framework at least: http://pietschsoft.com/post/2008/07/C-Generate-WebPage-Thumbmail-Screenshot-Image.aspx

vimpyboy
A: 

If your install has kde on it then you could launch konqueror and use dcop or dbus to send commands to it. It means that you have to have x running though, which may not work for you.

J.D. Fitz.Gerald
+4  A: 

You could give html2ps a try, it is written in Perl, so I guess it wil run on any operating system that runs Perl. It does support CSS and images. It does not render as good as you may perhaps want.

To use in Debian/Ubuntu sudo aptitude install html2ps and then pipe the output to lpr to print:

html2ps \
    http://stackoverflow.com/questions/286583 \
    |lpr

Or pipe the output to ps2pdf to convert to a pdf file:

html2ps \
    http://stackoverflow.com/questions/286583 \
    |ps2pdf - stackoverflow.pdf
Tader
+2  A: 

You have a ton of options: html2ps, html2pdf, a huge list at: http://www.hypernews.org/HyperNews/get/www/html/converters.html

But personally I would recommend going with http://www.htmldoc.org/ it does postscript, PDF and is up to date (most recent release was <2 weeks ago. You'll need to use a tool like wget or elinks to actually download the HTML file and it's components.

Kurt