Crates.io | pdftrim |
lib.rs | pdftrim |
version | |
source | src |
created_at | 2025-02-05 15:07:07.480509+00 |
updated_at | 2025-02-14 13:22:07.442949+00 |
description | Removes white margins from PDF files without inflating file sizes |
homepage | |
repository | https://github.com/ciffelia/pdftrim |
max_upload_size | |
id | 1544102 |
Cargo.toml error: | TOML parse error at line 22, column 1 | 22 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Removes white margins from PDF files without inflating file sizes.
pdftrim is a tool to trim white margins from PDF files. It is designed to be fast and efficient, producing minimal output file sizes.
This tool uses Ghostscript to calculate the bounding boxes for each page in the input PDF file. It then generates an output PDF file with updated CropBox values to remove white margins.
While similar to the pdfcrop script in the TeX Live distribution, this tool offers a key advantage: it maintains minimal output file sizes. The traditional pdfcrop processes PDFs by importing them into TeX documents and converting them back to PDF using pdfTeX, XeTeX, or LuaTeX, which often results in significantly larger files. In contrast, this tool directly modifies the PDF dimension data, avoiding file size inflation.
Prebuilt binaries are available for Linux, macOS, and Windows on the latest release page.
You need to have Ghostscript installed on your system.
brew install ghostscript # macOS
sudo apt install ghostscript # Ubuntu
sudo yum install ghostscript # CentOS
sudo dnf install ghostscript # Fedora
With Rust installed:
cargo install pdftrim
You need to have Ghostscript installed on your system.
With Rust and cargo-binstall installed:
cargo binstall pdftrim
You need to have Ghostscript installed on your system.
Usage: pdftrim [OPTIONS] [input[.pdf]] [output file]
Arguments:
[input[.pdf]]
The input PDF file to crop.
The `.pdf` extension is optional.
[output file]
The output PDF file to write.
If not specified, the input file name is used with `-crop.pdf` appended. Existing files will be overwritten.
Options:
--gscmd <command>
The Ghostscript command to use.
If not specified, it will search for Ghostscript in the system.
--generate-completion <shell>
If provided, outputs the completion file for given shell and exits
[possible values: bash, elvish, fish, powershell, zsh]
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
Verbose output can be enabled by setting the `RUST_LOG` environment variable to `debug`.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.