PDF Master Translator

👤 lingqing 📦 v1.0.0 ⭐ 4.2 ⬇️ 953 下载
📄 办公效率 免费 🔑 需 API Key

📖 技能介绍


name: pdf-master-translator description: A highly robust, multi-agent pipeline for translating and reconstructing complex, image-heavy, or scanned PDF documents (especially engineering, scientific, or military specs). Use this skill when dealing with PDFs that contain complex layouts, dense tables, mathematical formulas (LaTeX), or when previous translation attempts resulted in broken layouts, missing figures, "hallucinated" translations, or corrupted text. It uses a "mask-and-fill" approach, holographic context injection, and SVG math rendering to ensure zero information loss and strict visual fidelity.


PDF Master Translator (V10 Architecture)

This skill provides a battle-tested, "bulletproof" pipeline for translating complex PDF documents. It was forged from extensive trial and error on NASA engineering specifications.

Do NOT attempt to use simple OCR or zero-shot LLM translation for complex engineering documents. They will fail. Use the translator_engine_v10.py script provided in this skill.

Core Capabilities & The V10 Pipeline

This skill relies on a Python script (scripts/translator_engine_v10.py) that implements a specific, multi-agent workflow:

  1. Layout & Physical Isolation (Masking):
  2. Never ask an LLM to "ignore the picture and translate the text" on a messy scan.
  3. The pipeline first detects figures and tables.
  4. It physically whites out (masks) these regions on a temporary image.
  5. The "clean" image is sent for translation, eliminating visual hallucinations.
  6. Original figures are extracted, converted to Base64, and safely appended to the final HTML/PDF.

    小葱技能站7w4.net发现了升级插件。

  7. Holographic Context Injection:

  8. Masking creates fragmented sentences around the masked areas.
  9. To prevent the translation Agent from producing out-of-context or broken translations, the pipeline injects the raw, unformatted text stream of the entire page as a reference dictionary. The Agent uses this context to seamlessly bridge the visual gaps.

  10. Protocol Downgrade (XML over JSON):

  11. Forcing LLMs to output thousands of words of Markdown inside a strict JSON structure is fragile and prone to escaping errors.
  12. The engine enforces simple XML tags (<HEADER>, <BODY>, <FOOTER>) for structural routing.

  13. Strict Math & Symbol Rendering:

  14. Standard PDF renderers (like WeasyPrint) cannot execute JavaScript (MathJax).
  15. The script uses regex to intercept all LaTeX ($...$ or $$...$$) and calls an external API (math.vercel.app) to render them as high-quality, embeddable SVG images.
  16. The Prompt strictly mandates the format **$Variable$**: Description for symbol glossaries, ensuring visual consistency.

  17. Terminal Defense (Sanity Cleaner):

  18. The final step before PDF generation is a regex sweep to remove any leaked LLM artifacts (like ```markdown wrappers) or error placeholders (like RetryError[]) that might have survived the pipeline.

Usage Instructions

To use this skill, execute the translator_engine_v10.py script.

Prerequisites

Ensure the required dependencies are installed (typically handled via uv run if inline metadata is used) and the Gemini API key is set.

export GEMINI_API_KEY="your_api_key_here"
# If a proxy is required for your network:
export HTTPS_PROXY="http://127.0.0.1:10809" 

Execution

Run the script, providing the path to the target PDF and the specific page range.

uv run ~/.npm-global/lib/node_modules/openclaw/skills/pdf-master-translator/scripts/translator_engine_v10.py /path/to/target.pdf --start <start_page> --end <end_page>

Important Operational Rules: - Always specify --start and --end explicitly. - For very large documents (>20 pages), it is highly recommended to run this using nohup ... & in the background, as the multi-agent cross-checking and API rate-limiting sleep cycles make this a long-running process.

Output

The script will generate a new PDF named [OriginalName]_V10_FINAL_P[start]-[end].pdf in the current working directory.

This PDF will feature: - A clear --- Page X --- divider for continuous reading. - Consistent Header and Footer markdown tables. - SVG-rendered math formulas. - A dedicated [ 原文图表/示意图 ] section at the bottom of relevant pages containing the extracted original diagrams. - (If applicable) A [ 图例符号说明 ] section containing translations of text found inside the diagrams.

🤖 AI 评测

这个Skill质量中等偏上,核心功能扎实——能较好地处理带图表和公式的复杂PDF翻译。但缺点也很明显:使用前需要修改代码中的页码设置和文件名,不够开箱即用;版本包里有太多重复文件;另外依赖一个外部网站来渲染数学公式,网络不稳时可能出问题。适合有一定技术能力的开发者使用,普通用户直接上手有一定门槛。

📊 多维度评分

适应性4.3
规范性4
有效性4.2
可靠性4.3
可信度4.5

📁 包含文件 (12 个)

📄 SKILL.md 4.4 KB
📄 _meta.json 140 B
📄 package.json 218 B
📄 scripts/translator_engine.py 10.5 KB
📄 scripts/translator_engine_v10.py 9.3 KB
📄 scripts/translator_engine_v4.py 10.4 KB
📄 scripts/translator_engine_v5.py 10 KB
📄 scripts/translator_engine_v6.py 11.4 KB
📄 scripts/translator_engine_v7.py 9.8 KB
📄 scripts/translator_engine_v8.py 3.2 KB
📄 scripts/translator_engine_v9.py 7.2 KB
📄 scripts/translator_engine_v9_final.py 7.4 KB