用途:nano-pdf 是基于自然语言指令编辑 PDF 的 CLI 工具,适合需要修改现有 PDF 文本、或对 PDF 做合并、拆分、提取页面等处理的场景,例如报告、演示文稿和文档的更新。
主要能力:
- 按页编辑:nano-pdf edit <pdf_file> <page_number> "<instruction>",用自然语言描述修改内容,例如更改标题、修正错别字。
- 从文本创建 PDF:nano-pdf create --output output.pdf --text "Your content here"。
- 合并 PDF:nano-pdf merge --output merged.pdf file1.pdf file2.pdf file3.pdf。
- 拆分 PDF:nano-pdf split input.pdf --output-dir ./pages/。
- 提取页面:nano-pdf extract input.pdf --pages 1-5 --output extracted.pdf。
安装与使用: 先安装 uv(若未安装):curl -LsSf https://astral.sh/uv/install.sh | sh,然后执行 uv pip install nano-pdf。编辑示例:nano-pdf edit deck.pdf 1 "Change the title to 'Q3 Results' and fix the typo in the subtitle"。
注意事项与限制:
- page_number 在部分版本中为 0 起始、部分为 1 起始;若结果不符,可尝试另一种编号方式。
- AI 驱动的编辑需要设置 OPENAI_API_KEY。
- 复杂布局修改可能需要多次尝试;图片较多的 PDF 可编辑性有限。
- 分发前请务必检查输出 PDF;复杂编辑建议拆分为多次较小操作。