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.

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.css

Here 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的更多相关文章

  1. HTML 5与CSS 3权威指南(第2版·上册) 中文pdf扫描版​

    HTML5与CSS3权威指南(第2版·上册)已经成为HTML 5与CSS 3图书领域的一个标杆,被读者誉为“系统学习HTML 5与CSS 3技术的最佳指导参考书之一”和“Web前端工程师案头必备图书之 ...

  2. 使用 pdf.js 在网页中加载 pdf 文件

    在网页中加载并显示PDF文件是最常见的业务需求.例如以下应用场景:(1)在电商网站上购物之后,下载电子发票之前先预览发票.(2)电子商务管理系统中查看发布的公文,公文文件一般是PDF格式的文件. 目前 ...

  3. 使用pdf.js实现前端页面预览pdf文档,解决了跨域请求

    pdf.js主要包含两个库文件,一个pdf.js和一个pdf.worker.js,,一个负责API解析,一个负责核心解析 官网地址:http://mozilla.github.io/pdf.js/ 下 ...

  4. 在线打开,浏览PDF文件的各种方式及各种pdf插件------(MS OneDrive/google drive & google doc/ github ?raw=true)

    在线打开,浏览PDF文件的各种方式: 1 Google drive&doc   (国内不好使,you know GFW=Great Firewall) 1. google drive: 直接分 ...

  5. 谈谈一些有趣的CSS题目(十一)-- reset.css 知多少?

    开本系列,谈谈一些有趣的 CSS 题目,题目类型天马行空,想到什么说什么,不仅为了拓宽一下解决问题的思路,更涉及一些容易忽视的 CSS 细节. 解题不考虑兼容性,题目天马行空,想到什么说什么,如果解题 ...

  6. CSS性能分析,如何优化CSS提高性能

    不负十年后的自己,共勉! 前端性能优化一直是一个比较热门的话题,我们总是在尽我们最大的努力去,提高我们的页面性能,比如减少HTTP请求,利用工具对资源进行合并压缩,脚本置底,避免重复请求,css sp ...

  7. Normalize.css – 现代 Web 开发必备的 CSS resets

    Normalize.css 是一个可定制的 CSS 文件,使浏览器呈现的所有元素,更一致和符合现代标准.它正是针对只需要统一的元素样式.该项目依赖于研究浏览器默认元素风格之间的差异,精确定位需要重置的 ...

  8. 你真的精通 CSS 了?来挑战一下 CSS 选择器测验吧

    CSS 选择器赋予 CSS 强大的 HTML 元素匹配功能.作为前端开发人员必须要掌握的一部分,可能基本的大家都知道.但是你真的精通 CSS 了吗?挑战一下 CSS 选择器测验就知道. 您可能感兴趣的 ...

  9. CSS样式----图文详解:css样式表和选择器

    主要内容 CSS概述 CSS和HTML结合的三种方式:行内样式表.内嵌样式表.外部样式表 CSS四种基本选择器:标签选择器.类选择器.ID选择器.通用选择器 CSS三种扩展选择器:组合选择器.后代选择 ...

随机推荐

  1. C - Wooden Sticks

    C - Wooden Sticks Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  2. BZOJ 4321: queue2( dp )

    dp(i, j, 1)表示前i个, 有j对是不合法的, i和i-1是在一起的. dp(i, j, 0)表示前i个, 有j对是不合法的, i和i-1不在一起的. 转移我们只需考虑是多了一对不合法的还是少 ...

  3. 常用Java片段

    1. 字符串与整型的相互转换 String a = String.valueOf(2);   //integer to numeric string int i = Integer.parseInt( ...

  4. 初来乍到--------smarty

    Smarty Day01-----smarty的使用 作用:把php+html分离,程序和美工 使用: 1.下载源码包 2.目录结构 libs 源码文件 Smarty.class.php templa ...

  5. ndk 编译 boost 库,支持serialization

    Boost库是一个可移植.提供源代码的C++库,作为标准库的后备,是C++标准化进程的开发引擎之一. Boost库由C++标准委员会库工作组成员发起,其中有些内容有望成为下一代C++标准库内容.在C+ ...

  6. Python2.7.3 学习——准备开发环境

    安装环境搭建参考:http://blog.163.com/sunshine_linting/blog/static/4489332320129187464222/ 第一种方式,通过命令行方式安装Pyt ...

  7. Word2Vec在Tensorflow上的版本以及与Gensim之间的运行对比

    接昨天的博客,这篇随笔将会对本人运行Word2Vec算法时在Gensim以及Tensorflow的不同版本下的运行结果对比.在运行中,参数的调节以及迭代的决定本人并没有很好的经验,所以希望在展出运行的 ...

  8. firefox的window.onerror没有详细的出错提示

    当在firefox浏览器的a.htm页面中使用script标签加载某a.js出错时,如果放置window.onerror事件处理方法时,此方法获取到的错误信息都是固定的: {0:"Scrip ...

  9. gravitas是什么意思_gravitas在线翻译_英语_读音_用法_例句_海词词典

    gravitas是什么意思_gravitas在线翻译_英语_读音_用法_例句_海词词典 gravitas

  10. 有道翻译API

    轻奢侈品_百度百科 轻奢侈品 有道翻译API 有道翻译API申请成功 API key:72763558 keyfrom:lexus-studio