Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: wrap long unbroken text in PDF chat exports (#17425)

Nilayea2d2a0153ff
diff --git a/studio/backend/core/chat_pdf.py b/studio/backend/core/chat_pdf.py
index 729af7f97c3..adc058bf1c4 100644
--- a/studio/backend/core/chat_pdf.py
+++ b/studio/backend/core/chat_pdf.py
@@ -16,7 +16,7 @@ _PAGE_MARGIN_PT = 54
# MuPDF's HTML engine takes a CSS subset; unknown families fall back to its bundled Noto/Droid fonts.
_PDF_CSS = """
-body { font-family: sans-serif; font-size: 10.5pt; line-height: 1.45; color: #1f2328; }
+body { font-family: sans-serif; font-size: 10.5pt; line-height: 1.45; color: #1f2328; overflow-wrap: break-word; }
h1 { font-size: 17pt; margin: 0 0 4pt 0; }
.meta { color: #6e7781; font-size: 8.5pt; margin: 0 0 14pt 0; }
.conversation-title { font-size: 13.5pt; margin: 16pt 0 8pt 0; }
diff --git a/studio/backend/tests/test_chat_export_pdf.py b/studio/backend/tests/test_chat_export_pdf.py
index be4f54d5766..7e59ea17653 100644
--- a/studio/backend/tests/test_chat_export_pdf.py
+++ b/studio/backend/tests/test_chat_export_pdf.py
@@ -54,6 +54,19 @@ def test_long_chats_span_pages():
assert "line 399" in _text(response.content)
+ "run",
+ ["ภาษาไทยไม่เว้นวรรคระหว่างคำ" * 6, "a" * 200],
+ ids = ["thai", "long-token"],
+)
[email protected]("template", ["<p>{}</p>", "<pre><code>{}</code></pre>"], ids = ["p", "pre"])
+def test_text_without_break_points_wraps_inside_the_page(run, template):
+ body = template.format(f"{run}TAILMARK")
+ response = _client().post("/api/chat-export/pdf", json = {"title": "x", "html": body})
+ assert response.status_code == 200
+ assert "TAILMARK" in _text(response.content).replace("\n", "")
+
+
def test_only_data_images_embed(tmp_path):
png = io.BytesIO()
pixmap = pymupdf.Pixmap(pymupdf.csRGB, pymupdf.IRect(0, 0, 4, 4), False)