Can I print html files (with images, css) from the

2019-03-27 16:26发布

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.

4条回答
狗以群分
2楼-- · 2019-03-27 17:01

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

查看更多
疯言疯语
3楼-- · 2019-03-27 17:03

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
查看更多
你好瞎i
4楼-- · 2019-03-27 17:10

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

查看更多
劳资没心,怎么记你
5楼-- · 2019-03-27 17:19

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.

查看更多
登录 后发表回答