From: Yoan Le Clanche Date: Tue, 4 Jan 2022 15:52:24 +0000 (+0100) Subject: Reimplement xhtml2pdf instead of weasyprint (not tested yet) X-Git-Tag: 2.8.1-pro~119^2~4 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=08b72a8224c57360aa5e1bd894d2a3f6bdbe6ef5;p=teleforma.git Reimplement xhtml2pdf instead of weasyprint (not tested yet) --- diff --git a/teleforma/views/pro.py b/teleforma/views/pro.py index a283dcbf..50f77c34 100644 --- a/teleforma/views/pro.py +++ b/teleforma/views/pro.py @@ -77,11 +77,11 @@ def content_to_pdf(content, dest, encoding='utf-8', **kwargs): Write into *dest* file object the given html *content*. Return True if the operation completed successfully. """ - print("Write PDF 2") + from xhtml2pdf import pisa src = StringIO(content.encode(encoding)) - src = weasyprint.HTML(string=content.encode(encoding), encoding=encoding) - dest.write_pdf(result) - return True + pdf = pisa.pisaDocument(src, dest, encoding=encoding, **kwargs) + return not pdf.err + def content_to_response(content, filename=None): """