weasyprint understands certain custom css directives, such as:
@bottom-right {
content: "Page " counter(page) " of " counter(pages) "
}
which places a "Page 1 of 4" style counter at the bottom right of each pdf page weasyprint generates.
I'd like to produce slightly fancier formatting for my footers - for example, I'd like to be able to show some portions in bold, and others as italic, like so:
Page 1 of 4
Is this feasible with weasyprint? If so, how do I instruct weasyprint to use this kind of formatting - I'll take CSS based solutions, though I'd much rather do this programmatically using the weasyprint library from python.
"Page 1 of 4" is not doable at the moment. If you’re interested, please send comments to [email protected] about what a new CSS feature could look like to do this kind of thing.
What works is:
@bottom-right
, with the content
property. You get up to 16 such boxes per page, but parts of one box can not be styled differently.position: fixed
are repeated on every page. With tricks like top: 100%; right: 0
you can position them like headers or footers, but they are identical on every page. counter(page)
doesn’t work there.By the way, I do not usually watch StackOverflow for WeasyPrint question. Writing to WeasyPrint’s mailing list or issue tracker will get more response.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With