将.html文件转换为图像 [英] Convert .html file to image
问题描述
我正在寻找任何能够忠实地将.html文件转换为图像格式的实用程序 - 最好是png或jpeg。我搜索了几个小时,下载了十几个免费试用版,但似乎没有任何工作。 Adobe Acrobat Pro几乎可以工作,但它决定缩小表格单元格以适应页面,而不是缩小整个表格。
任何建议值得赞赏。
Regards。
我使用wkhtmltoimage。
这是一个快速的命令行工具,它使用webkit库来呈现任何网站。
有两个版本用于生成pdf和一个用于生成图像。
wkhtmltoimage可与Windows,Linux和Mac一起使用。
http://code.google.com/p/wkhtmltopdf/
/ wkhtmltoimage-i386 -H
名称:
wkhtmltoimage 0.10.0 rc2
简介:
wkhtmltoimage [选项] ...<输入文件> <输出文件>
描述:
将HTML页面转换为图像
常规选项:
--allow< path>允许指定的
文件夹中的文件或文件被加载(可重复)
--checkbox-checked-svg<路径>使用此SVG文件时呈现检查
复选框
--checkbox-svg<路径>渲染未选中时使用此SVG文件
复选框
--cookie< name> <值GT;设置一个额外的cookie(可重复)
--cookie-jar< path>从
提供的cookie jar文件中读取和写入cookie
--crop -h 设置裁切高度
--crop-w 设置裁切宽度
--crop-x 设置裁切
的-x坐标--crop-y 设置裁切
的自定义坐标 - 自定义标题<名称> <值GT;设置一个额外的HTTP头(可重复)
--custom-header-propagation为每个资源请求添加由
--custom-header指定的HTTP头。
--no-custom-header-propagation不要为每个资源请求添加由
--custom-header指定的HTTP标头。
--debug-javascript显示javascript调试输出
--no-debug-javascript不显示javascript调试输出
(默认)
--encoding< encoding>设置默认文本编码,用于输入
-H,--extended -help显示更广泛的帮助,详述
不常用命令开关
-f,--format< format>输出文件格式(默认为jpg)
--height< int>设置屏幕高度(默认值从页面内容计算
)(默认为0)
-h,--help显示帮助
--htmldoc输出程序html帮助
--images执行加载或打印图像(默认)
- 无图像不加载或打印图像
-n,--disable-javascript不允许网页运行javascript
--enable- javascript允许网页运行javascript
(默认)
--javascript-delay< msec> javascript
完成(默认200)等待几毫秒
- 载入错误处理<处理程序>指定如何处理无法执行
加载的页面:abort,ignore或skip(默认
abort)
--disable-local-file-access不允许转换本地文件
在其他本地文件中读取,除非
使用--allow
explecitily允许--enable-local-file-access允许本地文件转换为在其他本地文件中读取
。 (默认)
--manpage输出程序手册页
--minimum-font-size< int>最小字体大小
- 密码<密码> HTTP身份验证密码
--disable-plugins禁用已安装的插件(默认)
--enable-plugins启用已安装的插件(插件将
可能不起作用)
--post<名称> <值GT;添加额外的帖子字段(可重复)
- post-file< name> <路径>发布额外的文件(可重复)
-p,--proxy< proxy>使用代理
--quality< int>输出图像质量(0到100之间)
(默认94)
--radiobutton-checked-svg<路径>使用此SVG文件时,呈现检查
单选按钮
--radiobutton-svg<路径>渲染未经检查时使用此SVG文件
单选按钮
--readme输出程序自述文件
--run-script< js>在
页面完成加载后(可重复)
-0,--disable-smart-width,运行这个额外的javascript即使它不是
足够大的内容,也可以使用指定的宽度
--stop-slow-scripts停止运行缓慢的javascripts(默认)
--no-stop-slow-scripts不要停止运行缓慢的javascripts
(默认)
--transparent使背景在png中透明
--use-xserver使用X服务器(一些插件和其他
的东西在没有X11的情况下可能不起作用)
--user-style-sheet< url>指定用户样式表,每页加载
--username< username> HTTP身份验证用户名
-V,--version输出版本信息并退出
--width< int>设置屏幕宽度(默认值为1024)
(默认1024)
--window-status< windowStatus>在呈现页面之前等待window.status等于这个
字符串
--zoom< float>使用这个缩放因子(默认为1)
指定代理:
默认情况下,代理信息将从环境变量中读取:
proxy,all_proxy和http_proxy,代理选项也可以通过指定
-p开关
< type> :=http://| socks5://
< serif> :=<用户名> (:<密码>)? @
< proxy> :=无| <类型> ;? < sering> ;? <宿主GT; (:< port>)?
以下是一些示例(如果您不熟悉BNF):
http:// user:password @ myproxyserver:8080
socks5:// myproxyserver
无
联系人:
如果您遇到错误或想要申请新功能,请访问
< http://code.google.com/p/ wkhtmltopdf / issues / list>,如果您有任何问题
或意见,请随时与我联系:< uuf6429@gmail.com>
演示:
./ wkhtmltoimage-i386http://stackoverflow.com/questions/11907986/convert-html-file-to-image/11908055#11908055demo.png
I am looking for any utility that will faithfully convert a .html file to an image format -- preferable png or jpeg. I have Googled for hours and downloaded a dozen or so free trials but nothing seems to do the job. Adobe Acrobat Pro almost worked but it is determined to shrink table cells to fit on a page rather than shrinking the whole table.
Any advice is appreciated.
Regards.
I am using wkhtmltoimage.
It is a fast command line tool which uses the webkit library to render any website. There are two versions one to generate pdfs and one to generate images.
wkhtmltoimage works with Windows, Linux and Mac.
http://code.google.com/p/wkhtmltopdf/
/wkhtmltoimage-i386 -H
Name:
wkhtmltoimage 0.10.0 rc2
Synopsis:
wkhtmltoimage [OPTIONS]... <input file> <output file>
Description:
Converts an HTML page into an image,
General Options:
--allow <path> Allow the file or files from the specified
folder to be loaded (repeatable)
--checkbox-checked-svg <path> Use this SVG file when rendering checked
checkboxes
--checkbox-svg <path> Use this SVG file when rendering unchecked
checkboxes
--cookie <name> <value> Set an additional cookie (repeatable)
--cookie-jar <path> Read and write cookies from and to the
supplied cookie jar file
--crop-h <int> Set height for croping
--crop-w <int> Set width for croping
--crop-x <int> Set x coordinate for croping
--crop-y <int> Set y coordinate for croping
--custom-header <name> <value> Set an additional HTTP header (repeatable)
--custom-header-propagation Add HTTP headers specified by
--custom-header for each resource request.
--no-custom-header-propagation Do not add HTTP headers specified by
--custom-header for each resource request.
--debug-javascript Show javascript debugging output
--no-debug-javascript Do not show javascript debugging output
(default)
--encoding <encoding> Set the default text encoding, for input
-H, --extended-help Display more extensive help, detailing
less common command switches
-f, --format <format> Output file format (default is jpg)
--height <int> Set screen height (default is calculated
from page content) (default 0)
-h, --help Display help
--htmldoc Output program html help
--images Do load or print images (default)
--no-images Do not load or print images
-n, --disable-javascript Do not allow web pages to run javascript
--enable-javascript Do allow web pages to run javascript
(default)
--javascript-delay <msec> Wait some milliseconds for javascript
finish (default 200)
--load-error-handling <handler> Specify how to handle pages that fail to
load: abort, ignore or skip (default
abort)
--disable-local-file-access Do not allowed conversion of a local file
to read in other local files, unless
explecitily allowed with --allow
--enable-local-file-access Allowed conversion of a local file to read
in other local files. (default)
--manpage Output program man page
--minimum-font-size <int> Minimum font size
--password <password> HTTP Authentication password
--disable-plugins Disable installed plugins (default)
--enable-plugins Enable installed plugins (plugins will
likely not work)
--post <name> <value> Add an additional post field (repeatable)
--post-file <name> <path> Post an additional file (repeatable)
-p, --proxy <proxy> Use a proxy
--quality <int> Output image quality (between 0 and 100)
(default 94)
--radiobutton-checked-svg <path> Use this SVG file when rendering checked
radiobuttons
--radiobutton-svg <path> Use this SVG file when rendering unchecked
radiobuttons
--readme Output program readme
--run-script <js> Run this additional javascript after the
page is done loading (repeatable)
-0, --disable-smart-width Use the specified width even if it is not
large enough for the content
--stop-slow-scripts Stop slow running javascripts (default)
--no-stop-slow-scripts Do not Stop slow running javascripts
(default)
--transparent Make the background transparent in pngs
--use-xserver Use the X server (some plugins and other
stuff might not work without X11)
--user-style-sheet <url> Specify a user style sheet, to load with
every page
--username <username> HTTP Authentication username
-V, --version Output version information an exit
--width <int> Set screen width (default is 1024)
(default 1024)
--window-status <windowStatus> Wait until window.status is equal to this
string before rendering page
--zoom <float> Use this zoom factor (default 1)
Specifying A Proxy:
By default proxy information will be read from the environment variables:
proxy, all_proxy and http_proxy, proxy options can also by specified with the
-p switch
<type> := "http://" | "socks5://"
<serif> := <username> (":" <password>)? "@"
<proxy> := "None" | <type>? <sering>? <host> (":" <port>)?
Here are some examples (In case you are unfamiliar with the BNF):
http://user:password@myproxyserver:8080
socks5://myproxyserver
None
Contact:
If you experience bugs or want to request new features please visit
<http://code.google.com/p/wkhtmltopdf/issues/list>, if you have any problems
or comments please feel free to contact me: <uuf6429@gmail.com>
Demo:
./wkhtmltoimage-i386 "http://stackoverflow.com/questions/11907986/convert-html-file-to-image/11908055#11908055" demo.png
这篇关于将.html文件转换为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!