| name | pdf-layout-translate |
| description | Translate PDF documents (for example Chinese to English) while preserving the original page geometry, layout, tables, chart placement, and image positions. Use this skill when users ask to keep the "same layout", "exact format", or "do not move pictures" during PDF translation. |
PDF Layout Translation
Use this skill to replace source-language PDF text while keeping the original visual structure.
Workflow
- Extract text lines and their bounding boxes from each page with PyMuPDF.
- Translate by exact line map first, then phrase map fallback.
- Redact only text regions, not images or vector graphics.
- Reinsert translated text into the same bounding boxes with adaptive font-size fitting.
- Export translated PDF and optional companion formats (txt/md/html/docx).
Run the Bundled Script
python "skills/pdf-layout-translate/scripts/translate_pdf_preserve_layout.py" \
--input "/path/to/input.pdf" \
--output "/path/to/output_en.pdf" \
--mapping "skills/pdf-layout-translate/references/mapping.sample.json" \
--formats txt md html docx
Mapping File Rules
- Prefer
full_line translations for long narrative lines.
- Use
phrase_map for short labels, table headers, and repeated terms.
- Keep numeric strings and units unchanged unless explicitly translated.
Quality Checks
- Confirm page count and page size are unchanged.
- Confirm no source-language text remains in the text layer.
- Visually verify tables/charts and picture positions match the source PDF.
Read references/workflow-notes.md for implementation details and pitfalls.