Last active
September 16, 2021 16:44
-
-
Save opalczynski/99ff2dfca7498994c057853c6a6a87e4 to your computer and use it in GitHub Desktop.
CSS adding to weasyprint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def render_pdf(): | |
| template = get_template() | |
| rendered = template.render(**{"name": "John"}) | |
| html = weasyprint.HTML(string=rendered, base_url="/") | |
| css = weasyprint.CSS(filename="./template.css") | |
| with open("output/test.pdf", "wb") as f: | |
| html.write_pdf(f, stylesheets=[css]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment