Pad: pad.constantvzw.org/p/prado_workshop_weasyprint
Repository: gitlab.constantvzw.org/algolit/prado-weasyprint-workshop
Graphic design collective using only Free/Libre Open Source Software.
osp.kitchenA web browser!
Scripting language.
To see if it's installed: open a terminal and type:
python3 --version
Expected output, a number like: Python 3.6.9
If you don't have python installed it might be: Command not found
Download python: https://www.python.org/downloads/
Python library to convert HTML + CSS to a PDF
Install through the terminal:
pip3 install weasyprint
weasyprint http://weasyprint.org weasyprint-website.pdf
from weasyprint import HTML
HTML(filename=html_filename).write_pdf(output_pdf_filename)
@page {
/* width and height. In this case for an A5 */
size: 148.5mm 210mm;
/* OR */
/* size: A5 portrait; */
padding: 0;
marks: crop;
bleed: 5mm;
margin: 25mm;
/* Bigger bleed as weasyprint draws the cropmarks within the bleed*/
}
@page {
@bottom-center {
/**
On every page display the value of the page counter at the bottom center.
The page counter is a special counter created by weasyprint.
*/
content: counter(page);
}
}
@page:right {
/**
Use a pseudo-selector on the page to display page numbers on right pages
on the right.
*/
@bottom-right {
content: counter(page);
}
}
@page:left {
/**
Use a pseudo-selector on the page to display page numbers on left pages
on the left.
*/
@bottom-left {
content: counter(page);
}
}
@page:first {
/**
Selects the first page of the documents. Allows for example for hiding
the page numbers on the cover and / or different page margins there.
*/
}
@page:empty {
/**
According to the standards this selector should select empty pages.
In my experience it doesn't always work.
*/
}
h1 {
/**
When a header 1 is encoutered set the value of the string
running-header to the value of the header
*/
string-set: running-header content(text);
}
@page {
@bottom-center {
/**
On every page display the value of running-header at
that moment
*/
content: string(running-header);
}
}