agentleFS
haoyiyinhaoyiyin/pdf-translate/SKILL.md

pdf-translate

Skill0 starsChanged 5 months agoMITView on GitHub

Use when translating PDF documents between languages while preserving original layout, images, tables, and formulas using pdf2zh (PDFMathTranslate).

  • Reads credentials
  • Installs packages

6 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No API key needed for Google Translate backend (free, no sign-up).

    line 37
  2. Distinctive:

    Compatibility issues: If the output has rendering problems, try compatibility mode:

    line 169

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

PDF Translation with Layout Preservation (pdf2zh)

Translate PDF documents between languages while fully preserving original layout, images, tables, formulas, and typography. Uses pdf2zh (PDFMathTranslate, accepted at EMNLP 2025) with Google Translate as the free default backend.

Output: two files — *-mono.pdf (translated only) and *-dual.pdf (bilingual side-by-side).

When to Use

  • You need to translate a PDF from one language to another
  • The original layout, images, and formatting must be preserved
  • You want a bilingual version for comparison
  • The document contains tables, formulas, or complex layouts
  • Scanned PDFs or documents with embedded images

Don't use for: simple text extraction without layout preservation (use ocr-and-documents skill instead).

Prerequisites

# Install pdf2zh
pip install pdf2zh

No API key needed for Google Translate backend (free, no sign-up).

Usage

Basic Translation

# Translate Chinese to English
pdf2zh input.pdf -li zh -lo en -s google

# Translate English to Chinese
pdf2zh input.pdf -li en -lo zh -s google

# Translate Japanese to English
pdf2zh input.pdf -li ja -lo en -s google

# Translate French to Chinese
pdf2zh input.pdf -li fr -lo zh -s google

This generates:

  • input-mono.pdf — translated-only version
  • input-dual.pdf — bilingual version (original left, translated right)

Specify Custom Output Directory

pdf2zh input.pdf -li zh -lo en -s google -o ./output/

Translate Specific Pages Only

pdf2zh input.pdf -li zh -lo en -s google -p 1-10

Translate from URL (Online PDF)

pdf2zh https://example.com/document.pdf -li zh -lo en -s google

Batch Translate an Entire Folder

pdf2zh --dir ./pdfs/ -li zh -lo en -s google

GUI Mode (Browser Interface)

pdf2zh -i
# Opens at http://localhost:7860

Use Different Translation Backends

BackendCommandAPI Key Needed
Google (free)-s googleNo
DeepL-s deeplYes (higher quality)
OpenAI-s openaiYes
Ollama (local)-s ollamaNo (local LLM)
Azure-s azureYes
Claude-s claudeYes

Language Codes (Common)

LanguageCode
Chinese (Simplified)zh
Chinese (Traditional)zh-TW
Englishen
Japaneseja
Koreanko
Frenchfr
Germande
Spanishes
Russianru
Arabicar
Portuguesept
Italianit

Parameter Reference

FlagDescriptionExample
-liSource language-li zh
-loTarget language-lo en
-sTranslation service-s google
-pSpecific pages-p 1,3,5-10
-oOutput directory-o ./output/
-tThread count-t 4
-fExclude text (regex)-f "(MS.*)"
--dirBatch translate folder--dir ./pdfs/
-iLaunch GUI-i
--compatibleCompatibility mode--compatible
--ignore-cacheBypass translation cache--ignore-cache

One-Shot Recipes

Quick Translate a Local PDF

pip install -q pdf2zh && pdf2zh input.pdf -li zh -lo en -s google

Translate with Higher Quality (OpenAI)

pdf2zh input.pdf -li zh -lo en -s openai
# Requires OPENAI_API_KEY in environment

Common Pitfalls

  1. Model download failure: pdf2zh downloads a layout detection model (wybxc/DocLayout-YOLO-DocStructBench-onnx) on first run. If blocked by network, set:
    export HF_ENDPOINT=https://hf-mirror.com
  2. Large PDF processing: For documents with 100+ pages, increase thread count:
    pdf2zh input.pdf -li zh -lo en -s google -t 4
  3. Translation rate limits: Very large documents may hit the translation service's rate limit. Try splitting the document:
    pdf2zh input.pdf -li zh -lo en -s google -p 1-20
    pdf2zh input.pdf -li zh -lo en -s google -p 21-40
  4. Compatibility issues: If the output has rendering problems, try compatibility mode:
    pdf2zh input.pdf -li zh -lo en -s google --compatible

Verification Checklist

  • *-mono.pdf exists and contains translated text
  • *-dual.pdf exists with bilingual layout
  • Images/graphics from original are preserved
  • Tables and formulas render correctly
  • Page count matches original

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.