From 5839c6857b8dc6bd6e9b0aecad95ac42fd8acea6 Mon Sep 17 00:00:00 2001 From: Marco Westerhof Date: Wed, 29 Apr 2026 10:06:36 +0200 Subject: [PATCH] fix issue when trying to render pdf from in-memory data directly --- pyhtml2pdf/converter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyhtml2pdf/converter.py b/pyhtml2pdf/converter.py index 66a0841..1565361 100644 --- a/pyhtml2pdf/converter.py +++ b/pyhtml2pdf/converter.py @@ -117,7 +117,7 @@ def __get_pdf_from_html( if isinstance(source, io.BytesIO): encoded_content = base64.b64encode(source.getvalue()).decode("utf-8") path = f"data:text/html;base64,{encoded_content}" - if not source.startswith("http") and not source.startswith("file"): + elif not source.startswith("http") and not source.startswith("file"): encoded_content = base64.b64encode(source.encode("utf-8")).decode("utf-8") path = f"data:text/html;base64,{encoded_content}" else: