Allow building the PDF whatever the underlying Weasyprint version is (for futur updates)

This commit is contained in:
MrHeadwar 2022-11-03 08:25:37 +01:00 committed by Alexandre Prokoudine
parent b3358ebceb
commit 45b92cddd7

View File

@ -718,8 +718,11 @@ if pdf:
pdfpageFile.close() pdfpageFile.close()
# Generating the actual PDF with weasyprint (https://weasyprint.org/) # Generating the actual PDF with weasyprint (https://weasyprint.org/)
from weasyprint import HTML from weasyprint import HTML, __version__
if float(__version__) < 53.0: # handle an API change
from weasyprint.fonts import FontConfiguration from weasyprint.fonts import FontConfiguration
else:
from weasyprint.text.fonts import FontConfiguration
html_font_config = FontConfiguration() html_font_config = FontConfiguration()
doc = HTML(string = pdfpage, base_url = global_site_dir) doc = HTML(string = pdfpage, base_url = global_site_dir)