CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

Poppler (pdftotext)

$ pdftotext 基金会 低风险
freedesktop.org · AI 能力与音视频 · GPL-2.0-or-later · macos / linux / windows

Poppler 的 pdftotext 可将 PDF 中的纯文本、保留排版文本(-layout)、TSV(-tsv)或带边界框的 HTML(-bbox)直接提取至标准输出(-)。配合查看元数据的 pdfinfo 与栅格化页面的 pdftoppm,为 Agent 提供确定性的本地 PDF 解析能力。

FCRS-1.0 综合评分
84 /100
良好 (Good)
高置信度 (实测)
零摩擦安装命令
brew install poppler
CLI vs MCP 选型建议 仅 CLI 可用

使用 pdftotext -layout 与 pdfinfo 进行本地 PDF 提取仅需毫秒级耗时,且无需将文档上传至 MCP 服务器。

Agent 友好度体检单

本地探针实测证据
— 原生 JSON 输出
— 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
— 只读模式开关
✓ 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md
实测版本
I/O Error: Couldn't open file '--version': No such file or directory.
冷启动耗时
27 ms
退出码 (help / 非法参数)
0 / 1
NO_COLOR 无色码污染 / 无 TTY 不挂起
Yes / Safe
抓取的 --help 摘要
pdftotext version 26.08.0
Copyright 2005-2026 The Poppler Developers - http://poppler.freedesktop.org
Copyright 1996-2011, 2022 Glyph & Cog, LLC
Usage: pdftotext [options] <PDF-file> [<text-file>]
  -f <int>                : first page to convert
  -l <int>                : last page to convert
  -r <fp>                 : resolution, in DPI (default is 72)
  -x <int>                : x-coordinate of the crop area top left corner
  -y <int>                : y-coordinate of the crop area top left corner
  -W <int>                : width of crop area in pixels (default is 0)
  -H <int>                : height of crop area in pixels (default is 0)
  -layout                 : maintain original physical layout
  -fixed <fp>             : assume fixed-pitch (or tabular) text
  -raw                    : keep strings in content stream order
  -remove-hyphens <string>: end-of-line hyphen handling: none, soft, or all (default: all)
  -nodiag                 : discard diagonal text
  -htmlmeta               : generate a simple HTML file, including the meta information
  -tsv                    : generate a simple TSV file, including the meta information for bounding boxes
  -enc <string>           : output text encoding name
  -listenc                : list available encodings
  -eol <string>           : output end-of-line convention (unix, dos, or mac)
  -nopgbrk                : don't insert page breaks between pages
  -bbox                   : output bounding box for each word and page size to html. Sets -htmlmeta
  -bbox-layout            : like -bbox but with extra layout bounding box data.  Sets -htmlmeta
  -cropbox                : use the crop box rather than media box
  -colspacing <fp>        : how much spacing we allow after a word before considering adjacent text to be a new column, as a fraction of the font size (default is 0.7, old releases had a 0.3 default)
  -opw <string>           : owner password (for encrypted files)
  -upw <string>           : user password (for encrypted files)
  -q                      : don't print any messages or errors
  -v                      : print copyright and version info
  -h                      : print usage information
  -help                   : print usage information
  --help                  : print usage information
  -?                      : print usage information

FCRS-1.0 六维评分拆解

Agent 友好度 19 / 25

支持 - 标准输出流、-tsv 表格输出与 -q 静默模式,具备确定性的非交互执行能力,但缺少原生 --json 输出。

  • Supports -layout, -tsv, -bbox, -q, and - stdout streaming
  • No native --json output flag
安全与权限边界 22 / 25

输出至 - 时完全只读,绝不修改源 PDF,并支持通过 -f/-l 限定页码范围。

  • Writing to - performs zero filesystem mutations
安装与运行摩擦 14 / 15

广泛内置于 Homebrew(poppler)、各大 Linux 发行版(poppler-utils)与 Windows,C++ 原生启动极快。

  • Available via brew install poppler and standard OS repositories
能力覆盖与边际价值 14 / 15

单个软件包即提供 pdftotext、pdfinfo、pdftoppm 与 pdfimages,覆盖绝大多数本地 PDF 检查场景。

  • Includes text extraction, metadata, image extraction, and page rendering
维护与来源背书 9 / 10

隶属 freedesktop.org 的老牌项目,在各大 Linux 与 macOS 生态中持续积极维护。

  • Maintained under freedesktop.org Poppler project
文档与可验证性 6 / 10

-h 摘要与手册页清晰,但采用传统单短横线参数风格(如 -layout、-nopgbrk),而非 GNU --long 双短横线规范。

  • Built-in pdftotext -h lists all options concisely

安全边界、鉴权与放权指南

鉴权方式
无需鉴权
凭证存储位置

无需凭据;可选通过 -opw 和 -upw 参数为加密的本地 PDF 传入密码。

潜在副作用
只读查询 本地写入
费用与配额提示

免费,基于 GPL-2.0-or-later 协议的开源二进制工具套件。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# Poppler (pdftotext) Agent Rules
- Pass `-` as the output argument (`pdftotext -layout in.pdf -`) to read text directly via stdout without creating temporary files.
- Use `-f` and `-l` page bounds on large PDFs so output does not overflow agent context.

Agent 高频安全命令配方

只读查询(安全推荐)

将保留排版的文本流式输出至标准输出
pdftotext -layout -q -f 1 -l 5 input.pdf -

提取第 1–5 页并保持物理列对齐后直接输出到标准输出(-),同时用 -q 静默警告。

以 TSV 格式提取词级边界框
pdftotext -tsv -q input.pdf -

将带坐标与文本标记的制表符分隔数据输出至标准输出,便于结构化解析文档。

受控写入与预演

将提取的 UTF-8 文本写入旁路文件
pdftotext -enc UTF-8 -layout input.pdf extracted.txt

在不改动源 PDF 的前提下将提取文本保存至 extracted.txt。

核心优势

  • + 可通过 - 直接向标准输出流式输出整洁的 UTF-8 文本,支持 -layout 或 -tsv 结构。
  • + 随包附带 pdfinfo 与 pdftoppm,可一并完成元数据检查与页面栅格化。

注意事项与踩坑点

  • ! 不直接输出 --json,且对纯扫描图片型 PDF 需配合 pdftoppm 与 tesseract 进行 OCR。
  • ! 使用单短横线参数(-layout、-nopgbrk),与常见 GNU --long 习惯不同。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI