I found this guide for rst2pdf to find out how to style a reStructuredText file in the resulting pdf document. Having the following in my JSON stylesheet, for example, it is successfully applied to the whole document:
"pageSetup" : {
"size": "A4",
"width": null,
"height": null,
"margin-top": "2cm",
[...]
"margin-gutter": "0cm"
}
How is a particular style applied only to a specific class? For example, how can I apply a particular font the to the h1
class? My immediate difficulty stems from the fact that I'm unsure about whether it's actually called h1
, H1
, header1
, or Header1
.
The rst2pdf.py
manual does not seem very informative with regards to the style names. However, the section on Styles (chapter 8) has this example:
["heading1" , {
"parent": "normal",
"fontName": "Tuffy_Bold",
"fontSize": 18,
"keepWithNext": true,
"spaceAfter": 6
}],
So it seems that heading1
is the appropriate style name.
One thing to note is that
If your document requires a style that is not defined in your stylesheet, it will print a warning and use bodytext instead.
So presuming that you don't get any warnings when generating your document the styles must be set in the default stylesheet, so have a look through this to get a feel for the style names used.
You can make rst2pdf print the default stylesheet using
rst2pdf --print-stylesheet
If you want to add styles, just create a stylesheet, (or take the standard stylesheet and modify it) and pass it with the -s option
rst2pdf mydoc.txt -s mystyles.txt
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