pdf-to-word-docx

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

PDF to Word Converter

PDF转Word转换器

Purpose

用途

  • Wraps the
    ComPDFKitConversion
    Python SDK into a reusable local conversion workflow, supporting PDF / image to Word, PPT, Excel, HTML, RTF, Image, TXT, JSON, Markdown, and CSV (10 output formats in total).
  • ComPDFKitConversion
    Python SDK封装为可复用的本地转换工作流,支持PDF/图片转换为Word、PPT、Excel、HTML、RTF、图片、TXT、JSON、Markdown和CSV(共10种输出格式)。

Agent Skills Standard Compatibility

Agent Skills标准兼容性

  • This Skill uses an Anthropic Agent Skills-compatible directory structure:
    pdf-to-word-docx/
    .
  • The entry point is
    SKILL.md
    ; helper scripts are placed in
    scripts/
    .
  • The document uses
    $ARGUMENTS
    and
    ${CLAUDE_SKILL_DIR}
    conventions for distribution and execution in Claude Code / Agent Skills-compatible environments.
  • 本Skill采用Anthropic Agent Skills兼容的目录结构:
    pdf-to-word-docx/
  • 入口文件为
    SKILL.md
    ;辅助脚本存放于
    scripts/
    目录。
  • 文档使用
    $ARGUMENTS
    ${CLAUDE_SKILL_DIR}
    约定,以便在Claude Code/Agent Skills兼容环境中分发和执行。

Input / Output

