From 08b72a8224c57360aa5e1bd894d2a3f6bdbe6ef5 Mon Sep 17 00:00:00 2001 From: Yoan Le Clanche Date: Tue, 4 Jan 2022 16:52:24 +0100 Subject: [PATCH] Reimplement xhtml2pdf instead of weasyprint (not tested yet) --- teleforma/views/pro.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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): """ -- 2.39.5