360 Secure SkillHub
360 安全技能中心

pdfly-cli

提供 pdfly 纯 Python 命令行工具的使用说明,覆盖压缩、合并/拆分、删除与旋转页面、签名与验签、元数据查看、图像与文本提取、2-up/booklet 排版及图像转 PDF 等命令,并附带页面范围语法、输出格式和退出码等参考文档。

overdue-lin
overdue-lin
热度 33.45
最近更新 2026-05-11 17:40:12
分类:效率依赖:代码执行 / 读写文件应用场景:文件转换 / 数据处理 / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add pdfly-cli
Metadata
name
pdfly-cli
description
A pure-python CLI application for manipulating PDF files. Use when needing to compress, merge, split, rotate, sign, extract images/text, or convert files to/from PDF. Commands: 2-up, booklet, cat, check-sign, compress, extract-annotated-pages, extract-images, extract-text, meta, pagemeta, rm, rotate, sign, uncompress, update-offsets, x2pdf. Trigger phrases: "compress PDF", "merge PDFs", "split PDF", "rotate pages", "extract images from PDF", "sign PDF", "PDF metadata", "convert to PDF".

pdfly CLI Skill

A pure-python CLI for PDF manipulation built on pypdf, fpdf2, and endesive.

Installation

pip install pdfly
# or with uv
uvx pdfly --help

Quick Reference

Command Description
pdfly compress IN OUT Lossless compression
pdfly cat IN [PAGES]... -o OUT Merge/split pages
pdfly rm IN [PAGES]... -o OUT Remove pages
pdfly rotate -o OUT IN DEG [PGRGS] Rotate pages
pdfly sign IN --p12 CERT [-o OUT] Sign PDF
pdfly check-sign IN --pem CERT Verify signature
pdfly meta IN [-o FORMAT] Show metadata
pdfly pagemeta IN IDX [-o FORMAT] Page details (0-based)
pdfly extract-images IN Extract images
pdfly extract-text IN Extract text
pdfly extract-annotated-pages IN [-o OUT] Extract annotated
pdfly uncompress IN OUT Decompress streams
pdfly update-offsets IN [-o OUT] Fix offsets
pdfly 2-up IN OUT 2-up layout
pdfly booklet IN OUT [-b FILE] [-c FILE] Booklet layout
pdfly x2pdf [FILES]... -o OUT Convert to PDF

Output Formats (meta/pagemeta)

-o text   # Default
-o json
-o yaml

Page Range Syntax

See references/page-ranges.md for full syntax including negative indices and strides.

PDF Signing

See references/sign.md for complete signing/verification workflow.

Rotate Command

The -o/--output option is required and must come before positional arguments:

pdfly rotate -o output.pdf input.pdf 90 "1-3"

See references/rotate.md for full examples.

Extract/Merge (cat)

See references/cat.md for complex merge/split operations.

Key Libraries

Library Purpose
pypdf PDF reading/writing, page manipulation
fpdf2 Creating PDFs from images/text
endesive PDF signing with PKCS12
pillow Image processing
cryptography Cryptographic operations

Exit Codes

  • 0 = Success
  • 1 = Error (file not found, invalid input, etc.)