| name | thai-pdf-booklet |
| description | Translate documents into Thai and render them as polished, print-ready Thai PDFs — single files or a combined booklet with a premium full-bleed cover, a matching back cover, a per-page credit footer, and page numbers. Ships TWO interchangeable variants — a portable Node CLI (default; bundled Chromium via puppeteer + embedded Noto Sans Thai, runs on macOS/Linux/Windows with no system deps) and a lightweight native variant in native/ (system Chrome via puppeteer-core + pandoc + poppler + system fonts). Use when the user wants to "แปล PDF/เอกสารเป็นไทยแล้วทำเป็นเล่ม/PDF", "ทำ PDF ภาษาไทยสวย ๆ", "รวมหลายเอกสารเป็นเล่มเดียวมีปก/ปกหลัง/เลขหน้า", make a Thai cheat-sheet / quiz / handout PDF, or render Thai Markdown into a designed PDF. Do NOT use for an mdBook website+PDF (use publishing-mdbook-pdf) or English-only output. |
| license | Apache-2.0 |
| compatibility | Any OS (macOS / Linux / Windows). Only needs Node.js >= 18. `npm install` pulls puppeteer (which downloads a known-good Chromium); the Thai font and PDF stitching are bundled (Noto Sans Thai + pdf-lib), so there are no system-package or system-font dependencies. |
| metadata | {"author":"supachai-j","version":"2.0","repo":"https://github.com/supachai-j/thai-pdf-booklet"} |
Thai PDF Booklet — translate + render beautiful Thai PDFs (cross-platform)
A standalone Node CLI that turns Markdown (often translated from English source PDFs) into
print-quality Thai PDFs: each document on its own, or all of them bound into one booklet with
a designed cover, a matching back cover, a credit line + page number on every content page.
v2 is OS-independent. It replaces the old macOS-only pipeline (system Chrome path, system Thai
fonts, pandoc, poppler) with pure npm dependencies:
| Concern | How v2 handles it (any OS) |
|---|
| Browser | puppeteer downloads its own Chromium — no system Chrome, no hardcoded paths |
| Thai font | Noto Sans Thai (OFL) bundled in assets/fonts/ and embedded — no system fonts |
| Markdown → HTML | markdown-it (npm) — no pandoc |
| Cover stitching | pdf-lib (npm) — no poppler |
Two variants — pick one
Both produce the same designed output (cover, back cover, per-page Thai credit, page numbers).
| Portable (repo root) | Native (native/) |
|---|
| OS | macOS / Linux / Windows | macOS / Linux |
| Browser | bundled Chromium (puppeteer) | system Chrome (puppeteer-core) |
| Thai font | embedded Noto Sans Thai | system font (Sukhumvit/Thonburi; Linux: fonts-thai-tlwg) |
| MD→HTML / stitch | markdown-it / pdf-lib | pandoc / poppler |
| Install | npm install (downloads Chromium) | npm install + brew install pandoc poppler + Chrome |
| Configure | book.config.json (no code edits) | edit cover.html / build-book.sh |
| Run | node cli.js book <dir> | cd native && ./build-book.sh |
| Best when | zero system setup / any OS / Windows | you already have the tools and want a small footprint (no Chromium download) |
Default to Portable. Choose Native only on macOS/Linux when Chrome + pandoc + poppler are already
present and avoiding the Chromium download matters. The native variant has its own native/README.md.
Setup
cd ~/.claude/skills/thai-pdf-booklet && npm install
mkdir -p ~/work/my-pdfs/src && cd ~/work/my-pdfs
Run it with node ~/.claude/skills/thai-pdf-booklet/cli.js <cmd> <dir> (or npm link to get a
global thai-pdf-booklet command).
Workflow
1. Translate source → Thai Markdown (<project>/src/<base>.md)
If translating from English PDFs, Read each PDF (the Read tool renders PDF pages) and write
natural professional Thai Markdown. For many docs, fan out one subagent per doc. Conventions:
- Keep in English: tickers/company names, ratio/metric abbreviations (OCF, FCF, P/E, EBITDA…),
standard names (IAS 7, ASC 230), code. Translate prose; keep every number and
$ figure.
- Cheat sheets → Markdown pipe tables; green/red columns → headers
🟢 จุดแข็ง / 🔴 จุดอ่อน.
- Quizzes →
**ข้อ N.** … + a)…d), then ## เฉลย, then ## ประเด็นสำคัญ.
- Callouts (optional, styled):
<div class="callout tip|warn|example|key"><span class="callout-title">…</span> …</div>.
- First line of each file = its title:
# English Title — คำบรรยายไทย.
2. Render individual PDFs
node cli.js render <project>
node cli.js render <project> --credit "เรียบเรียง: … · แปลโดย …"
3. Combine into a booklet
Add <project>/book.config.json (schema below), then:
node cli.js book <project>
book.config.json
{
"output": "my-booklet.pdf",
"title": "ชื่อเล่ม\nบรรทัดสอง", "subtitle": "คำโปรย\nบรรทัดสอง",
"eyebrow": "หมวด · ฉบับแปลไทย", "meta": "ฉบับพิมพ์ครั้งแรก · 2026",
"coverCredit": "เรียบเรียง: ชื่อ\nแปลโดย Claude Code (AI)",
"credit": "เครดิตท้ายทุกหน้า", "tocTitle": "สารบัญ",
"backQuote": "\"คำคมปิดเล่ม\"", "backQuoteSub": "English subtitle",
"backThanks": "ขอบคุณที่อ่านจนจบ", "backMeta": "ชื่อเล่ม · 2026",
"colors": { "base1": "#18715c",
\n in any string becomes a line break. docs are src/<base>.md names, in order. The TOC is
auto-built from each file's # H1. See examples/ for a runnable sample (node cli.js book examples).
Gotchas (each cost real debugging)
- Inlining a big base64 font hangs
page.setContent — a ~290 KB data-URI font in the page
<style> blew the navigation timeout. Fix: write the HTML to a temp file and page.goto(file://),
loading the font from a file:// URL (use url.pathToFileURL for Windows paths). Fast and OS-safe.
- Chrome header/footer templates can't load
file:// resources — so the page uses the file://
font, but the footer template embeds the font as a base64 data URI (small, isolated). That
is how the Thai credit ("หน้า …") renders in the footer with no system font.
- Full-bleed covers + numbered body + back cover = render three parts (front cover via
pageRanges:'1' no footer; body with footer; back cover standalone no footer) and merge with
pdf-lib (drop body page 1). @page :first { margin: 0 } + preferCSSPageSize:true.
- Don't rely on system fonts/tools for portability — bundle the font, use puppeteer's Chromium,
markdown-it, and pdf-lib. The only host requirement is Node ≥ 18.
- Verify visually — read the output PDF (the Read tool renders pages) to confirm cover, a content
page (footer + page number), and back cover;
pdfinfo only if poppler happens to be installed.
Files
cli.js (CLI) · lib/build.js (engine) · templates/ (styles.css + cover/back-cover) ·
assets/fonts/NotoSansThai.ttf (bundled, OFL) · examples/ (runnable sample). Default house credit:
เรียบเรียง: ศุภชัย จตุรพรม · แปลโดย Claude Code (AI) — override via --credit or config.