WeasyPrint - Converts HTML + CSS to PDF - WeasyPrint converts HTML/CSS documents to PDF
WeasyPrint - Converts HTML + CSS to PDF - WeasyPrint converts HTML/CSS documents to PDF
WeasyPrint converts HTML/CSS documents to PDF
WeasyPrint is a visual rendering engine for HTML and CSS that can export to PDF. It aims to support web standards for printing. WeasyPrint is free software made available under a BSD license.
It is based on various libraries but not on a full rendering engine like WebKit or Gecko. The CSS layout engine is written in Python, designed for pagination, and meant to be easy to hack on.
- Free software: BSD licensed
- Python 2.6+ or 3.x
- Source code and issue tracker: on Github
- Documentation
- Get in touch
Sample output
As an example, here is the introduction chapter of the CSS 2.1 spec rendered with WeasyPrint: CSS21-intro.pdf. It was obtained by running:
weasyprint http://www.w3.org/TR/CSS21/intro.html CSS21-intro.pdf -s http://weasyprint.org/samples/CSS21-print.cssHere is an extract of CSS21-print.css:
@page {
margin: 3cm 2cm; padding-left: 1.5cm;
@top-center {
content: "Introduction to CSS 2.1";
vertical-align: bottom; border-bottom: 0.5pt solid }
@bottom-right {
content: "Page " counter(page) " of " counter(pages) }
@left-top {
content: "W3C Recommendation";
background: #005a9c; color: #fff; text-align: right;
transform-origin: % ; transform: rotate(-90deg) }}
body { text-align: justify }
h1 { -weasy-bookmark-level: none }
Acid2
Starting with version 0.11, WeasyPrint passes the Acid2 test. This test was published by the Web Standards Project as a challenge for web browser to get better support for the HTML, CSS and PNG standards. It is made of many small elements with various positioning techniques. When all the layout rules are implemented correctly, they should add up to the smiling face shown on the right.
Have a look at WeasyPrint’s output in PDF and in PNG. The PNG is pixel-perfect, but with PDF you may see faint lines or a moiré pattern inside the smiling head. This is because the test is made for pixel-based screens with many layers of different colors that overlap exactly. Only the top layers are supposed to be visible but due to the way that most PDF viewers use anti-aliasing, the bottom layers may bleed on the sides.
WeasyPrint - Converts HTML + CSS to PDF - WeasyPrint converts HTML/CSS documents to PDF的更多相关文章
- HTML 5与CSS 3权威指南(第2版·上册) 中文pdf扫描版
HTML5与CSS3权威指南(第2版·上册)已经成为HTML 5与CSS 3图书领域的一个标杆,被读者誉为“系统学习HTML 5与CSS 3技术的最佳指导参考书之一”和“Web前端工程师案头必备图书之 ...
- 使用 pdf.js 在网页中加载 pdf 文件
在网页中加载并显示PDF文件是最常见的业务需求.例如以下应用场景:(1)在电商网站上购物之后,下载电子发票之前先预览发票.(2)电子商务管理系统中查看发布的公文,公文文件一般是PDF格式的文件. 目前 ...
- 使用pdf.js实现前端页面预览pdf文档,解决了跨域请求
pdf.js主要包含两个库文件,一个pdf.js和一个pdf.worker.js,,一个负责API解析,一个负责核心解析 官网地址:http://mozilla.github.io/pdf.js/ 下 ...
- 在线打开,浏览PDF文件的各种方式及各种pdf插件------(MS OneDrive/google drive & google doc/ github ?raw=true)
在线打开,浏览PDF文件的各种方式: 1 Google drive&doc (国内不好使,you know GFW=Great Firewall) 1. google drive: 直接分 ...
- 谈谈一些有趣的CSS题目(十一)-- reset.css 知多少?
开本系列,谈谈一些有趣的 CSS 题目,题目类型天马行空,想到什么说什么,不仅为了拓宽一下解决问题的思路,更涉及一些容易忽视的 CSS 细节. 解题不考虑兼容性,题目天马行空,想到什么说什么,如果解题 ...
- CSS性能分析,如何优化CSS提高性能
不负十年后的自己,共勉! 前端性能优化一直是一个比较热门的话题,我们总是在尽我们最大的努力去,提高我们的页面性能,比如减少HTTP请求,利用工具对资源进行合并压缩,脚本置底,避免重复请求,css sp ...
- Normalize.css – 现代 Web 开发必备的 CSS resets
Normalize.css 是一个可定制的 CSS 文件,使浏览器呈现的所有元素,更一致和符合现代标准.它正是针对只需要统一的元素样式.该项目依赖于研究浏览器默认元素风格之间的差异,精确定位需要重置的 ...
- 你真的精通 CSS 了?来挑战一下 CSS 选择器测验吧
CSS 选择器赋予 CSS 强大的 HTML 元素匹配功能.作为前端开发人员必须要掌握的一部分,可能基本的大家都知道.但是你真的精通 CSS 了吗?挑战一下 CSS 选择器测验就知道. 您可能感兴趣的 ...
- CSS样式----图文详解:css样式表和选择器
主要内容 CSS概述 CSS和HTML结合的三种方式:行内样式表.内嵌样式表.外部样式表 CSS四种基本选择器:标签选择器.类选择器.ID选择器.通用选择器 CSS三种扩展选择器:组合选择器.后代选择 ...
随机推荐
- STL模板_十大容器概念
一.向量(续)1.大小和容量大小:容器中元素的个数.容量:容器中可容纳元素的个数.size_type size (void) const; // 获取大小void resize (size_type ...
- cocos2d-x学习日志(12) --弹出对话框的设计与实现
我们时常需要这么些功能,弹出一个层,给与用户一些提示,这也是一种模态窗口,在没有对当前对话框进行确认的时候,不能继续往下操作. 功能分析 我们设计一个对话框,对话框上有几个按钮(个数可定制),当然有个 ...
- Android 图片处理效果集
总共可以处理出大约100种图片效果,常见的和不常见的滤镜效果可以处理出来,可以说涵盖了市面上所有特效相机可以处理出来的效果.项目所有代码都是纯java代码实现,没有封装成jar包.截图是挑选了几张有代 ...
- 通过class实例取得类的接口,父类,构造器
interface China { public static final String NATIONAL = "JAPAN"; public static fin ...
- JAVA之GUI编程窗体事件
package GUI; import java.awt.Button;import java.awt.FlowLayout;import java.awt.Frame;import java.awt ...
- php知识--递归
<?php // /* * 遍历输出文件夹中的所有内容 * @param1 string $dir,要遍历的路径 * @param2 int $level = 0,当前的级别 */ functi ...
- Ubuntu14下LAMP环境的安装以及yaf扩展的安装
前段时间在ubuntu下安装了lamp环境,记录一下安装过程方便以后查阅. 安装lamp环境 ① 安装apache sudo apt-get install apache2 系统会弹出如图所示的提示, ...
- zoj 3171 The Hidden 7's
这道题,我在网上看到两种dp,不过基本原理是一样的,不过感觉还是后面的一种比较巧妙!因为我对动态不是很熟,自能加上一些自己的理解,写上注释. 1) #include <stdio.h> # ...
- 《Pointers On C》读书笔记(第四章 语句)
1.空语句只包含一个分号,它本身并不执行任何任务,其适用的场合是语法要求出现一条完整的语句,但并不需要它执行任何任务. 2.C语言中并不存在专门的“赋值语句”,赋值就是一种操作,在表达式内进行.通过在 ...
- 转: Apache SSI详解及应用
转: Apache SSI详解及应用 什么是 SSI? SSI(Server Side Includes),是嵌套在 HTML 网页中的指示语句,由后台服务器进行代码的解释计算.使用 SSI 可以动态 ...
