diff --git a/backend/open_webui/static/assets/pdf-style.css b/backend/open_webui/static/assets/pdf-style.css index db9ac83dd..85c36271c 100644 --- a/backend/open_webui/static/assets/pdf-style.css +++ b/backend/open_webui/static/assets/pdf-style.css @@ -26,7 +26,7 @@ html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'NotoSans', 'NotoSansJP', 'NotoSansKR', - 'NotoSansSC', 'STSong-Light', 'MSung-Light', 'HeiseiMin-W3', 'HYSMyeongJo-Medium', Roboto, + 'NotoSansSC', 'Twemoji', 'STSong-Light', 'MSung-Light', 'HeiseiMin-W3', 'HYSMyeongJo-Medium', Roboto, 'Helvetica Neue', Arial, sans-serif; font-size: 14px; /* Default font size */ line-height: 1.5; @@ -40,7 +40,7 @@ html { body { margin: 0; - color: #212529; + padding: 0; background-color: #fff; width: auto; } diff --git a/backend/open_webui/static/fonts/Twemoji.ttf b/backend/open_webui/static/fonts/Twemoji.ttf new file mode 100644 index 000000000..281d356d9 Binary files /dev/null and b/backend/open_webui/static/fonts/Twemoji.ttf differ diff --git a/backend/open_webui/utils/pdf_generator.py b/backend/open_webui/utils/pdf_generator.py index fb6cd57d5..6b7d506e6 100644 --- a/backend/open_webui/utils/pdf_generator.py +++ b/backend/open_webui/utils/pdf_generator.py @@ -51,21 +51,25 @@ class PDFGenerator: # extends pymdownx extension to convert markdown to html. # - https://facelessuser.github.io/pymdown-extensions/usage_notes/ - html_content = markdown(content, extensions=["pymdownx.extra"]) + # html_content = markdown(content, extensions=["pymdownx.extra"]) html_message = f""" -
{date_str}
-
+
-

+

{role.title()} - {model} -

+ {model} + +
{date_str}
-
+                
+
+ +
{content} -
+
+
""" return html_message @@ -74,18 +78,15 @@ class PDFGenerator: return f""" - - + -
-
-

{self.form_data.title}

-
-
- {self.messages_html} -
+
+
+

{self.form_data.title}

+ {self.messages_html}
+
""" @@ -114,9 +115,12 @@ class PDFGenerator: pdf.add_font("NotoSansKR", "", f"{FONTS_DIR}/NotoSansKR-Regular.ttf") pdf.add_font("NotoSansJP", "", f"{FONTS_DIR}/NotoSansJP-Regular.ttf") pdf.add_font("NotoSansSC", "", f"{FONTS_DIR}/NotoSansSC-Regular.ttf") + pdf.add_font("Twemoji", "", f"{FONTS_DIR}/Twemoji.ttf") pdf.set_font("NotoSans", size=12) - pdf.set_fallback_fonts(["NotoSansKR", "NotoSansJP", "NotoSansSC"]) + pdf.set_fallback_fonts( + ["NotoSansKR", "NotoSansJP", "NotoSansSC", "Twemoji"] + ) pdf.set_auto_page_break(auto=True, margin=15)