]> git.parisson.com Git - teleforma.git/commitdiff
Reimplement xhtml2pdf instead of weasyprint (not tested yet)
authorYoan Le Clanche <yoanl@pilotsystems.net>
Tue, 4 Jan 2022 15:52:24 +0000 (16:52 +0100)
committerYoan Le Clanche <yoanl@pilotsystems.net>
Tue, 4 Jan 2022 15:52:24 +0000 (16:52 +0100)
teleforma/views/pro.py

index a283dcbf77448b205fc97217326106a76d8c45a4..50f77c34dc506e20a7e1e009f8fe23afe9980e5c 100644 (file)
@@ -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):
     """