Last active
April 18, 2017 10:36
-
-
Save ammaaim/c5d60d7c4411ff33913d to your computer and use it in GitHub Desktop.
Python3 HTML to PDF generator
This file contains 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
>>> INSTALL | |
pip3.4 install weasyprint | |
>>> EXAMPLE | |
from weasyprint import HTML, CSS | |
html_src=''' | |
<h1>The title</h1> | |
<p>Content goes here | |
''' | |
css_src='@page { size: A4; margin: 1cm }' | |
HTML(string=html_src).write_pdf('weasyprint-website.pdf', stylesheets=[CSS(string=css_src)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment