Skip to main content

PDF Compressor

Tests pre-commit.ci status PyPI Requires Python 3.11+ PyPI Downloads

Command line PDF compression powered by the free iLovePDF API.

Why? iLovePDF delivers the best PDF compression I've seen but their web UI doesn't support automation and can be cumbersome when dealing with many files.

Installation

pip install pdf-compressor

Usage

First, tell pdf-compressor your iLovePDF API key (if you haven't yet, get one by signing up at https://developer.ilovepdf.com/signup):

pdf-compressor --set-api-key project_public_7c854a9db0...

Then start compressing!

pdf-compressor **/*.pdf

Options

Flags Default Description
-i/--inplace False Whether to compress PDFs in place.
-s/--suffix '-compressed' String to append to the filename of compressed PDFs. Mutually exclusive with --inplace.
--cl/--compression-level 'recommended' How hard to squeeze the file size. One of 'low', 'recommended', 'extreme'. 'extreme' noticeably degrades quality of embedded bitmap images.
--set-api-key Set the public key needed to authenticate with the iLovePDF API. You only need to do this once to start using.
--report-quota Report the number of remaining file operations in the current billing cycle for the stored iLovePDF API key.
--debug False When true, iLovePDF won't process the request but only reports the parameters that would have been sent to the server.
--verbose False When true, progress will be reported while tasks are running.
-v/--version Get the version number of pdf-compressor.
--on-no-files 'ignore' What to do when no input PDFs received. One of 'ignore' or 'error', former exits 0, latter raises ValueError. Can be useful when using pdf-compressor in shell scripts.
--on-bad-files 'error' How to behave when receiving input files that don't appear to be PDFs. One of 'error', 'warn', 'ignore'. Error type will be ValueError. Code used to check if something is PDF: filepath.lower().endswith(".pdf")

Metadata

Release files for pdf-compressor 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pdf-compressor 0.4.0
File Size Uploaded
pdf_compressor-0.4.0.tar.gz 296.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pdf-compressor 0.4.0
File Interpreter ABI Platform
pdf_compressor-0.4.0-py3-none-any.whl Python 3 none any Details
pdf_compressor-0.4.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 726.7 kB

Release files / pdf_compressor-0.4.0.tar.gz

Download URL pdf_compressor-0.4.0.tar.gz
Size 296.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7e2f3052762999062d09368a0f8c04bcb230b7eaeee32e55293c9960d5f5562b
BLAKE2b-256 checksum
How to use checksums
37871b37b306e42f607a4165b981608bf0f5ad3f61e67a776d2ff514fd488ec1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.19

Release files / pdf_compressor-0.4.0-py3-none-any.whl

Download URL pdf_compressor-0.4.0-py3-none-any.whl
Size 415.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d5ef98f60ddff23d8d721c981bfed504fa8bd5cc778cd19d3846152a6deeded7
BLAKE2b-256 checksum
How to use checksums
5dcc73e2072bbbeb08e1dc76da99d49ee206e9c778eba1a2e56215c79921e26c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.19

Release files / pdf_compressor-0.4.0-py2.py3-none-any.whl

Download URL pdf_compressor-0.4.0-py2.py3-none-any.whl
Size 14.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
3bd0634827242e3f999b969230ba1cd69577028085dd8f909c111d399a951b1b
BLAKE2b-256 checksum
How to use checksums
6253209ddc1a7519a02f7c42e9524a7df1f1e560f50b8ffb6e71fdd1c8831dd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.19

Release history Release notifications | RSS feed

This release

0.4.0 This release

3 release files

0.2.1

1 release file

0.2.0

1 release file

0.1.9

1 release file

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page