Scripts2026年7月20日·1 分钟阅读

pdfcpu — PDF Processing Toolkit for Go and the Command Line

A comprehensive Go library and CLI for PDF manipulation including merge, split, watermark, encrypt, optimize, and validate operations. Requires no external dependencies like Ghostscript.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
pdfcpu
直接安装命令
npx -y tokrepo@latest install ef46d767-8457-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

pdfcpu is a pure Go library and command-line tool for processing PDF files. It covers the full spectrum of common PDF operations without relying on external tools like Ghostscript or Poppler.

What pdfcpu Does

  • Merges, splits, rotates, and reorders PDF pages
  • Adds text and image watermarks or stamps to pages
  • Encrypts and decrypts PDFs with AES-256 or RC4
  • Validates PDF files against the PDF specification
  • Optimizes file size by removing redundant objects and compressing streams

Architecture Overview

pdfcpu is written entirely in Go with no CGo dependencies. It implements a PDF parser and writer that handles the full PDF object model including cross-reference tables, object streams, and incremental updates. The CLI wraps the library API and supports batch operations across multiple files.

Self-Hosting & Configuration

  • Install via go install or download prebuilt binaries from GitHub Releases
  • Available in Homebrew, AUR, and Docker Hub
  • No configuration file required; all options are passed via CLI flags
  • The Go library can be imported directly into Go projects
  • Supports stdin/stdout piping for integration into shell pipelines

Key Features

  • Pure Go implementation with zero external dependencies
  • Full PDF spec compliance including PDF 2.0 support
  • Batch processing support for operating on multiple files at once
  • Page-level operations: extract, insert, remove, rotate individual pages
  • Form filling and flattening for automated document workflows

Comparison with Similar Tools

  • Ghostscript — C-based and heavyweight; pdfcpu is a single Go binary with no system dependencies
  • qpdf — C++ PDF transformation tool; pdfcpu offers a similar feature set in pure Go
  • PyPDF — Python library; pdfcpu is faster and works as both a CLI and Go library
  • pdftk — Java-based PDF toolkit; pdfcpu has no JVM requirement and is easier to deploy
  • Stirling PDF — web-based PDF suite; pdfcpu is a CLI/library for automation and scripting

FAQ

Q: Does pdfcpu support password-protected PDFs? A: Yes. It can encrypt and decrypt PDFs using AES-128, AES-256, or RC4 encryption.

Q: Can I use pdfcpu as a Go library? A: Yes. The library API mirrors the CLI functionality and is well-documented.

Q: Does it handle scanned PDFs or OCR? A: No. pdfcpu works with the PDF structure, not image content. Use a separate OCR tool first.

Q: Is PDF 2.0 supported? A: Yes. pdfcpu supports reading and writing PDF 2.0 compliant files.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产