wkhtmltopdf 将网页转换为PDF和图片
wkhtmltopdf 是一个shell工具,它使用了WebKit渲染引擎和Qt,将网页html转换为pdf的强大工具,转换后的pdf也可以通过pdf工具进行复制、备注、修改
官网下载地址:http://wkhtmltopdf.org/downloads.html
安装:
linux
apt-get install wkhtmltopdf
windows 执行下载安装包安装
使用:
使用-help查看使用命令
Name:
wkhtmltopdf 0.12.3.2 (with patched qt) Synopsis:
wkhtmltopdf [GLOBAL OPTION]... [OBJECT]... <output file> Document objects:
wkhtmltopdf is able to put several objects into the output file, an object is
either a single webpage, a cover webpage or a table of content. The objects
are put into the output document in the order they are specified on the
command line, options can be specified on a per object basis or in the global
options area. Options from the Global Options section can only be placed in
the global options area A page objects puts the content of a singe webpage into the output document. (page)? <input url/file name> [PAGE OPTION]...
Options for the page object can be placed in the global options and the page
options areas. The applicable options can be found in the Page Options and
Headers And Footer Options sections. A cover objects puts the content of a singe webpage into the output document,
the page does not appear in the table of content, and does not have headers
and footers. cover <input url/file name> [PAGE OPTION]...
All options that can be specified for a page object can also be specified for
a cover. A table of content object inserts a table of content into the output document. toc [TOC OPTION]...
All options that can be specified for a page object can also be specified for
a toc, further more the options from the TOC Options section can also be
applied. The table of content is generated via XSLT which means that it can be styled to look however you want it to look. To get an aide of how to do this
you can dump the default xslt document by supplying the
--dump-default-toc-xsl, and the outline it works on by supplying
--dump-outline, see the Outline Options section. Description:
Converts one or more HTML pages into a PDF document, using wkhtmltopdf patched qt. Global Options:
--collate Collate when printing multiple copies
(default)
--no-collate Do not collate when printing multiple
copies
--copies <number> Number of copies to print into the pdf
file (default )
-H, --extended-help Display more extensive help, detailing
less common command switches
-g, --grayscale PDF will be generated in grayscale
-h, --help Display help
--license Output license information and exit
-l, --lowquality Generates lower quality pdf/ps. Useful to
shrink the result document space
-O, --orientation <orientation> Set orientation to Landscape or Portrait
(default Portrait)
-s, --page-size <Size> Set paper size to: A4, Letter, etc.
(default A4)
-q, --quiet Be less verbose
--read-args-from-stdin Read command line arguments from stdin
--title <text> The title of the generated pdf file (The
title of the first document is used if not specified)
-V, --version Output version information and exit Page Options:
--print-media-type Use print media-type instead of screen
--no-print-media-type Do not use print media-type instead of
screen (default) Contact:
If you experience bugs or want to request new features please visit
<https://github.com/wkhtmltopdf/wkhtmltopdf/issues> C:\Program Files\wkhtmltopdf\bin>
所以
wkhtmltopdf example.com example.pdf
即可生成pdf

查看 topdf.pdf

然而,wkhtmltopdf 还提供了一个wkhtmltoimage 的工具
将html转换为图片

效果toimage.png:

wkhtmltopdf 将网页转换为PDF和图片的更多相关文章
- 使用Pechkin将HTML网页转换为PDF
Pechkin开源组件使用wkhtmlbox,可以解析CSS样式,将网页转换为PDF文件, 支持URL,或者HTML字符串 1, 从NuGet程序管理器中获得Pechkin GlobalConfig ...
- Python爬虫实战:将网页转换为pdf电子书
写爬虫似乎没有比用 Python 更合适了,Python 社区提供的爬虫工具多得让你眼花缭乱,各种拿来就可以直接用的 library 分分钟就可以写出一个爬虫出来,今天就琢磨着写一个爬虫,将廖雪峰的 ...
- wkhtmltopdf 将网页生成pdf文件
先安装依赖 yum install fontconfig libXrender libXext xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi freetype l ...
- 如何讲一个网页转换为jpg?(图片!)
不需要安装插件!!! 打开网页,打开开发者工具 快捷键: ctrl+shift+p输入>full即可自动下载!
- 关于html转换为pdf案例的一些测试与思考
由于工作所需,最近花时间研究了html转换为pdf的功能.html转换为pdf的关键技术是如何处理网页中复杂的css样式,通过在网上收集资料,发现目前html 转换为pdf的解决方案主要分为三类: 客 ...
- C# 使用 wkhtmltopdf 把HTML文本或文件转换为PDF
一.简介 之前也记录过一篇关于把 HTML 文本或 HTML 文件转换为 PDF 的博客,只是之前那种方法有些局限性. 后来又了解到 wkhtmltopdf.exe 这个工具,这个工具比起之前的那种方 ...
- Python|网页转PDF,PDF转图片爬取校园课表~
import pdfkit import requests from bs4 import BeautifulSoup from PIL import Image from pdf2image imp ...
- C#/VB.NET 将SVG图片添加到PDF、转换为PDF
以下内容介绍在C# 程序中如何将SVG图片添加到PDF文档.以及如何将SVG图片转换为PDF文档. 一.环境准备 先下载PDF类库工具,Spire.PDF for .NET hotfix 6.5.6及 ...
- python 爬虫,网页转PDF:OSError: No wkhtmltopdf executable found
解决办法: 代码中设置参数: path_wk = r‘D:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe‘ #wkhtmltopdf安装位置 config ...
随机推荐
- LR破解版录制手机脚本(一)模拟器录制
最近在网上听到好多童鞋都在问如何用LR做手机性能测试,恰好自己对这方面也挺感兴趣,经过查阅很多资料,形成此文档以做备注~!如果有感觉我写的不对的地方,敬请指正,谢谢~! 其实自从LR12出来之 ...
- 【转】PHP中获取当前系统时间、时间戳
今天写下otime($time, $now)为将时间格式转为时间戳,$time为必填.清楚了这个,想了解更多,请继续往下看. 3. date($format)用法比如:echo date('Y-m-d ...
- jsp URL中文传值
js中,讲中文转码 encodeURI(中文): Java中,转回中文 java.net.URLDecoder.decode(乱码,"utf-8"): 例子; window.loc ...
- jquery 返回顶部 兼容web移动
返回顶部图片 http://hovertree.com/texiao/mobile/6/tophovertree.gif 具体实现代码 <span id="tophovertree&q ...
- MongoDB【第三篇】MongoDB基本操作
MongoDB的基本操作包括文档的创建.删除.和更新 文档插入 1.插入 #查看当前都有哪些数据库 > show dbs; local 0.000GB tim 0.000GB #使用 tim数据 ...
- 在使用 vscode 时 eslint 检测 .vue 文件中的less 部分内容
问题: 在使用 vscode 以及 eslint 来检测 基于 webpack 的 vue-cli 的项目中,eslint 无法检测到 .vue 文件中的less 部分内容. 解答: 1.通过 下载 ...
- 李炎恢《PHP第二季视频教程》之总结
课时 <面向对象工具[1]>. 语法: __autoload. __call.__tostring.__clone 1. autoload 自动引用类.不用包含类,call屏蔽调用类 ...
- web页面跳转的几种方式
可用客户端触发或服务端触发的方式来实现页面跳转. 客户端触发 方式一:使用Javascript 利用window.location对象的href属性.assign()方法或replace()方法来实现 ...
- soft-margin SVM
1. soft-margin SVM的形式 其中ξn表示每个点允许的犯错程度(偏离margin有多远),但是犯错是有代价的,也就是目标函数里面要最小化的.c控制对犯错的容忍程度. 2. 推导soft ...
- linux Mint 安装apache2
sudo apt-get install apache2 y 启动apache2 /etc/init.d/apache2 restart 浏览器输入localhost看看是否访问正常 apache2 ...