- Home
- Skills
- Writing & Content
- Thai DOCX Fixer: Thai That Renders Right in Word
Thai DOCX Fixer: Thai That Renders Right in Word
Stop broken Thai in generated Word files: wrong font, tiny text, thin bold and floating tone marks, fixed with one call before save, plus a scanner that proves it.
Free
Works with the AI Agents you already use
Thai DOCX Fixer: Thai That Renders Right in Word
Example session with this skill installed
Write a one-page Thai service agreement as a .docx with python-docx: a bold title, 16pt TH Sarabun New body, and a two-column table for the parties. It will be opened in Microsoft Word by the client, so make sure the Thai renders correctly there.
- Read your context and instructions
- Compiled the thai docx fixer
Summary
Built service_agreement.docx, patched the Thai complex-script slots with enforce_thai(doc), and ran the scanner: 6 of 6 Thai runs pass. Before the patch the same file failed on all 6.
Code
from docx import Document
from docx.shared import Pt
from enforce_thai import enforce_thai, add_word_breaks
doc = Document()
doc.add_heading("สัญญาจ้างบริการ", level=1)
p = doc.add_paragraph()
p.add_run("Agreement No. 12 ")
title = p.add_run("ฉบับนี้ทำขึ้นเมื่อวันที่ 1 มกราคม 2569")
title.bold = True
body = doc.add_paragraph().add_run("ผู้ว่าจ้างและผู้รับจ้างตกลงกันดังต่อไปนี้")
body.font.size = Pt(16)
table = doc.add_table(rows=1, cols=2)
table.rows[0].cells[0].text = "ผู้ว่าจ้าง"
table.rows[0].cells[1].text = "ผู้รับจ้าง"
doc.sections[0].header.paragraphs[0].text = "หน้า 1"
add_word_breaks(doc) # word-boundary hints for justified Thai
enforce_thai(doc) # one call, right before save
doc.save("service_agreement.docx")
Scanner before the patch
python verify_thai_docx.py service_agreement.docx
| Location | Thai run | Problem |
|---|---|---|
| body para 0 | สัญญาจ้างบริการ | no rPr: font, size and bold all unset |
| body para 1 run 1 | ฉบับนี้ทำขึ้น... | w:cs missing, w:bCs missing: Thai not bold |
| body para 2 | ผู้ว่าจ้าง... | w:szCs missing: Thai smaller than the 16pt Latin |
| table r0 c0, r0 c1 | ผู้ว่าจ้าง / ผู้รับจ้าง | no rPr |
| header | หน้า 1 | no rPr |
✗ FAIL — 6/6 Thai run(s) have issues.
Scanner after the patch
✓ PASS — 6 Thai run(s) checked, all OK. File is ready to send.
Opened in Microsoft Word: every Thai run reports TH Sarabun New, 16pt where a size was set, bold where set. <w:rPr> children are in schema order, so Word shows no repair prompt.
Next steps
- Replace the placeholder clauses with the reviewed contract text.
- If the text came from a PDF, pass it through
clean_pdf_thai()first. - Re-run the scanner after every edit that regenerates the file.
Connects securely to your tools. The creator never sees your data.
About this skill
python-docx writes only the Latin font slot. Microsoft Word draws Thai from the complex-script slot, so a Thai .docx that looks fine in a preview opens on a client's Word with the wrong font, Thai text smaller than the English next to it, bold and italic missing on the Thai part, and tone marks floating off their consonants.
This skill teaches your agent to fix that every time it writes a Thai Word file:
enforce_thai(doc)— one call beforedoc.save(). Fillsw:cs,w:szCs,w:bCs,w:iCsandw:langon every run, style, table cell, header and footer, in the child order the OOXML schema requires.verify_thai_docx.py— a CLI scanner that fails the build when any Thai run is still missing a slot (exit 1), so the agent checks instead of guessing.add_word_breaks(doc)— optional zero-width break hints so justified Thai paragraphs wrap at word boundaries (uses pythainlp).clean_pdf_thai(text)— repairs Thai pasted from PDFs: injected spaces, zero-width characters, NFD tone marks, split sara am.selftest.py— proves the whole thing works on the buyer's machine in one command.
Defaults follow the Thai government document standard (TH Sarabun New, 16pt); font and size are parameters.
Requires: Python 3.9+, python-docx. Optional: pythainlp. Tested: output opened in Microsoft Word on Windows; Word reports TH Sarabun New, correct size, bold and italic on the Thai runs.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Writing & Content.
Requires python-docx; the word-break helper also needs pythainlp. Patches paragraphs in the body, top-level tables, headers and footers. Text inside nested tables, text boxes, footnotes and hyperlinks is not patched yet. Preview tools (LibreOffice, Word Online) hide the bug, so check with the scanner, not by eye.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 18 days ago
- Free with an Agensi account
- Software
Python 3.9+python-docx
- Optional
- pythainlp
Permissions
File Scopes
Runs Python scripts in the terminal, reads the .docx you generate, and writes the patched .docx back. No network access, no accounts.