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
1 changed files with 5 additions and 2 deletions

View File

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