输入/输出

  • Input: The target format (
    word
    /
    excel
    /
    ppt
    /
    html
    /
    rtf
    /
    image
    /
    txt
    /
    json
    /
    markdown
    /
    csv
    ), the PDF or image path, and the output path are passed via Skill arguments or the command line. An optional PDF password and conversion parameters may also be provided.
  • Supported input file types:
    • PDF files (
      .pdf
      )
    • Image files (
      .jpg
      /
      .jpeg
      /
      .png
      /
      .bmp
      /
      .tif
      /
      .tiff
      /
      .webp
      /
      .jp2
      /
      .gif
      /
      .tga
      )
  • Output: A file in the corresponding format (
    .docx
    ,
    .pptx
    ,
    .xlsx
    ,
    .html
    ,
    .rtf
    , image,
    .txt
    ,
    .json
    ,
    .md
    ,
    .csv
    ), or a clear error message.
  • 输入:目标格式(
    word
    /
    excel
    /
    ppt
    /
    html
    /
    rtf
    /
    image
    /
    txt
    /
    json
    /
    markdown
    /
    csv
    )、PDF或图片路径、输出路径通过Skill参数或命令行传递。还可提供可选的PDF密码和转换参数。
  • 支持的输入文件类型:
    • PDF文件(
      .pdf
    • 图片文件(
      .jpg
      /
      .jpeg
      /
      .png
      /
      .bmp
      /
      .tif
      /
      .tiff
      /
      .webp
      /
      .jp2
      /
      .gif
      /
      .tga
  • 输出:对应格式的文件(
    .docx
    .pptx
    .xlsx
    .html
    .rtf
    、图片、
    .txt
    .json
    .md
    .csv
    ),或清晰的错误提示信息。

Prerequisites

前置条件

  • Supports Windows and macOS.
  • The conversion SDK must be installed first:
    bash
    pip install ComPDFKitConversion
  • On first run, the script automatically downloads
    license.xml
    from the ComPDF server and caches it in the
    scripts/
    directory:
    text
    https://download.compdf.com/skills/license/license.xml
  • The script reads the
    <key>...</key>
    field from
    license.xml
    and uses that key for
    LibraryManager.license_verify(...)
    authentication — it does not pass the XML file path directly to the SDK.
  • To use a custom license, place your own
    license.xml
    in the
    scripts/
    directory; the script will use it directly without downloading.
  • During SDK initialization, the
    resource
    directory is always set to the directory containing
    pdf-to-word-docx.py
    , i.e., the
    scripts/
    directory itself.
  • When
    --enable-ocr
    or
    --enable-ai-layout
    (enabled by default) is used, the Skill also requires
    scripts/documentai.model
    . If the file does not exist, the script will automatically download it from:
    text
    https://download.compdf.com/skills/model/documentai.model
  • To reuse an existing model file, you can override the default model path via an environment variable:
    bash
    export COMPDF_DOCUMENT_AI_MODEL="/path/to/documentai.model"
  • 支持Windows和macOS系统。
  • 必须先安装转换SDK:
    bash
    pip install ComPDFKitConversion
  • 首次运行时,脚本会自动从ComPDF服务器下载
    license.xml
    并缓存到
    scripts/
    目录:
    text
    https://download.compdf.com/skills/license/license.xml
  • 脚本从
    license.xml
    中读取
    <key>...</key>
    字段,并使用该密钥进行
    LibraryManager.license_verify(...)
    认证——不会直接将XML文件路径传递给SDK。
  • 若要使用自定义许可证,将您自己的
    license.xml
    放置在
    scripts/
    目录中;脚本会直接使用该文件,不会自动下载。
  • SDK初始化时,
    resource
    目录始终设置为包含
    pdf-to-word-docx.py
    的目录,即
    scripts/
    目录本身。
  • 当使用
    --enable-ocr
    --enable-ai-layout
    (默认启用)时,Skill还需要
    scripts/documentai.model
    文件。若文件不存在,脚本会自动从以下地址下载:
    text
    https://download.compdf.com/skills/model/documentai.model
  • 若要复用现有模型文件,可通过环境变量覆盖默认模型路径:
    bash
    export COMPDF_DOCUMENT_AI_MODEL="/path/to/documentai.model"

Workflow

工作流

  1. Confirm the Python package is installed:
    bash
    python -m pip show ComPDFKitConversion
  2. The script automatically downloads
    license.xml
    on first run; the
    scripts/
    directory is used directly as the SDK
    resource
    path.
  3. In Agent Skills / Claude Code environments, prefer using the Skill's built-in script path variable:
    bash
    python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" word input.pdf output.docx
    python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" ppt input.pdf output.pptx
    python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" excel input.pdf output.xlsx
  4. For more control, append common parameters:
    bash
    python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" excel input.pdf output.xlsx --page-ranges "1-3,5" --excel-all-content --excel-worksheet-option for-page
    python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" word input.pdf output.docx --enable-ocr --page-layout-mode flow
  5. On startup, the script ensures
    scripts/license.xml
    exists (downloading it automatically from the ComPDF server if missing), reads the
    <key>
    field for SDK authentication, and uses the
    scripts/
    directory as the
    resource
    path.
  6. If
    --enable-ocr
    or
    --enable-ai-layout
    (enabled by default) is active, the script checks whether
    scripts/documentai.model
    exists; if not, it downloads the file automatically before initializing the Document AI model.
  7. Check the return code; if it is not
    SUCCESS
    , handle license, password, resource, model, or input file issues according to the error name.
  1. 确认Python包已安装:
    bash
    python -m pip show ComPDFKitConversion
  2. 脚本首次运行时自动下载
    license.xml
    scripts/
    目录直接用作SDK的
    resource
    路径。
  3. 在Agent Skills/Claude Code环境中,优先使用Skill内置的脚本路径变量:
    bash
    python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" word input.pdf output.docx
    python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" ppt input.pdf output.pptx
    python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" excel input.pdf output.xlsx
  4. 如需更多控制,可追加常用参数:
    bash
    python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" excel input.pdf output.xlsx --page-ranges "1-3,5" --excel-all-content --excel-worksheet-option for-page
    python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" word input.pdf output.docx --enable-ocr --page-layout-mode flow
  5. 启动时,脚本确保
    scripts/license.xml
    存在(若缺失则自动从ComPDF服务器下载),读取
    <key>
    字段用于SDK认证,并将
    scripts/
    目录作为
    resource
    路径。
  6. --enable-ocr
    --enable-ai-layout
    (默认启用)处于激活状态,脚本会检查
    scripts/documentai.model
    是否存在;若不存在,会在初始化Document AI模型前自动下载该文件。
  7. 检查返回码;若返回码不是
    SUCCESS
    ,则根据错误名称处理许可证、密码、资源、模型或输入文件相关问题。

documentai.model Download Optimization

documentai.model下载优化

  • The script preferentially uses the model file pointed to by
    COMPDF_DOCUMENT_AI_MODEL
    .
  • The default model path is
    scripts/documentai.model
    .
  • During automatic download, the file is first written to
    documentai.model.part
    and then atomically renamed to the final file upon success, preventing partial file corruption.
  • On download failure, the script retries automatically with back-off intervals of
    2s / 5s / 10s
    .
  • 脚本优先使用
    COMPDF_DOCUMENT_AI_MODEL
    指向的模型文件。
  • 默认模型路径为
    scripts/documentai.model
  • 自动下载时,文件先写入
    documentai.model.part
    ,成功后再原子重命名为最终文件,避免文件部分损坏。
  • 下载失败时,脚本会自动重试,退避间隔为
    2s / 5s / 10s

Invoking Directly as a Skill

直接作为Skill调用

  • In environments that support Agent Skills, the Skill can be called directly:
    text
    /pdf-to-word-docx word input.pdf output.docx
    /pdf-to-word-docx excel input.pdf output.xlsx --excel-worksheet-option for-page
  • When the Skill receives arguments, it passes them through to the script as-is:
    bash
    python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" $ARGUMENTS
  • If the environment does not support direct Skill invocation, fall back to a regular command-line call.
  • 在支持Agent Skills的环境中,可直接调用该Skill:
    text
    /pdf-to-word-docx word input.pdf output.docx
    /pdf-to-word-docx excel input.pdf output.xlsx --excel-worksheet-option for-page
  • Skill收到参数后,会原样传递给脚本:
    bash
    python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" $ARGUMENTS
  • 若环境不支持直接调用Skill,则退回到常规命令行调用方式。

Supported Output Formats

支持的输出格式

  • word
    → calls
    CPDFConversion.start_pdf_to_word
  • excel
    → calls
    CPDFConversion.start_pdf_to_excel
  • ppt
    → calls
    CPDFConversion.start_pdf_to_ppt
  • html
    → calls
    CPDFConversion.start_pdf_to_html
  • rtf
    → calls
    CPDFConversion.start_pdf_to_rtf
  • image
    → calls
    CPDFConversion.start_pdf_to_image
  • txt
    → calls
    CPDFConversion.start_pdf_to_txt
  • json
    → calls
    CPDFConversion.start_pdf_to_json
  • markdown
    → calls
    CPDFConversion.start_pdf_to_markdown
  • csv
    → reuses
    CPDFConversion.start_pdf_to_excel
    with table/Excel parameters to produce CSV-friendly output
  • word
    → 调用
    CPDFConversion.start_pdf_to_word
  • excel
    → 调用
    CPDFConversion.start_pdf_to_excel
  • ppt
    → 调用
    CPDFConversion.start_pdf_to_ppt
  • html
    → 调用
    CPDFConversion.start_pdf_to_html
  • rtf
    → 调用
    CPDFConversion.start_pdf_to_rtf
  • image
    → 调用
    CPDFConversion.start_pdf_to_image
  • txt
    → 调用
    CPDFConversion.start_pdf_to_txt
  • json
    → 调用
    CPDFConversion.start_pdf_to_json
  • markdown
    → 调用
    CPDFConversion.start_pdf_to_markdown
  • csv
    → 复用
    CPDFConversion.start_pdf_to_excel
    并配合表格/Excel参数生成适合CSV的输出

Input Source Types

输入源类型

  • The script supports PDF and image as input sources. The SDK's
    start_pdf_to_*
    interfaces natively accept image files with no pre-processing required.
  • By default, the script auto-detects the input type from the file extension:
    • .pdf
      pdf
    • .png/.jpg/.jpeg/.bmp/.tif/.tiff/.gif/.webp/.tga
      image
  • You can also specify the source type explicitly:
    bash
    python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" word input.png output.docx --source-type image
  • image -> *
    and
    pdf -> *
    share the same set of
    CPDFConversion.start_pdf_to_*
    interfaces; only the input file type differs.
  • 脚本支持PDF和图片作为输入源。SDK的
    start_pdf_to_*
    接口原生支持图片文件输入,无需预处理。
  • 默认情况下,脚本会根据文件扩展名自动检测输入类型:
    • .pdf
      pdf
    • .png/.jpg/.jpeg/.bmp/.tif/.tiff/.gif/.webp/.tga
      image
  • 您也可以显式指定源类型:
    bash
    python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" word input.png output.docx --source-type image
  • image -> *
    pdf -> *
    使用相同的
    CPDFConversion.start_pdf_to_*
    接口集;仅输入文件类型不同。

Smart Defaults

智能默认值

The script automatically adjusts certain parameters based on the input source and output format to reduce manual configuration:
TriggerAutomatic BehaviorUser-OverridableDescription
Input source is an image (auto-detected or explicit
--source-type image
)
Automatically enables
--enable-ocr
No (
--enable-ocr
uses
store_true
; there is no
--no-enable-ocr
)
Text in images must be extracted via OCR; without OCR, output will contain only images and no text
Output format is HTML (
format = html
)
Automatically sets
--page-layout-mode
to
box
(box layout)
Yes — passing
--page-layout-mode flow
explicitly overrides this
Box layout better preserves the original formatting in HTML; specify
flow
explicitly if flow layout is needed
When triggered, the script prints a notice to
stderr
, for example:
text
Auto-enabled OCR for image input.
Auto-set page layout mode to BOX for HTML output.
脚本会根据输入源和输出格式自动调整某些参数,减少手动配置:
触发条件自动行为用户可覆盖描述
输入源为图片(自动检测或显式指定
--source-type image
自动启用
--enable-ocr
否(
--enable-ocr
使用
store_true
;没有
--no-enable-ocr
选项)
图片中的文本必须通过OCR提取;若不启用OCR,输出将仅包含图片,无文本内容
输出格式为HTML
format = html
自动将
--page-layout-mode
设置为
box
(框式布局)
是——显式传递
--page-layout-mode flow
会覆盖此设置
框式布局能更好地保留HTML中的原始格式;若需要流式布局,需显式指定
flow
触发时,脚本会向
stderr
打印提示信息,例如:
text
Auto-enabled OCR for image input.
Auto-set page layout mode to BOX for HTML output.

All Parameters

所有参数

Positional Parameters

位置参数

ParameterDescription
format
Target format:
word
/
excel
/
ppt
/
html
/
rtf
/
image
/
txt
/
json
/
markdown
/
csv
input_pdf
Input file path (PDF or image)
output_path
Output file path
参数描述
format
目标格式:
word
/
excel
/
ppt
/
html
/
rtf
/
image
/
txt
/
json
/
markdown
/
csv
input_pdf
输入文件路径(PDF或图片)
output_path
输出文件路径

General Parameters

通用参数

ParameterTypeDefaultDescription
--source-type
Option
auto
Input source type:
auto
/
pdf
/
image
--password
String
""
PDF open password
--page-ranges
StringNonePage range, e.g.
1-3,5
--font-name
String
""
Output font name
参数类型默认值描述
--source-type
选项
auto
输入源类型:
auto
/
pdf
/
image
--password
字符串
""
PDF打开密码
--page-ranges
字符串None页面范围,例如
1-3,5
--font-name
字符串
""
输出字体名称

Layout Parameters

布局参数

ParameterTypeDefaultDescription
--enable-ai-layout
BooleanTrueAI layout analysis (disable with
--no-enable-ai-layout
)
--page-layout-mode
OptionSDK default
flow
(auto-switched to
box
for HTML output)
Page layout:
box
(box layout) /
flow
(flow layout)
参数类型默认值描述
--enable-ai-layout
布尔值TrueAI布局分析(使用
--no-enable-ai-layout
禁用)
--page-layout-mode
选项SDK默认值
flow
(HTML输出时自动切换为
box
页面布局:
box
(框式布局)/
flow
(流式布局)

Content Retention Parameters

内容保留参数

ParameterTypeDefaultDescription
--contain-image
BooleanTrueRetain images (disable with
--no-contain-image
)
--contain-annotation
BooleanTrueRetain annotations (disable with
--no-contain-annotation
)
--contain-page-background-image
BooleanTrueRetain page background images (disable with
--no-contain-page-background-image
)
--formula-to-image
BooleanFalseConvert formulas to image output
--transparent-text
BooleanFalsePreserve transparent text
参数类型默认值描述
--contain-image
布尔值True保留图片(使用
--no-contain-image
禁用)
--contain-annotation
布尔值True保留注释(使用
--no-contain-annotation
禁用)
--contain-page-background-image
布尔值True保留页面背景图片(使用
--no-contain-page-background-image
禁用)
--formula-to-image
布尔值False将公式转换为图片输出
--transparent-text
布尔值False保留透明文本

Output Control Parameters

输出控制参数

ParameterTypeDefaultDescription
--output-document-per-page
BooleanFalseSplit output into one document per page
--auto-create-folder
BooleanTrueAutomatically create output directory (disable with
--no-auto-create-folder
)
参数类型默认值描述
--output-document-per-page
布尔值False将输出按每页拆分单独文档
--auto-create-folder
布尔值True自动创建输出目录(使用
--no-auto-create-folder
禁用)

OCR Parameters

OCR参数

ParameterTypeDefaultDescription
--enable-ocr
BooleanFalse (auto-enabled for image input)Enable OCR
--ocr-option
OptionSDK default
all
OCR scope:
invalid-character
/
scan-page
/
invalid-character-and-scan-page
/
all
--ocr-language
Multi-select
auto
OCR language(s); multiple languages can be specified simultaneously. Options:
auto
/
chinese
/
chinese-tra
/
english
/
korean
/
japanese
/
latin
/
devanagari
/
cyrillic
/
arabic
/
tamil
/
telugu
/
kannada
/
thai
/
greek
/
eslav
参数类型默认值描述
--enable-ocr
布尔值False(图片输入时自动启用)启用OCR
--ocr-option
选项SDK默认值
all
OCR范围:
invalid-character
/
scan-page
/
invalid-character-and-scan-page
/
all
--ocr-language
多选
auto
OCR语言;可同时指定多种语言。选项:
auto
/
chinese
/
chinese-tra
/
english
/
korean
/
japanese
/
latin
/
devanagari
/
cyrillic
/
arabic
/
tamil
/
telugu
/
kannada
/
thai
/
greek
/
eslav

Excel-Specific Parameters

Excel专属参数

ParameterTypeDefaultDescription
--excel-all-content
BooleanFalseInclude all content in Excel output
--excel-csv-format
BooleanFalseOutput Excel result in CSV format
--excel-worksheet-option
OptionSDK default
for-table
Worksheet split strategy:
for-table
/
for-page
/
for-document
参数类型默认值描述
--excel-all-content
布尔值False在Excel输出中包含所有内容
--excel-csv-format
布尔值False将Excel结果输出为CSV格式
--excel-worksheet-option
选项SDK默认值
for-table
工作表拆分策略:
for-table
/
for-page
/
for-document

JSON-Specific Parameters

JSON专属参数

ParameterTypeDefaultDescription
--json-contain-table
BooleanTrueInclude table data in JSON output (disable with
--no-json-contain-table
)
参数类型默认值描述
--json-contain-table
布尔值True在JSON输出中包含表格数据(使用
--no-json-contain-table
禁用)

TXT-Specific Parameters

TXT专属参数

ParameterTypeDefaultDescription
--txt-table-format
BooleanTrueEnable table formatting in TXT output (disable with
--no-txt-table-format
)
参数类型默认值描述
--txt-table-format
布尔值True在TXT输出中启用表格格式化(使用
--no-txt-table-format
禁用)

HTML-Specific Parameters

HTML专属参数

ParameterTypeDefaultDescription
--html-option
OptionSDK default
single-page
HTML output mode:
single-page
/
single-page-with-bookmark
/
multiple-page
/
multiple-page-with-bookmark
参数类型默认值描述
--html-option
选项SDK默认值
single-page
HTML输出模式:
single-page
/
single-page-with-bookmark
/
multiple-page
/
multiple-page-with-bookmark

Image-Specific Parameters

图片专属参数

ParameterTypeDefaultDescription
--image-type
OptionSDK default
jpg
Image output format:
jpg
/
jpeg
/
jpeg2000
/
png
/
bmp
/
tiff
/
tga
/
gif
/
webp
--image-color-mode
OptionSDK default
color
Image color mode:
color
/
gray
/
binary
--image-scaling
Float
1.0
Image scaling factor
--image-path-enhance
BooleanFalseEnable image path enhancement
参数类型默认值描述
--image-type
选项SDK默认值
jpg
图片输出格式:
jpg
/
jpeg
/
jpeg2000
/
png
/
bmp
/
tiff
/
tga
/
gif
/
webp
--image-color-mode
选项SDK默认值
color
图片颜色模式:
color
/
gray
/
binary
--image-scaling
浮点数
1.0
图片缩放比例
--image-path-enhance
布尔值False启用图片路径增强

Parameter Default Value Rules

参数默认值规则

  • Parameters that default to True (
    --enable-ai-layout
    /
    --contain-image
    /
    --contain-annotation
    /
    --contain-page-background-image
    /
    --auto-create-folder
    /
    --json-contain-table
    /
    --txt-table-format
    ) use
    BooleanOptionalAction
    ; pass
    --no-xxx
    to disable.
  • Parameters that default to False (
    --enable-ocr
    /
    --formula-to-image
    /
    --transparent-text
    /
    --output-document-per-page
    /
    --excel-all-content
    /
    --excel-csv-format
    /
    --image-path-enhance
    ) use
    store_true
    ; passing the flag enables them.
  • All CLI parameter defaults are fully consistent with the SDK's
    ConvertOptions()
    defaults
    — omitting a parameter is equivalent to using the SDK's original default value.
  • 默认值为True的参数
    --enable-ai-layout
    /
    --contain-image
    /
    --contain-annotation
    /
    --contain-page-background-image
    /
    --auto-create-folder
    /
    --json-contain-table
    /
    --txt-table-format
    )使用
    BooleanOptionalAction
    ;传递
    --no-xxx
    即可禁用。
  • 默认值为False的参数
    --enable-ocr
    /
    --formula-to-image
    /
    --transparent-text
    /
    --output-document-per-page
    /
    --excel-all-content
    /
    --excel-csv-format
    /
    --image-path-enhance
    )使用
    store_true
    ;传递该标志即可启用。
  • 所有CLI参数默认值与SDK的
    ConvertOptions()
    默认值完全一致
    ——省略参数等效于使用SDK的原始默认值。

Recommended Command Examples

推荐命令示例

PDF to Word (default parameters, AI layout analysis enabled)

PDF转Word(默认参数,启用AI布局分析)

bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" word input.pdf output.docx
bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" word input.pdf output.docx

PDF to Word, box layout, no images, no AI layout analysis

PDF转Word,框式布局,不含图片,禁用AI布局分析

bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" word input.pdf output.docx --no-enable-ai-layout --no-contain-image --page-layout-mode box
bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" word input.pdf output.docx --no-enable-ai-layout --no-contain-image --page-layout-mode box

PDF to Word, retain annotations and background images, one document per page

PDF转Word,保留注释和背景图片,按每页拆分文档

bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" word input.pdf output.docx --output-document-per-page
bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" word input.pdf output.docx --output-document-per-page

PDF to Excel, include all content and split worksheets by page

PDF转Excel,包含所有内容并按页面拆分工作表

bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" excel input.pdf output.xlsx --excel-all-content --excel-worksheet-option for-page
bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" excel input.pdf output.xlsx --excel-all-content --excel-worksheet-option for-page

PDF to TXT, with table formatting enabled

PDF转TXT,启用表格格式化

bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" txt input.pdf output.txt
bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" txt input.pdf output.txt

PDF to HTML, multi-page with bookmarks mode

PDF转HTML,带书签的多页模式

bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" html input.pdf output_dir --html-option multiple-page-with-bookmark
bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" html input.pdf output_dir --html-option multiple-page-with-bookmark

PDF to Image, PNG format, grayscale, 2x scaling

PDF转图片,PNG格式,灰度,2倍缩放

bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" image input.pdf output.png --image-type png --image-color-mode gray --image-scaling 2.0
bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" image input.pdf output.png --image-type png --image-color-mode gray --image-scaling 2.0

Image to Word (OCR auto-enabled, specify Chinese language)

图片转Word(自动启用OCR,指定中文语言)

bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" word input.png output.docx --ocr-language chinese
Note: For image input, the script automatically enables OCR — there is no need to pass
--enable-ocr
manually. To specify an OCR language,
--ocr-language
can still be used.
bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" word input.png output.docx --ocr-language chinese
注意:对于图片输入,脚本会自动启用OCR——无需手动传递
--enable-ocr
。若要指定OCR语言,仍可使用
--ocr-language
参数。

PDF with OCR enabled (multiple languages)

启用OCR的PDF转换(多语言)

bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" word input.pdf output.docx --enable-ocr --ocr-language chinese english japanese
bash
python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" word input.pdf output.docx --enable-ocr --ocr-language chinese english japanese

Trial License and Usage Limits

试用许可证及使用限制

  • The
    scripts/license.xml
    auto-downloaded from the ComPDF server is a Trial License, allowing a maximum of 200 conversions.
  • The script uses a SHA-256 fingerprint to detect whether the current License is the default trial key; no usage limit applies when using any other License.
  • After each successful conversion using the trial License, the script prints the current used/remaining count to
    stderr
    , for example:
    text
    Trial license: 5/200 conversions used, 195 remaining.
  • When the trial limit is reached (200 conversions), the script refuses to convert and prompts the user to purchase a full License:
    text
    Error: Trial license usage limit reached (200 conversions). Please purchase a license at: https://www.compdf.com/contact-sales?utm_source=clawhub&utm_medium=skillhub&utm_campaign=pdf_skill_to_word&ref_platform_id=clawhub_skills
  • When the trial License has expired (SDK authentication fails), the error message also includes a purchase link.
  • After purchasing a full License, place a custom
    license.xml
    containing the new
    <key>
    in
    scripts/
    (overwriting the auto-downloaded trial file) — no script modifications or counter file cleanup are required.
  • 从ComPDF服务器自动下载的
    scripts/license.xml
    试用许可证,最多允许200次转换
  • 脚本使用SHA-256指纹检测当前许可证是否为默认试用密钥;使用其他任何许可证时无使用限制
  • 使用试用许可证完成每次成功转换后,脚本会向
    stderr
    打印当前已使用/剩余次数,例如:
    text
    Trial license: 5/200 conversions used, 195 remaining.
  • 当试用限制达到(200次转换)时,脚本会拒绝转换并提示用户购买完整许可证:
    text
    Error: Trial license usage limit reached (200 conversions). Please purchase a license at: https://www.compdf.com/contact-sales?utm_source=clawhub&utm_medium=skillhub&utm_campaign=pdf_skill_to_word&ref_platform_id=clawhub_skills
  • 当试用许可证过期(SDK认证失败)时,错误信息也会包含购买链接。
  • 购买完整许可证后,将包含新
    <key>
    的自定义
    license.xml
    放置在
    scripts/
    目录中(覆盖自动下载的试用文件)——无需修改脚本或清理计数器文件。

Confirmed Facts

已确认事实

  • ComPDFKitConversion
    has been successfully installed on the local machine.
  • The installed package provides 10 conversion methods including
    CPDFConversion.start_pdf_to_word/start_pdf_to_ppt/start_pdf_to_excel
    .
  • LibraryManager
    provides
    initialize
    ,
    license_verify
    ,
    release
    ,
    set_document_ai_model
    , and
    set_ocr_language
    .
  • Official documentation confirms support for PDF to Word / Excel / PPT / HTML / RTF / Image / TXT / JSON / Markdown.
  • The SDK's
    start_pdf_to_*
    interfaces natively accept image file input (PNG → Word has been verified successfully).
  • enable_ai_layout
    defaults to
    True
    in the SDK;
    set_document_ai_model()
    must be called first to load the model before use, otherwise a 0xC0000005 crash will occur.
  • --ocr-language
    supports specifying multiple languages simultaneously (e.g.
    --ocr-language chinese english
    ).
  • ComPDFKitConversion
    已成功安装在本地机器上。
  • 已安装的包提供10种转换方法,包括
    CPDFConversion.start_pdf_to_word/start_pdf_to_ppt/start_pdf_to_excel
  • LibraryManager
    提供
    initialize
    license_verify
    release
    set_document_ai_model
    set_ocr_language
    方法。
  • 官方文档确认支持PDF转Word/Excel/PPT/HTML/RTF/图片/TXT/JSON/Markdown。
  • SDK的
    start_pdf_to_*
    接口原生支持图片文件输入(PNG转Word已验证成功)。
  • SDK中
    enable_ai_layout
    默认值为
    True
    ;使用前必须先调用
    set_document_ai_model()
    加载模型,否则会发生0xC0000005崩溃。
  • --ocr-language
    支持同时指定多种语言(例如
    --ocr-language chinese english
    )。

Risks / Notes

风险/注意事项

  • The official requirements page states Python
    >=3.6
    , while the demo page states
    <3.11
    , but PyPI currently provides a
    cp314
    wheel in practice; treat the locally installable wheel as the source of truth, but always verify installation in a new environment first.
  • If the script cannot download
    license.xml
    from the server (network issue) and no manual file exists in
    scripts/
    , or the
    <key>
    field is empty, the script cannot complete SDK authentication and cannot perform any real conversions.
  • documentai.model
    is a large file (approximately 525 MB); there will be a noticeable download delay the first time OCR / AI layout is enabled. Because
    --enable-ai-layout
    defaults to True, the model download will be triggered on the very first run.
  • If the runtime environment cannot access
    https://download.compdf.com/skills/model/documentai.model
    , place
    documentai.model
    in the
    scripts/
    directory in advance.
  • Do not directly apply the initialization patterns from ComPDF SDKs for other languages to the Python package; this Skill is based on the locally verified
    LibraryManager
    /
    CPDFConversion
    API.
  • 官方要求页面说明Python版本
    >=3.6
    ,而演示页面说明
    <3.11
    ,但PyPI实际提供
    cp314
    版本的wheel包;以本地可安装的wheel包为准,但在新环境中始终要先验证安装情况。
  • 若脚本无法从服务器下载
    license.xml
    (网络问题)且
    scripts/
    目录中无手动放置的文件,或
    <key>
    字段为空,脚本无法完成SDK认证,无法执行任何实际转换。
  • documentai.model
    是大文件(约525 MB);首次启用OCR/AI布局时会有明显的下载延迟。由于
    --enable-ai-layout
    默认启用,首次运行时会触发模型下载
  • 若运行环境无法访问
    https://download.compdf.com/skills/model/documentai.model
    ,请提前将
    documentai.model
    放置在
    scripts/
    目录中。
  • 不要将其他语言的ComPDF SDK初始化模式直接应用于Python包;本Skill基于本地验证的
    LibraryManager
    /
    CPDFConversion
    API开发。

Resource Navigation

资源导航

  • License file:
    License.txt
  • Script:
    scripts/pdf-to-word-docx.py
  • SDK authentication file:
    scripts/license.xml
    (auto-downloaded from
    https://download.compdf.com/skills/license/license.xml
    if missing)
  • SDK authentication source: the
    <key>
    field in
    license.xml
  • SDK resource path:
    scripts/
  • OCR / AI layout model:
    scripts/documentai.model
    (auto-downloaded if missing)
  • Purchase a full License:
    https://www.compdf.com/contact-sales?utm_source=clawhub&utm_medium=skillhub&utm_campaign=pdf_skill_to_word&ref_platform_id=clawhub_skills
  • Official documentation:
    • https://www.compdf.com/guides/conversion-sdk/python/overview
    • https://www.compdf.com/guides/conversion-sdk/python/pdf-to-word
    • https://www.compdf.com/guides/conversion-sdk/python/pdf-to-excel
    • https://www.compdf.com/guides/conversion-sdk/python/pdf-to-ppt
    • https://www.compdf.com/guides/conversion-sdk/python/apply-license
  • 许可证文件:
    License.txt
  • 脚本:
    scripts/pdf-to-word-docx.py
  • SDK认证文件:
    scripts/license.xml
    (若缺失则从
    https://download.compdf.com/skills/license/license.xml
    自动下载)
  • SDK认证来源:
    license.xml
    中的
    <key>
    字段
  • SDK资源路径:
    scripts/
  • OCR/AI布局模型:
    scripts/documentai.model
    (若缺失则自动下载)
  • 购买完整许可证:
    https://www.compdf.com/contact-sales?utm_source=clawhub&utm_medium=skillhub&utm_campaign=pdf_skill_to_word&ref_platform_id=clawhub_skills
  • 官方文档:
    • https://www.compdf.com/guides/conversion-sdk/python/overview
    • https://www.compdf.com/guides/conversion-sdk/python/pdf-to-word
    • https://www.compdf.com/guides/conversion-sdk/python/pdf-to-excel
    • https://www.compdf.com/guides/conversion-sdk/python/pdf-to-ppt
    • https://www.compdf.com/guides/conversion-sdk/python/apply-license

Acceptance Checklist

验收 checklist

  • python -m pip show ComPDFKitConversion
    shows the installed package
  • Running
    python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" --help
    or an equivalent local command produces normal output
  • The script auto-downloads
    scripts/license.xml
    if missing, then extracts the license key from the
    <key>
    field for authentication
  • The script uses the
    scripts/
    directory as the SDK resource path
  • The script recognizes all 10 target formats:
    word
    /
    excel
    /
    ppt
    /
    html
    /
    rtf
    /
    image
    /
    txt
    /
    json
    /
    markdown
    /
    csv
  • The script accepts both PDF and image files (
    .png
    /
    .jpg
    /
    .jpeg
    /
    .bmp
    /
    .tif
    /
    .tiff
    /
    .gif
    /
    .webp
    /
    .tga
    ) as input
  • When
    --enable-ocr
    or
    --enable-ai-layout
    (enabled by default) is active and
    documentai.model
    is missing, the script auto-downloads the model
  • When
    license.xml
    cannot be obtained (download fails and no manual file exists) or authentication fails, a clear error is output rather than a silent failure
  • The 7 parameters that default to True can be disabled with
    --no-xxx
  • --ocr-language
    supports specifying multiple languages simultaneously
  • After a conversion using the trial License, the usage count increments
  • When the trial License reaches 200 conversions, the script refuses to convert and outputs a purchase link
  • When using a non-trial License, no usage limit applies
  • For image input, even if
    --enable-ocr
    is not passed, the script automatically enables OCR and prints a notice to
    stderr
  • For HTML output, even if
    --page-layout-mode
    is not passed, the script automatically uses
    box
    (box layout) and prints a notice to
    stderr
  • For HTML output, explicitly passing
    --page-layout-mode flow
    overrides the automatic box layout behavior
  • python -m pip show ComPDFKitConversion
    显示已安装的包
  • 运行
    python "${CLAUDE_SKILL_DIR}/scripts/pdf-to-word-docx.py" --help
    或等效本地命令能正常输出
  • scripts/license.xml
    缺失,脚本会自动下载,然后从
    <key>
    字段提取许可证密钥进行认证
  • 脚本将
    scripts/
    目录用作SDK资源路径
  • 脚本识别所有10种目标格式:
    word
    /
    excel
    /
    ppt
    /
    html
    /
    rtf
    /
    image
    /
    txt
    /
    json
    /
    markdown
    /
    csv
  • 脚本接受PDF和图片文件(
    .png
    /
    .jpg
    /
    .jpeg
    /
    .bmp
    /
    .tif
    /
    .tiff
    /
    .gif
    /
    .webp
    /
    .tga
    )作为输入
  • --enable-ocr
    --enable-ai-layout
    (默认启用)激活且
    documentai.model
    缺失时,脚本自动下载模型
  • 若无法获取
    license.xml
    (下载失败且无手动文件)或认证失败,输出清晰错误而非静默失败
  • 7个默认值为True的参数可通过
    --no-xxx
    禁用
  • --ocr-language
    支持同时指定多种语言
  • 使用试用许可证完成转换后,使用次数递增
  • 当试用许可证达到200次转换时,脚本拒绝转换并输出购买链接
  • 使用非试用许可证时无使用限制
  • 对于图片输入,即使未传递
    --enable-ocr
    ,脚本也会自动启用OCR并向
    stderr
    打印提示
  • 对于HTML输出,即使未传递
    --page-layout-mode
    ,脚本也会自动使用
    box
    (框式布局)并向
    stderr
    打印提示
  • 对于HTML输出,显式传递
    --page-layout-mode flow
    会覆盖自动框式布局行为

Distribution Notes

分发说明

  • This Skill does not depend on any machine-specific absolute paths.
  • When distributing to other users, the following directory structure is sufficient:
    text
    pdf-to-word-docx/
    ├── SKILL.md
    ├── License.txt
    └── scripts/
        └── pdf-to-word-docx.py
  • Users place this directory under their own skills root directory and the Skill is ready to use.
  • license.xml
    is auto-downloaded at runtime; no need to include it in the distribution package.
  • 本Skill不依赖任何机器特定的绝对路径。
  • 分发给其他用户时,以下目录结构即可:
    text
    pdf-to-word-docx/
    ├── SKILL.md
    ├── License.txt
    └── scripts/
        └── pdf-to-word-docx.py
  • 用户将此目录放置在自己的技能根目录下即可使用。
  • license.xml
    会在运行时自动下载;无需包含在分发包中。

Common Pitfalls

常见陷阱

  • scripts/license.xml
    is missing and cannot be auto-downloaded (network unavailable or server error): the script will error out before authentication. If you are in an offline environment, place
    license.xml
    manually in the
    scripts/
    directory.
  • scripts/license.xml
    is missing the
    <key>
    field or its value is empty: the script will error out before authentication.
  • SDK resource files required by the SDK are absent from the
    scripts/
    directory: conversion may fail after
    LibraryManager.initialize()
    .
  • A password-protected PDF is provided without
    --password
    : this will trigger
    PDF_PASSWORD_ERROR
    .
  • OCR / AI layout is enabled but
    documentai.model
    is not present locally and the network is unavailable: the model download will fail; place the file in the
    scripts/
    directory manually in advance.
  • When the Excel output strategy is unclear, prefer passing
    --excel-worksheet-option
    explicitly to avoid unexpected result structures.
  • When converting images to other formats, the script already enables OCR automatically; if the output still contains no text, check whether
    documentai.model
    is complete and whether the OCR language matches.
  • Once the trial License usage limit is exhausted, a full License must be purchased to continue; purchase link:
    https://www.compdf.com/contact-sales?utm_source=clawhub&utm_medium=skillhub&utm_campaign=pdf_skill_to_word&ref_platform_id=clawhub_skills
    .
  • scripts/license.xml
    缺失且无法自动下载(网络不可用或服务器错误):脚本会在认证前报错。若处于离线环境,请手动将
    license.xml
    放置在
    scripts/
    目录中。
  • scripts/license.xml
    缺少
    <key>
    字段或值为空:脚本会在认证前报错。
  • SDK所需的SDK资源文件在
    scripts/
    目录中缺失:
    LibraryManager.initialize()
    后转换可能失败。
  • 提供了受密码保护的PDF但未传递
    --password
    :会触发
    PDF_PASSWORD_ERROR
  • 启用了OCR/AI布局但本地无
    documentai.model
    且网络不可用:模型下载会失败;请提前手动将文件放置在
    scripts/
    目录中。
  • 若对Excel输出策略不明确,优先显式传递
    --excel-worksheet-option
    以避免意外的结果结构。
  • 将图片转换为其他格式时,脚本已自动启用OCR;若输出仍无文本,请检查
    documentai.model
    是否完整以及OCR语言是否匹配。
  • 试用许可证使用限制耗尽后,必须购买完整许可证才能继续;购买链接:
    https://www.compdf.com/contact-sales?utm_source=clawhub&utm_medium=skillhub&utm_campaign=pdf_skill_to_word&ref_platform_id=clawhub_skills

Copyright

版权声明

This Skill is built on top of the ComPDFKit Conversion SDK.
© 2014-2026 PDF Technologies, Inc., a KDAN Company. All Rights Reserved.
Important: Under the ComPDFKit Terms of Service, distributing the documentation, sample code, or source code of the ComPDFKit Conversion SDK to third parties is prohibited. Please ensure you have obtained a valid ComPDFKit License before using this Skill.
本Skill基于ComPDFKit Conversion SDK构建。
© 2014-2026 PDF Technologies, Inc., a KDAN Company. All Rights Reserved.
重要提示:根据ComPDFKit服务条款,禁止向第三方分发ComPDFKit Conversion SDK的文档、示例代码或源代码。使用本Skill前请确保已获取有效的ComPDFKit许可证。