pdf-poppler-utils Skill
A collection of PDF manipulation tools from the poppler-utils package.
Installation
Prerequisites
Install Poppler
CODEBLOCK0
⚠️ Important Warning About curl
The poppler Homebrew package has curl as a dependency. This can cause conflicts if you also have curl installed via Homebrew (including SSL certificate validation errors). Use the system curl directly or consider alternative approaches.
Before using poppler, it is strongly recommended to unlink the Homebrew installed curl:
CODEBLOCK1
⚠️ Please ask for human permission before executing brew unlink curl -v. If the human is unsure, recommend executing it (to resolve the potential conflict).
When to Use Which Tool
| Tool | Use Case |
|---|
| pdfinfo | Get detailed metadata and information about a PDF |
| pdftotext |
Extract text content from a PDF |
|
pdffonts | Analyze font usage in a PDF |
|
pdfimages | Extract images embedded in a PDF |
|
pdfdetach | Extract attachments from a PDF |
|
pdfseparate | Split a multi-page PDF into individual pages |
|
pdfunite | Merge multiple PDFs into one |
|
pdfsig | Verify digital signatures in a PDF |
|
pdftohtml | Convert PDF to HTML |
|
pdftoppm | Convert PDF pages to image formats (PNG, PPM) |
|
pdftocairo | Convert PDF to Cairo image formats (PNG, JPEG, TIFF, PDF, SVG) |
|
pdfattach | Attach files to a PDF |
Quick Reference
View PDF Information
CODEBLOCK2
Extract Text
CODEBLOCK3
Extract Images
CODEBLOCK4
Split PDF
CODEBLOCK5
Merge PDFs
CODEBLOCK6
Convert to HTML
CODEBLOCK7
Convert to Images
pdftoppm -png -r 300 document.pdf output_prefix
Tool Details
See individual documentation files in the tools/ folder for detailed usage:
Common Options
Many tools share common options:
| Option | Description |
|---|
| INLINECODE3 | Owner password (bypasses all security) |
| INLINECODE4 |
User password |
|
-v | Print version information |
|
-h | Print help |
Notes
- - All tools follow the convention: INLINECODE7
- Use
- as filename to read from stdin / write to stdout - Exit codes: 0=success, 1=error opening PDF, 2=error opening output, 3=permission error, 99=other error
Reference: Debian manpages
pdf-poppler-utils 技能
来自 poppler-utils 软件包的一套 PDF 操作工具。
安装
前置条件
安装 Poppler
bash
brew install poppler
⚠️ 关于 curl 的重要警告
poppler 的 Homebrew 软件包依赖 curl。如果您也通过 Homebrew 安装了 curl,这可能会导致冲突(包括 SSL 证书验证错误)。请直接使用系统自带的 curl,或考虑其他替代方案。
在使用 poppler 之前,强烈建议取消链接 Homebrew 安装的 curl:
bash
brew unlink curl -v
⚠️ 在执行 brew unlink curl -v 之前,请先征求人工许可。 如果人工不确定,建议执行该命令(以解决潜在的冲突)。
何时使用哪个工具
| 工具 | 使用场景 |
|---|
| pdfinfo | 获取 PDF 的详细元数据和信息 |
| pdftotext |
从 PDF 中提取文本内容 |
|
pdffonts | 分析 PDF 中的字体使用情况 |
|
pdfimages | 提取 PDF 中嵌入的图片 |
|
pdfdetach | 提取 PDF 中的附件 |
|
pdfseparate | 将多页 PDF 拆分为单页 |
|
pdfunite | 合并多个 PDF 文件 |
|
pdfsig | 验证 PDF 中的数字签名 |
|
pdftohtml | 将 PDF 转换为 HTML |
|
pdftoppm | 将 PDF 页面转换为图片格式(PNG、PPM) |
|
pdftocairo | 将 PDF 转换为 Cairo 图片格式(PNG、JPEG、TIFF、PDF、SVG) |
|
pdfattach | 向 PDF 附加文件 |
快速参考
查看 PDF 信息
bash
pdfinfo document.pdf
提取文本
bash
pdftotext document.pdf output.txt
pdftotext document.pdf - | less # 输出到标准输出
提取图片
bash
pdfimages -png document.pdf image_prefix
拆分 PDF
bash
pdfseparate document.pdf page_%03d.pdf
合并 PDF
bash
pdfunite file1.pdf file2.pdf file3.pdf merged.pdf
转换为 HTML
bash
pdftohtml document.pdf output.html
转换为图片
bash
pdftoppm -png -r 300 document.pdf output_prefix
工具详情
详细用法请参见 tools/ 文件夹中的独立文档文件:
常用选项
许多工具共享以下常用选项:
| 选项 | 描述 |
|---|
| -opw <密码> | 所有者密码(绕过所有安全限制) |
| -upw <密码> |
用户密码 |
| -v | 打印版本信息 |
| -h | 打印帮助信息 |
注意事项
- - 所有工具遵循以下约定:tool [选项] input.pdf [输出]
- 使用 - 作为文件名可从标准输入读取 / 写入标准输出
- 退出码:0=成功,1=打开 PDF 出错,2=打开输出出错,3=权限错误,99=其他错误
参考: Debian 手册页