← 返回命令列表

Linux command

qpdf 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Decrypt PDF

qpdf --decrypt [input.pdf] [output.pdf]

Linearize PDF

qpdf --linearize [input.pdf] [output.pdf]

Merge PDFs

qpdf --empty --pages [file1.pdf] [file2.pdf] -- [output.pdf]

Extract specific pages

qpdf --empty --pages [input.pdf] [1-5,10] -- [output.pdf]

Rotate pages

qpdf [input.pdf] [output.pdf] --rotate=[+90:1-5]

Compress streams

qpdf --compress-streams=y [input.pdf] [output.pdf]

Check PDF structure

qpdf --check [input.pdf]

Remove password

qpdf --password=[pass] --decrypt [encrypted.pdf] [output.pdf]

Replace input file

qpdf --replace-input --linearize [input.pdf]

Split PDF

qpdf --split-pages [input.pdf] [output_%d.pdf]

Add password protection

qpdf --encrypt [user_pass] [owner_pass] 256 -- [input.pdf] [output.pdf]

说明

qpdf is a command-line tool for structural, content-preserving transformations of PDF files. Unlike tools that rasterize or re-render, qpdf manipulates PDF structure directly. Primary uses include encryption management (decrypting, encrypting, changing passwords), linearization (optimizing for web delivery), and page manipulation (merging, splitting, reordering). Page specification uses flexible syntax: ranges (1-10), specific pages (1,3,5), reverse (z-1), and rotation (1-5:90). Multiple files can contribute pages using --pages with file:range pairs. The --check option validates PDF structure without modifying, useful for identifying damaged files. JSON output exposes internal structure for analysis or custom processing. QDF mode produces "normalized" PDFs that can be edited with text editors, enabling debugging and manual fixes. Stream decompression reveals human-readable content. Linearization reorganizes PDFs for efficient byte-serving over HTTP, enabling page-at-a-time loading without downloading entire files.

参数

--decrypt
Remove encryption.
--linearize
Optimize for web viewing.
--encrypt _user_ _owner_ _bits_ --
Add encryption (bits: 40, 128, or 256).
--pages _spec_
Page selection specification.
--collate=_n_
Collate pages from multiple files rather than concatenating.
--rotate _+|-__angle_:_pages_
Rotate pages.
--empty
Use empty PDF as input base.
--replace-input
Overwrite input file with output instead of writing to a separate file.
--check
Check PDF structure.
--show-encryption
Display encryption details.
--password _PASS_
Input file password.
--compress-streams=_y|n_
Compress/decompress streams.
--object-streams=_mode_
Control object streams: preserve, disable, or generate.
--decode-level _LEVEL_
Stream decoding: none, generalized, specialized, all.
--normalize-content=_y|n_
Normalize content streams.
--split-pages=_n_
Split into n-page files.
--overlay _file_
Overlay pages from file.
--underlay _file_
Underlay pages from file.
--flatten-rotation
Make rotation permanent.
--flatten-annotations=_parameter_
Flatten annotation appearances.
--coalesce-contents
Combine multiple content streams per page into one.
--optimize-images
Use efficient compression for images.
--remove-unreferenced-resources=_auto|yes|no_
Remove unused resources from page dictionaries.
--json
Output PDF structure as JSON.

FAQ

What is the qpdf command used for?

qpdf is a command-line tool for structural, content-preserving transformations of PDF files. Unlike tools that rasterize or re-render, qpdf manipulates PDF structure directly. Primary uses include encryption management (decrypting, encrypting, changing passwords), linearization (optimizing for web delivery), and page manipulation (merging, splitting, reordering). Page specification uses flexible syntax: ranges (1-10), specific pages (1,3,5), reverse (z-1), and rotation (1-5:90). Multiple files can contribute pages using --pages with file:range pairs. The --check option validates PDF structure without modifying, useful for identifying damaged files. JSON output exposes internal structure for analysis or custom processing. QDF mode produces "normalized" PDFs that can be edited with text editors, enabling debugging and manual fixes. Stream decompression reveals human-readable content. Linearization reorganizes PDFs for efficient byte-serving over HTTP, enabling page-at-a-time loading without downloading entire files.

How do I run a basic qpdf example?

Run `qpdf --decrypt [input.pdf] [output.pdf]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --decrypt do in qpdf?

Remove encryption.