agentleFS
phanghonghaophanghonghao/THU-Awesome-Skills/skills/word2pdf/SKILL.md

word2pdf

Skill8 starsChanged 3 months agoMITView on GitHub

Convert Word (.doc / .docx) to PDF. Auto-detects binary .doc (OLE2) vs .docx (Office Open XML) via magic bytes, then converts using Microsoft Word COM or LibreOffice headless. Use when user mentions "word2pdf", "Word转PDF", "Word to PDF", "doc转PDF", "docx转PDF", or needs to convert a Word document to PDF.

  • Installs packages

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If unavailable, try LibreOffice headless

    line 64
  2. Very specific:

    Always use PYTHONIOENCODING=utf-8 on Windows

    line 69
  3. Distinctive:

    If neither Word nor LibreOffice is available, inform the user to install one

    line 72

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

Word to PDF Converter

Convert Word documents (.doc / .docx) to PDF with automatic format detection.

When to Use

  • User mentions: "word2pdf", "Word转PDF", "Word to PDF", "doc转PDF", "docx转PDF"
  • Need to convert a Word document to PDF for sharing or submission
  • Need to check whether a file is .doc or .docx before converting

How It Works

  1. Format Detection — reads first 8 bytes to identify:
    • D0 CF 11 E0 ... → .doc (OLE2 Compound Binary Format)
    • 50 4B 03 04 → .docx (ZIP / Office Open XML)
  2. Conversion — tries in order:
    • Microsoft Word COM automation (win32com) — best fidelity for both formats
    • LibreOffice headless (soffice --headless) — fallback for both formats

Usage

python "<LOCAL_USER>/.claude/skills/word2pdf/word2pdf.py" <input.doc|input.docx> [output.pdf]

Arguments

ArgumentRequiredDescription
inputYesInput Word file path (.doc or .docx)
outputNoOutput PDF path (default: same name with .pdf extension)

Examples

# Convert .docx (auto-detect format, output = input_name.pdf)
python "<LOCAL_USER>/.claude/skills/word2pdf/word2pdf.py" "report.docx"

# Convert .doc (legacy binary format)
python "<LOCAL_USER>/.claude/skills/word2pdf/word2pdf.py" "old_document.doc"

# Convert with custom output path
python "<LOCAL_USER>/.claude/skills/word2pdf/word2pdf.py" "report.docx" "output.pdf"

Dependencies

  • Primary: Microsoft Word (installed) + pywin32
    python -m pip install pywin32
  • Fallback: LibreOffice (any recent version)

Workflow

  1. Validate input file exists
  2. Detect format via magic bytes (report .doc or .docx)
  3. Try Microsoft Word COM conversion
  4. If unavailable, try LibreOffice headless
  5. Report output path, file size, and page count

Rules

  1. Always use PYTHONIOENCODING=utf-8 on Windows
  2. Report detected format to user before converting
  3. Report any conversion warnings or errors
  4. If neither Word nor LibreOffice is available, inform the user to install one

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.