CSS Print: Difference between revisions

From XPUB & Lens-Based wiki
 
(53 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__TOC__


==Web-to-print tools==


Experimental, fragile, in progress but also more stable tools.
<div style="font-weight:bold;font-size:200%;">Printing a Book with CSS: Boom! (as in: TADA!)</div>
<div style="font-weight:bold;font-size:200%;">Printing a Book with CSS: Boom! (as in: OH NO...)</div>
<div style="font-weight:bold;font-size:200%;">Printing a Book with CSS: Boom! (as in: EH? WOW!)</div>


===More widely used===
==CSS==
 
Cascading Style Sheets
 
<syntaxhighlight lang="css">
body{
    background-color: pink;
    color: green;
    margin: 100px;
}
</syntaxhighlight>
 
===CSS1, CSS2, CSS2.1, CSS3===
 
[[File:Screenshot from 2023-10-03 15-11-04.png|600px]]
 
<small>Screenshot of one of the slides from Julie Blanc and Julien Taquet, as part of their presentation during the Paged.js workshop in October 2022. http://slides.julie-blanc.fr/20221013_xpub-rotterdam.html#/19</small>
 
Since CSS3, the CSS standard is cut up into modules that each describe a specific part of the CSS standard. It was a way to work on specific features in parallel.
 
A full list of all the CSS3 modules and their status: https://www.w3.org/Style/CSS/current-work
 
==CSS Print==
 
CSS Print extends the CSS standard with print features!
 
These features are formulated in these modules:
 
* CSS Paged Media ([https://www.w3.org/TR/css-page-3/ official w3c draft], [https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Paged_media mdn docs])
* CSS Generated Content for Paged Media module ([https://www.w3.org/TR/css-gcpm-3/ official w3c draft])
* CSS Fragmentation ([https://www.w3.org/TR/css-break-3/ official w3c draft], [https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Fragmentation mdn docs])
 
===CSS Paged Media Module ===
 
<blockquote>
Paged media have many special requirements for the display of document content, which have evolved over the long history of printed books. Running headers and footers function as aids to navigation. Notes may appear at the bottom of the page, as footnotes. The properties of pages themselves may change based on their content or position in the document. Leaders visually connect related content. Cross-references may require generated text. Some paged media formats such as PDF use bookmarks for navigation.
 
This module defines new properties and values, so that authors may bring these techniques to paged media.
</blockquote>
 
===CSS Print Community Group===
 
For a couple of years (2020-2023), a group of people formed a W3C community group to provide feedback to the CSS Print specs. Unfortunately this group is closed since Dec 2023.
 
This was their web page and blog: https://www.w3.org/community/cssprint/
 
===Working with a NOT YET standard===
 
====Modern browsers (partial CSS Print support)====
 
A few of the CSS Print properties are supported by modern (aka up-to-date) browsers, but not many unfortunately, as the W3C CSS Paged Media module is still in a "working draft" mode.
 
You can check if a CSS property is supported by a specific browser at: https://caniuse.com/
 
It's good to say that you can still get pretty far with the properties that are supported atm. It really depends on what you want to make in the end.
 
====Paged.js and Weasyprint (already support CSS Print!)====
 
If you nevertheless do want to use these properties, you can use '''Paged.js''', a Javascript library also known as a ''polyfill'', that aims to ''fill'' the gaps between the working draft document and modern browsers. The project comes with extended documentation: https://pagedjs.org/documentation/.
 
Or you can use '''Weasyprint''', who also supports most of the CSS Paged Media properties described on this page. In the  Weasyprint documentation [https://doc.courtbouillon.org/weasyprint/stable/api_reference.html#css-paged-media-module-level-3 here] you can read which properties are supported and which ones not.
 
==CSS Print examples==
 
An important proposal of the CSS Print drafts is to add a @page selector, that you can use to style a web page when it is rendered into pages.
 
<syntaxhighlight lang="css">
@page{
    size: A4 portrait;
    margin: 20mm 30mm;
    bleed: 3mm;
    marks: crop;
}
</syntaxhighlight>
 
More examples of CSS Print selectors and properties can be found here: [[CSS Print examples]]
 
==CSS Print documentation==
 
As the state of CSS Print features is so much in flux, it can be hard to find documentation that gives you an overview of all the different pieces you want to use.
 
It '''really depends''' on which tool you use to produce a PDF:
 
* '''Paged.js''': https://pagedjs.org/documentation/ - official project documentation
* '''Weasyprint''': https://doc.courtbouillon.org/weasyprint/stable/api_reference.html#css - list of supported CSS properties in Weasyprint
* '''browser''': check caniuse.com
 
For an '''overview of the two CSS Print modules''' in their latest w3c draft version:
 
* paged media: https://www.w3.org/TR/css-page-3/
* generated content for paged media: https://www.w3.org/TR/css-gcpm-3/
 
Media queries: @media print, @media screen
 
* https://developer.mozilla.org/en-US/docs/Web/CSS/@media
* https://developer.mozilla.org/en-US/docs/Web/Guide/Printing
 
Kiara's great listing of css-print links:
 
* https://pzwiki.wdka.nl/mediadesign/User:Kiara/Code#CSS-print
 
==CSS Print tools==
 
===Layout engines for CSS Print===


* your browser (based on [[Paged_Media_CSS_examples|CSS Paged Media]]): use CTRL+P/CMD+P
* your browser (based on [[Paged_Media_CSS_examples|CSS Paged Media]]): use CTRL+P/CMD+P
* [[Weasyprint]] https://weasyprint.readthedocs.io/
* [[Weasyprint]] <!--https://weasyprint.readthedocs.io/ not there anymore?--> https://doc.courtbouillon.org/weasyprint/stable/
* [[Paged.js]] https://www.pagedjs.org/
* [[Paged.js]] https://www.pagedjs.org/
* wkhtmltopdf https://wkhtmltopdf.org/
* wkhtmltopdf https://wkhtmltopdf.org/
* Vivliostyle https://vivliostyle.org/
* OSPKit (CSS Regions legacy support!) http://osp.kitchen/tools/ospkit/


===More experimental===
===Custom workflows made with CSS Print===


* OSPKit (CSS Regions legacy support!) http://osp.kitchen/tools/ospkit/
* html2print http://osp.kitchen/tools/html2print/
* html2print http://osp.kitchen/tools/html2print/
* Etherpash https://github.com/chchchchchchch/var.lgm.etherpash
* etherpash https://github.com/chchchchchchch/var.lgm.etherpash
* 8m-posters (8 March poster generator made by Julien Bidoret) https://prepostprint.org/8m-posters/
* 8m-posters (8 March poster generator made by Julien Bidoret) https://prepostprint.org/8m-posters/
* PageTypeToPrint https://ateliers.esad-pyrenees.fr/pagetypetoprint/
* PageTypeToPrint https://ateliers.esad-pyrenees.fr/pagetypetoprint/
Line 23: Line 129:
* ethertoff http://osp.kitchen/tools/ethertoff/
* ethertoff http://osp.kitchen/tools/ethertoff/


==Examples, boilerplates==
==Books and publications made with CSS Print workflows==
* https://gitlab.com/prepostprint/demos
* [https://books.constantvzw.org/home/diversions-v2 DiVersions] (MediaWiki, [[Paged.js]])
* http://blog.osp.kitchen/residency/a-practice-of-boilerplates.html
* [https://books.constantvzw.org/home/RDI Reclaiming Digital Infrastructures] (pads, [[Paged.js]])
* [https://books.constantvzw.org/home/machine_research Machine Research] (pads?, [https://sarahgarcin.com/projets/pj-machine PJ Machine])
* [https://books.constantvzw.org/home/mondotheque Mondoteque] (MediaWiki, [[Weasyprint]])
* [https://books.constantvzw.org/home/tgso The Techno-Galactic Guide to Software Observation] (pads, [https://freeze.sh/_/2015/conversations/#mdsh mdsh?])
* [http://www.data-browser.net/db08.html Volumetric Regimes] (MediaWiki, [[Paged.js]])
* [https://www.algolit.net/index.php?title=Data_Workers_Publication Data Workers] (MediaWiki, [https://git.vvvvvvaria.org/mb/asciiWriter asciiWriter])
* ...


==Readings==
==Examples, boilerplates, resources==
* https://phd.julie-blanc.fr/ (published in 2023)
* https://yanntrividic.fr/assets/files/sujet_these.html (PhD in progress)
 
==Lists, archives, resources==
* https://constantvzw.org/wefts/webpublications.en.html
* https://constantvzw.org/wefts/webpublications.en.html
* http://web.2print.org/
* http://web.2print.org/
* https://books.constantvzw.org/
* https://gitlab.com/prepostprint/demos
* https://prepostprint.org/resources/
* https://prepostprint.org/resources/
* https://ateliers.esad-pyrenees.fr/web/pages/exemples/#webtoprint
* https://ateliers.esad-pyrenees.fr/web/pages/exemples/#webtoprint


==Events==
==Readings==
* [https://alistapart.com/article/boom/ Printing a Book with CSS: Boom!] by Håkon Wium Lie, Bert Bos (2005)
* [https://www.smashingmagazine.com/2015/01/designing-for-print-with-css/ Designing For Print With CSS] by Rachel Andrew (2015)
* https://phd.julie-blanc.fr/ (PhD published in 2023)
* https://yanntrividic.fr/assets/files/sujet_these.html (PhD in progress)


Summer schools, workshops, conferences, worksessions, seminars
==Online channels==


* [http://relearn.be/2013/ Relearn 2013, hosted by OSP/Constant]
* [https://www.w3.org/community/cssprint/ W3C CSS Print Community Group] (launched in 2020, closed in December 2023)
* [https://constantvzw.org/site/-Promiscuous-pipelines-.html Promiscuous Pipelines, hosted by Constant (2013)]
* [https://matrix.to/#/#prepostprint-public:matrix.org PrePostPrint Matrix space]
* [https://varia.zone/publishing-partyline.html Publishing Partyline, hosted by Varia (2022)]
* [https://libregraphicsmeeting.org/ Libre Graphics Meetings] (multiple editions)
* [https://core.servus.at/en/projekt/2021/servus-dsign-week Servus Dsign Week, hosted by Servus (2021 + 2023)]
* [https://raphaelbastide.com/workshops/a-party-to-print/ Seminar at HfG Karlsruhe with Raphaël Bastide and Sarah Garcin (June 2023)]
* [https://prepostprint.org/ppprototype/2022/ PPPrototype 2 (2022)]
* [https://prepostprint.org/gaitelyrique/#gaite PrePostPrint @ La Gaîté Lyrique (2017)]


==Online channels==
==See also==


* [https://matrix.to/#/#prepostprint-public:matrix.org PrePostPrint Matrix space]
* [[CSS Print examples]]
* [https://lists.domainepublic.net/cgi-bin/mailman/listinfo/prepostprint PrePostPrint mailinglist]
* [[Free, Libre, and Open Source Software publishing practices]]
* [[PDF]]
* [[HTML + CSS]]
* [[Typesetting Tools]]


[[Category:PagedMedia]]
[[Category:PagedMedia]]
[[Category:Cookbook]]
[[Category:Cookbook]]
[[Category:FLOSS design]]
[[Category:Workbooks]]

Latest revision as of 22:26, 10 November 2025


Printing a Book with CSS: Boom! (as in: TADA!)
Printing a Book with CSS: Boom! (as in: OH NO...)
Printing a Book with CSS: Boom! (as in: EH? WOW!)

CSS

Cascading Style Sheets

body{
    background-color: pink;
    color: green;
    margin: 100px;
}

CSS1, CSS2, CSS2.1, CSS3

Screenshot from 2023-10-03 15-11-04.png

Screenshot of one of the slides from Julie Blanc and Julien Taquet, as part of their presentation during the Paged.js workshop in October 2022. http://slides.julie-blanc.fr/20221013_xpub-rotterdam.html#/19

Since CSS3, the CSS standard is cut up into modules that each describe a specific part of the CSS standard. It was a way to work on specific features in parallel.

A full list of all the CSS3 modules and their status: https://www.w3.org/Style/CSS/current-work

CSS Print

CSS Print extends the CSS standard with print features!

These features are formulated in these modules:

CSS Paged Media Module

Paged media have many special requirements for the display of document content, which have evolved over the long history of printed books. Running headers and footers function as aids to navigation. Notes may appear at the bottom of the page, as footnotes. The properties of pages themselves may change based on their content or position in the document. Leaders visually connect related content. Cross-references may require generated text. Some paged media formats such as PDF use bookmarks for navigation.

This module defines new properties and values, so that authors may bring these techniques to paged media.

CSS Print Community Group

For a couple of years (2020-2023), a group of people formed a W3C community group to provide feedback to the CSS Print specs. Unfortunately this group is closed since Dec 2023.

This was their web page and blog: https://www.w3.org/community/cssprint/

Working with a NOT YET standard

Modern browsers (partial CSS Print support)

A few of the CSS Print properties are supported by modern (aka up-to-date) browsers, but not many unfortunately, as the W3C CSS Paged Media module is still in a "working draft" mode.

You can check if a CSS property is supported by a specific browser at: https://caniuse.com/

It's good to say that you can still get pretty far with the properties that are supported atm. It really depends on what you want to make in the end.

Paged.js and Weasyprint (already support CSS Print!)

If you nevertheless do want to use these properties, you can use Paged.js, a Javascript library also known as a polyfill, that aims to fill the gaps between the working draft document and modern browsers. The project comes with extended documentation: https://pagedjs.org/documentation/.

Or you can use Weasyprint, who also supports most of the CSS Paged Media properties described on this page. In the Weasyprint documentation here you can read which properties are supported and which ones not.

CSS Print examples

An important proposal of the CSS Print drafts is to add a @page selector, that you can use to style a web page when it is rendered into pages.

@page{
    size: A4 portrait;
    margin: 20mm 30mm;
    bleed: 3mm;
    marks: crop;
}

More examples of CSS Print selectors and properties can be found here: CSS Print examples

CSS Print documentation

As the state of CSS Print features is so much in flux, it can be hard to find documentation that gives you an overview of all the different pieces you want to use.

It really depends on which tool you use to produce a PDF:

For an overview of the two CSS Print modules in their latest w3c draft version:

Media queries: @media print, @media screen

Kiara's great listing of css-print links:

CSS Print tools

Layout engines for CSS Print

Custom workflows made with CSS Print

Books and publications made with CSS Print workflows

Examples, boilerplates, resources

Readings

Online channels

See also