Preface¶
Having a PDF contract or report on hand that requires minor edits, such as changing a few words or adjusting tables, but only allowing for copy-pasting that results in a completely messed-up layout, is a common pain point in office scenarios. Pure OCR treating the page as an image often loses table lines and alignment relationships; if the PDF itself has a text layer, a safer approach is to parse the layout directly and write .docx. Below is an introduction to the SkillHub community skill PDF转Word保留排版|简诗 AI (PDF to Word with Layout Retention | Jianshi AI). It puts the usage and boundaries of pdf2docx into an Agent-readable SKILL.md, allowing the conversion to be completed step-by-step within the conversation.
What is this¶
PDF转Word保留排版|简诗 AI (located at @user_fccf428b/pdf-to-docx-formatter, current version 1.0.2) is a community Skill aimed at office-efficiency, published by user_fccf428b. The official description is: Use the pdf2docx library to convert PDFs to editable Word documents, preserving the original layout, tables, images, and text formatting. The SkillHub page is labeled requires_api_key=false, requiring no additional API Key. The ORIGIN.json inside the package shows it is based on the pdf-to-docx path organization from claude-office-skills/skills, with a license of MIT.
Core Features¶
Based on the Skill description, capabilities are concentrated in the following categories (all revolving around pdf2docx, not full-page OCR recognition):
- Full document or page-range conversion: Can convert the entire PDF to
.docx, or specify a page range viastart/end/pages(page numbers use 0-based indexing in the library). - Preserving layout elements: Emphasizes preserving layout, tables, images, and text formatting; the description notes that scenarios like complex tables, watermarks, and password-protected PDFs may have deviations or require a password.
- Python integration examples:
SKILL.mdcontains code snippets for basic conversion, advanced parameters, batch conversion, and structural analysis, to help the Agent align with the library API when generating scripts. - Scanned document boundaries: The Skill explicitly states that scanned PDFs need OCR first (examples mention pytesseract,
pdf2image, etc.), and pdf2docx is better suited for PDFs with native text layers. - Security boundaries: Does not automatically install dependencies or execute external writes; commands and code are for reference only and require explicit user consent before execution.
Compared to solutions like MinerU that focus on layout analysis/OCR pipelines, this Skill is positioned as native content extraction based on pdf2docx, offering a lighter path suitable for quickly making text-based PDFs editable.
Installation and Usage¶
Install SkillHub CLI (if not already installed)¶
First, check if the CLI already exists:
command -v skillhub && skillhub --version
If not installed, use the official script as per the SkillHub installation documentation (full installation includes default Skills):
curl -fsSL https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/install.sh | bash
Install CLI only:
curl -fsSL https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/install.sh | bash -s -- --cli-only
Install this Skill¶
The SkillHub skill page requires referring to the skillhub.md installation instructions to install the skill into the current Agent’s skills directory (you must include --dir during installation, otherwise it defaults to ./skills/ which might not be recognized).
skillhub install pdf-to-docx-formatter --namespace user_fccf428b --dir <your Agent skills directory>
Common Agent skills directories (excerpted from the official installation documentation):
| Agent | skills directory |
|---|---|
| Cursor | ~/.cursor/skills/ |
| Claude Code | ~/.claude/skills/ |
| Codex | ~/.codex/skills/ or .agents/skills/ in the project |
After successful installation, the package includes SKILL.md (slug: pdf-to-docx-formatter). The default prompt in agents/openai.yaml is:
使用 $pdf-to-docx-formatter 完成“PDF转Word保留排版”任务,并给出可执行结果。
Runtime dependencies¶
The Python dependency installation method given in the Skill documentation is:
pip install pdf2docx
pip install Pillow
Whether to execute pip install locally should be confirmed by you according to the Skill’s security boundaries before proceeding.
Typical Usage¶
Triggering in Conversation¶
Following the “How to Use” flow in SKILL.md:
- Provide the PDF file to be converted (path or upload).
- Optionally specify the page range or conversion options.
- The Agent generates and executes the conversion according to the Skill (with your consent), outputting
.docx.
Example prompts (English original from the official Skill is quoted for reference):
Convert this PDF report to an editable Word documentTurn pages 1-5 of this PDF into Word format
In Chinese contexts, equivalent expressions can be used, for example: “Convert this PDF report to an editable Word document, preserving tables.”
Minimal Reproducible Conversion Code¶
The following snippets are from the official SKILL.md, showing the most basic usage of pdf2docx:
from pdf2docx import Converter
cv = Converter('input.pdf')
cv.convert('output.docx')
cv.close()
Converting only specific pages (0 is the first page):
from pdf2docx import Converter
cv = Converter('input.pdf')
cv.convert('output.docx', start=0, end=5)
cv.close()
For encrypted PDFs, you can pass the password parameter in convert (see the Advanced Options section in the Skill).
For a more complete parameter list, batch directory conversion, progress printing during conversion, etc., refer to SKILL.md inside the package; upstream library documentation can be found at pdf2docx.readthedocs.io and PyPI: pdf2docx.
Applicable Scenarios and Precautions¶
More suitable for: Digital PDFs (with selectable text, common office layouts), scenarios requiring quick editable Word output, or scenarios where you want the Agent to directly provide a pdf2docx script or page-breaking strategy.
Use with caution:
- Scanned documents, camera-shot PDFs: The Skill recommends OCR first, then layout Word; do not assume pdf2docx can “read” pure image pages.
- Complex layouts, special fonts: Font replacement or table misalignment may occur; the Skill recommends testing a small range first.
- Watermarks, encryption: Watermarks will be included in the docx; encrypted files require a password.
- Dependencies and security: The Skill agrees not to automatically install packages or execute commands without confirmation; in production environments, please review the scripts and file paths yourself.
SkillHub page statistics (based on scraped data): Rating 100000, Downloads 952 times; Category office-efficiency, Source community.
Conclusion¶
PDF转Word保留排版|简诗 AI puts the capabilities and limitations of pdf2docx into a standard Skill format, suitable for completing the “PDF → Editable Word” office task using natural language in Agents like Cursor and Claude Code that support skills directories. Installation and file structure are based on SkillHub.
- SkillHub skill page: https://www.skillhub.cn/skills/user_fccf428b/pdf-to-docx-formatter
- Official location / API entry: https://api.skillhub.cn/user_fccf428b/pdf-to-docx-formatter