Features ======== This page is for WeasyPrint |version|. See :doc:`changelog ` for older versions. URLs ---- WeasyPrint can read normal files, HTTP, FTP and `data URIs`_. It will follow HTTP redirects but more advanced features like cookies and authentication are currently not supported, although a custom :ref:`url fetcher ` can help. .. _data URIs: http://en.wikipedia.org/wiki/Data_URI_scheme HTML ---- Many HTML elements are implemented in CSS through the HTML5 `User-Agent stylesheet `_. Some elements need special treatment: * The ```` element, if present, determines the base for relative URLs. * CSS stylesheets can be embedded in `` … Automatic hyphenation can be disabled again with the ``manual`` value: .. code-block:: css html { hyphens: auto } a[href]::after { content: ' [' attr(href) ']'; hyphens: manual } The other features provided by `CSS Text Module Level 3`_ are **not** supported: - the ``line-break`` and ``word-break`` properties; - the ``start``, ``end``, ``match-parent`` and ``start end`` values of the ``text-align`` property; - the ``text-align-last`` and ``text-justify`` properties; and - the ``text-indent`` and ``hanging-punctuation`` properties. The other features provided by `CSS Text Module Level 4`_ are **not** supported: - the ``text-space-collapse`` and ``text-space-trim`` properties; - the ``text-wrap``, ``wrap-before``, ``wrap-after`` and ``wrap-inside`` properties; - the ``pre-wrap-auto`` value of the ``white-space`` property; and - the ``text-spacing`` property. .. _CSS Text Module Level 3: https://www.w3.org/TR/css-text-3/ .. _CSS Text Module Level 4: https://www.w3.org/TR/css-text-4/ .. _hyphenation: http://www.w3.org/TR/css3-text/#hyphenation CSS Fonts Module Level 3 ~~~~~~~~~~~~~~~~~~~~~~~~ The `CSS Fonts Module Level 3`_ is a candidate recommendation describing "how font properties are specified and how font resources are loaded dynamically". WeasyPrint supports the ``font-size``, ``font-stretch``, ``font-style`` and ``font-weight`` properties, coming from CSS 2.1. WeasyPrint also supports the following font features added in Level 3: - ``font-kerning``, - ``font-variant-ligatures``, - ``font-variant-position``, - ``font-variant-caps``, - ``font-variant-numeric``, - ``font-variant-east-asian``, - ``font-feature-settings``, and - ``font-language-override``. ``font-family`` is supported. The string is given to Pango that tries to find a matching font in a way different from what is defined in the recommendation, but that should not be a problem for common use. The shorthand ``font`` and ``font-variant`` properties are supported. WeasyPrint supports the ``@font-face`` rule on Linux and macOS, but does **not** support it on Windows. WeasyPrint does **not** support the ``@font-feature-values`` rule and the values of ``font-variant-alternates`` other than ``normal`` and ``historical-forms``. The ``font-variant-caps`` property is supported but needs the small-caps variant of the font to be installed. WeasyPrint does **not** simulate missing small-caps fonts. CSS Paged Media Module Level 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The `CSS Paged Media Module Level 3`_ is a working draft including features for paged media "describing how: - page breaks are created and avoided; - the page properties such as size, orientation, margins, border, and padding are specified; - headers and footers are established within the page margins; - content such as page counters are placed in the headers and footers; and - orphans and widows can be controlled." All the features of this draft are available, including: - the ``@page`` rule and the ``:left``, ``:right``, ``:first`` and ``:blank`` selectors; - the page margin boxes; - the page-based counters (with known bugs `#91`_, `#93`_, `#289`_); - the page ``size``, ``bleed`` and ``marks`` properties; - the named pages. .. _CSS Paged Media Module Level 3: http://dev.w3.org/csswg/css3-page/ .. _#91: https://github.com/Kozea/WeasyPrint/issues/91 .. _#93: https://github.com/Kozea/WeasyPrint/issues/93 .. _#289: https://github.com/Kozea/WeasyPrint/issues/289 CSS Generated Content for Paged Media Module ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The `CSS Generated Content for Paged Media Module`_ (GCPM) is a working draft defining "new properties and values, so that authors may bring new techniques (running headers and footers, footnotes, leaders, bookmarks) to paged media". Two features from this module have been implemented in WeasyPrint. The first feature is `PDF bookmarks`_. Using the experimental_ ``bookmark-level`` and ``bookmark-level`` properties, you can add bookmarks that will be available in your PDF reader. Bookmarks have already been added in the WeasyPrint's `user agent stylesheet`_, so your generated documents will automatically have bookmarks on headers (from ``

`` to ``

``). But for example, if you have only one top-level ``

`` and do not wish to include it in the bookmarks, add this in your stylesheet: .. code-block:: css h1 { bookmark-level: none } The second feature is `Named strings`_. You can define strings related to the first or last element of a type present on a page, and display these strings in page borders. This feature is really useful to add the title of the current chapter at the top of the pages of a book for example. The named strings can embed static strings, counters, tag contents and tag attributes. .. code-block:: css @top-center { content: string(chapter); } h2 { string-set: chapter "Current chapter: " content() } The other features of GCPM are **not** implemented: - running elements (``running()`` and ``element()``); - footnotes (``float: footnote``, ``footnote-display``, ``footnote`` counter, ``::footnote-call``, ``::footnote-marker``, ``@footnote`` rule, ``footnote-policy``); - page selectors and page groups (``:nth()`` pseudo-class); - leaders (``content: leader()``); - cross-references (``target-counter()``, ``target-counters()`` and ``target-text()``); - bookmark states (``bookmark-state``). .. _CSS Generated Content for Paged Media Module: http://www.w3.org/TR/css-gcpm-3/ .. _PDF bookmarks: http://www.w3.org/TR/css-gcpm-3/#bookmarks .. _Named strings: http://www.w3.org/TR/css-gcpm-3/#named-strings .. _experimental: http://www.w3.org/TR/css-2010/#experimental .. _user agent stylesheet: https://github.com/Kozea/WeasyPrint/blob/master/weasyprint/css/html5_ua.css CSS Color Module Level 3 ~~~~~~~~~~~~~~~~~~~~~~~~ The `CSS Color Module Level 3`_ is a recommandation defining "CSS properties which allow authors to specify the foreground color and opacity of an element". Its main goal is to specify how colors are defined, including color keywords and the ``#rgb``, ``#rrggbb``, ``rgb()``, ``rgba()``, ``hsl()``, ``hsla()`` syntaxes. Opacity and alpha compositing are also defined in this document. This recommandation is fully implemented in WeasyPrint, except the deprecated System Colors. .. _CSS Color Module Level 3: http://www.w3.org/TR/css3-color/ CSS Transforms Module Level 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The `CSS Transforms Module Level 1`_ working draft "describes a coordinate system within each element is positioned. This coordinate space can be modified with the transform property. Using transform, elements can be translated, rotated and scaled in two or three dimensional space." WeasyPrint supports the ``transform`` and ``transform-origin`` properties, and all the 2D transformations (``matrix``, ``rotate``, ``translate(X|Y)?``, ``scale(X|Y)?``, ``skew(X|Y)?``). WeasyPrint does **not** support the ``transform-style``, ``perspective``, ``perspective-origin`` and ``backface-visibility`` properties, and all the 3D transformations (``matrix3d``, ``rotate(3d|X|Y|Z)``, ``translate(3d|Z)``, ``scale(3d|Z)``). .. _CSS Transforms Module Level 1: http://dev.w3.org/csswg/css3-transforms/ CSS Backgrounds and Borders Module Level 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The `CSS Backgrounds and Borders Module Level 3`_ is a candidate recommandation defining properties dealing "with the decoration of the border area and with the background of the content, padding and border areas". The `border part`_ of this module is supported, as it is already included in the the CSS 2.1 specification. WeasyPrint supports the `background part`_ of this module (allowing multiple background layers per box), including the ``background``, ``background-color``, ``background-image``, ``background-repeat``, ``background-attachment``, ``background-position``, ``background-clip``, ``background-origin`` and ``background-size`` properties. WeasyPrint also supports the `rounded corners part`_ of this module, including the ``border-radius`` property. WeasyPrint does **not** support the `border images part`_ of this module, including the ``border-image``, ``border-image-source``, ``border-image-slice``, ``border-image-width``, ``border-image-outset`` and ``border-image-repeat`` properties. WeasyPrint does **not** support the `box shadow part`_ of this module, including the ``box-shadow`` property. This feature has been implemented in a `git branch`_ that is not released, as it relies on raster implementation of shadows. .. _CSS Backgrounds and Borders Level 3: http://www.w3.org/TR/css3-background/ .. _border part: http://www.w3.org/TR/css3-background/#borders .. _background part: http://www.w3.org/TR/css3-background/#backgrounds .. _rounded corners part: http://www.w3.org/TR/css3-background/#corners .. _border images part: http://www.w3.org/TR/css3-background/#border-images .. _box shadow part: http://www.w3.org/TR/css3-background/#misc .. _git branch: https://github.com/Kozea/WeasyPrint/pull/149 CSS Image Values and Replaced Content Module Level 3 / 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The `Image Values and Replaced Content Module Level 3`_ is a candidate recommandation introducing "additional ways of representing 2D images, for example as a list of URIs denoting fallbacks, or as a gradient", defining "several properties for manipulating raster images and for sizing or positioning replaced elements" and "generic sizing algorithm for replaced elements". The `Image Values and Replaced Content Module Level 4`_ is a working draft on the same subject. The ``linear-gradient()``, ``radial-gradient()`` and ``repeating-radial-gradient()`` properties are supported as background images. The the ``url()`` notation is supported, but the ``image()`` notation is **not** supported for background images. The ``from-image`` and ``snap`` values of the ``image-resolution`` property are **not** supported, but the ``resolution`` value is supported. The ``image-rendering`` property is supported. The ``image-orientation``, ``object-fit`` and ``object-position`` are **not** supported. .. _Image Values and Replaced Content Module Level 3: http://www.w3.org/TR/css3-images/ .. _Image Values and Replaced Content Module Level 4: http://www.w3.org/TR/css4-images/ CSS Basic User Interface Module Level 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The `CSS Basic User Interface Module Level 3`_ also known as CSS3 UI is a candidate recommandation describing "CSS properties which enable authors to style user interface related properties and values." Only one new property defined in this document is implemented in WeasyPrint: the ``box-sizing`` property. Some of the properties do not apply for WeasyPrint: ``cursor``, ``resize``, ``caret-color``, ``nav-(up|right|down|left)``. The other properties are **not** implemented: ``outline-offset`` and ``text-overflow``. .. _CSS Basic User Interface Module Level 3: http://www.w3.org/TR/css-ui-3/ CSS Values and Units Module Level 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The `CSS Values and Units Module Level 3`_ defines various units and keywords used in "value definition field of each CSS property". The ``initial`` and ``inherit`` CSS-wide keywords are supported, but the ``unset`` keyword is **not** supported. Quoted strings, URLs and numeric data types are supported. Font-related lengths (``em``, ``ex``, ``ch``, ``rem``), absolute lengths (``cm``, ``mm``, ``q``, ``in``, ``pt``, ``pc``, ``px``), angles (``rad``, ``grad``, ``turn``, ``deg``), resolutions (``dpi``, ``dpcm``, ``dppx``) are supported. The ``attr()`` functional notation is allowed in the ``content`` and ``string-set`` properties. Viewport-percentage lengths (``vw``, ``vh``, ``vmin``, ``vmax``) are **not** supported. .. _CSS Values and Units Module Level 3: https://www.w3.org/TR/css3-values/ CSS Multi-column Layout Module ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The `CSS Multi-column Layout Module`_ "describes multi-column layouts in CSS, a style sheet language for the web. Using functionality described in the specification, content can be flowed into multiple columns with a gap and a rule between them." Simple multi-column layouts are supported in WeasyPrint. Features such as constrained height, spanning columns or column breaks are **not** supported. Pagination and overflow are not seriously tested. The ``column-width`` and ``column-count`` properties, and the ``columns`` shorthand property are supported. The ``column-gap``, ``column-rule-color``, ``column-rule-style`` and ``column-rule-width`` properties, and the ``column-rule`` shorthand property are supported. The ``break-before``, ``break-after`` and ``break-inside`` properties are **not** supported. The ``column-span`` property is **not** supported. The ``column-fill`` property is supported, with a column balancing algorithm that should be efficient with simple cases. .. _CSS Multi-column Layout Module: https://www.w3.org/TR/css3-multicol/