我可以从命令行打印html文件(带图像,css)吗?

Ken*_*Ken 8 html linux printing scripting command-line

我想用脚本中的图像打印样式化的html页面.任何人都可以建议一个开源解决方案吗?

我正在使用linux(Ubuntu 8.04),但也会对其他操作系统的解决方案感兴趣.

Tad*_*der 9

您可以尝试使用html2ps,它是用Perl编写的,所以我猜它会在任何运行Perl的操作系统上运行.它支持CSS和图像.它并没有像你想象的那样好.

要在Debian/Ubuntu中使用sudo aptitude install html2ps,然后将输出管道输出lpr到print:

html2ps \
    http://stackoverflow.com/questions/286583 \
    |lpr
Run Code Online (Sandbox Code Playgroud)

或者将输出传递给ps2pdf以转换为pdf文件:

html2ps \
    http://stackoverflow.com/questions/286583 \
    |ps2pdf - stackoverflow.pdf
Run Code Online (Sandbox Code Playgroud)


小智 5

您有很多选择:html2ps、html2pdf,还有一个巨大的列表:http ://www.hypernews.org/HyperNews/get/www/html/converters.html

但我个人建议使用htmldoc,它可以提供 postscript、PDF 并且是最新的(最新版本是 <2 周前)。您需要使用 wget 或 elinks 等工具来实际下载 HTML 文件及其组件。