Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save documentprocessing/f243e74a3d92019f8fe97dfc608e9410 to your computer and use it in GitHub Desktop.
Save documentprocessing/f243e74a3d92019f8fe97dfc608e9410 to your computer and use it in GitHub Desktop.
Convert HTML to PDF via Web URL and also with Inline CSS in Python using WeasyPrint Library. Check https://products.documentprocessing.com/conversion/python/weasyprint/ for more details.
// Import the HTML class from the WeasyPrint library
from weasyprint import HTML
// Instantiate HTML class and call write_pdf() method to convert Website URL to PDF
HTML('https://www.groupdocs.com/').write_pdf('groupdocs-weasyprint.pdf')
// Import the HTML class from the WeasyPrint library
from weasyprint import HTML
// Instantiate HTML class. Call write_pdf() method to convert Website URL to PDF with Inline Stylesheet
HTML('https://www.groupdocs.com/').write_pdf('groupdocs-weasyprint.pdf',
stylesheets=[CSS(string='body { font-family: serif !important }')])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment