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和图片的更多相关文章

  1. 使用Pechkin将HTML网页转换为PDF

    Pechkin开源组件使用wkhtmlbox,可以解析CSS样式,将网页转换为PDF文件, 支持URL,或者HTML字符串 1, 从NuGet程序管理器中获得Pechkin  GlobalConfig ...

  2. Python爬虫实战:将网页转换为pdf电子书

    写爬虫似乎没有比用 Python 更合适了,Python 社区提供的爬虫工具多得让你眼花缭乱,各种拿来就可以直接用的 library 分分钟就可以写出一个爬虫出来,今天就琢磨着写一个爬虫,将廖雪峰的 ...

  3. wkhtmltopdf 将网页生成pdf文件

    先安装依赖 yum install fontconfig libXrender libXext xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi freetype l ...

  4. 如何讲一个网页转换为jpg?(图片!)

    不需要安装插件!!! 打开网页,打开开发者工具 快捷键: ctrl+shift+p输入>full即可自动下载!

  5. 关于html转换为pdf案例的一些测试与思考

    由于工作所需,最近花时间研究了html转换为pdf的功能.html转换为pdf的关键技术是如何处理网页中复杂的css样式,通过在网上收集资料,发现目前html 转换为pdf的解决方案主要分为三类: 客 ...

  6. C# 使用 wkhtmltopdf 把HTML文本或文件转换为PDF

    一.简介 之前也记录过一篇关于把 HTML 文本或 HTML 文件转换为 PDF 的博客,只是之前那种方法有些局限性. 后来又了解到 wkhtmltopdf.exe 这个工具,这个工具比起之前的那种方 ...

  7. Python|网页转PDF,PDF转图片爬取校园课表~

    import pdfkit import requests from bs4 import BeautifulSoup from PIL import Image from pdf2image imp ...

  8. C#/VB.NET 将SVG图片添加到PDF、转换为PDF

    以下内容介绍在C# 程序中如何将SVG图片添加到PDF文档.以及如何将SVG图片转换为PDF文档. 一.环境准备 先下载PDF类库工具,Spire.PDF for .NET hotfix 6.5.6及 ...

  9. python 爬虫,网页转PDF:OSError: No wkhtmltopdf executable found

    解决办法: 代码中设置参数: path_wk = r‘D:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe‘ #wkhtmltopdf安装位置 config ...

随机推荐

  1. href,src,url 整理

    一.href 和 src 的定义及区别 href:Hypertext Reference(超文本引用),指定网络资源的位置,从而在当前元素或者当前文档和由当前属性定义的需要的锚点或资源之间定义一个链接 ...

  2. 深入浅出学Spring Data JPA

    第一章:Spring Data JPA入门 Spring Data是什么 Spring Data是一个用于简化数据库访问,并支持云服务的开源框架.其主要目标是使得对数据的访问变得方便快捷,并支持map ...

  3. mysql-proxy 读写分离

    mysql-proxy 读写分离 主从复制 MySQL Replication可以将master的数据复制分布到多个slave上,然后利用slave来分担master的读压力. 读写分离 MySQL- ...

  4. Oracle下批量将一个用户的所有表的select权限赋值给另外一个用户

    起因 为什么会有这篇文章呢? 因为最近在做项目的时候遇到一个问题...实际生产环境中程序datasource登陆的Oracle数据库用户user1不是我们创建的.这个用户没有访问我们业务表的权限(因为 ...

  5. 美团HD(2)-设置导航栏内容

    DJHomeViewController.m #import "DJHomeViewController.h" #import "DJConstantValue.h&qu ...

  6. nGrinder安装指南

    NGrinder 由两个模块组成,其运行环境为 Oracle JDK 1.6 nGrinder controller  web 应用程序,部署在Tomcat 6.x 或更高的版本 nGrinder A ...

  7. Tiny Mapper

    今天看到一个对象映射工具-TinyMapper 1.介绍 Tiny Mapper是一个.net平台的开源的对象映射组件,其它的对象映射组件比如AutoMapper有兴趣的可以去看,Tiny Mappe ...

  8. C++网络套接字编程TCP和UDP实例

    原文地址:C++网络套接字编程TCP和UDP实例作者:xiaojiangjiang 1.       创建一个简单的SOCKET编程流程如下 面向有连接的套接字编程 服务器: 1)  创建套接字(so ...

  9. express-session使用理解

    本篇主要段落翻译来自https://github.com/expressjs/session 客户端与服务会使用一个Sessionid的Cookie值来进行客户端和服务器端会话的匹配,这个Cookie ...

  10. http://detectmobilebrowsers.com/

    <%@ Page Language="C#" %> <%@ Import Namespace="System.Text.RegularExpressio ...