360 Secure SkillHub
360 安全技能中心

Pdf2word Skills

核心功能是提取扫描版PDF文本并转为可复用的Word(docx)文件,默认用本地免费RapidOCR引擎,也可配置Google Gemini API提升复杂布局、表格的识别精度。典型场景为处理扫描生成的PDF,尤其是含复杂内容的文件。通过命令行运行脚本,输入为PDF路径,输出为指定docx文件,可附加参数选择引擎、配置密钥优化效果。

scottkiss
scottkiss
热度 54.99
最近更新 2026-05-11 17:33:20
分类:效率依赖:代码执行 / 读写文件 / 第三方 API应用场景:文件转换

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add pdf2word-skills
Metadata
name
pdf2word-skills
description
Convert scanned PDF documents into Word text documents using a free, local OCR engine or remote api.

PDF to Word Converter

🇨🇳 简体中文 / Simplified Chinese

A skill to extract text from scanned PDF documents and convert them into reusable Word (.docx) files using the free, local docr OCR engine.

Prerequisites

  1. Initialize the OCR engine by downloading the binaries:
    bash scripts/install.sh
    
  2. Install the required Python dependencies:
    pip install -r scripts/requirements.txt
    

Usage

Run the Python script passing the input PDF file and the desired output .docx file path. You can also append any additional standard docr arguments (such as engine preferences).

python scripts/pdf2word.py <input.pdf> <output.docx> [docr_args...]

Examples

Convert a single file with the default local engine:

python scripts/pdf2word.py sample.pdf sample_output.docx

Using Other API Engines

By default, the script uses the local RapidOCR engine. The underlying docr tool also supports other engines like the Google Gemini API for potentially higher recognition accuracy on complex layouts.

To use Gemini, first configure your API key:

mkdir -p ~/.ocr
echo "gemini_api_key=your_gemini_key" > ~/.ocr/config

Then pass the -engine gemini argument to the script:

python scripts/pdf2word.py sample.pdf sample_output.docx -engine gemini

If your document has tables, you can force Gemini to output them in Markdown format so the script can parse them into native Word tables:

python scripts/pdf2word.py sample.pdf sample_output.docx -engine gemini -prompt "Extract all text and preserve tables in Markdown format using | symbols."

How it Works

  1. The script calls docr, which uses the specified OCR model (RapidOCR by default) to read text from the scanned PDF.
  2. The extracted text is temporarily stored.
  3. The python-docx library is used to read the temporary text and construct a formatted Word document.
  4. Temporary files are cleaned up automatically.