Skip to main content

CLI + Python API for batch compressing PDFs with iLovePDF.com

Project description

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")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdf_compressor-0.4.0.tar.gz (296.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pdf_compressor-0.4.0-py3-none-any.whl (415.1 kB view details)

Uploaded Python 3

pdf_compressor-0.4.0-py2.py3-none-any.whl (14.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pdf_compressor-0.4.0.tar.gz.

File metadata

  • Download URL: pdf_compressor-0.4.0.tar.gz
  • Upload date:
  • Size: 296.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.19

File hashes

Hashes for pdf_compressor-0.4.0.tar.gz
Algorithm Hash digest
SHA256 7e2f3052762999062d09368a0f8c04bcb230b7eaeee32e55293c9960d5f5562b
MD5 5af50138f83783219ff0d8f0c1ed32fc
BLAKE2b-256 37871b37b306e42f607a4165b981608bf0f5ad3f61e67a776d2ff514fd488ec1

See more details on using hashes here.

File details

Details for the file pdf_compressor-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pdf_compressor-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5ef98f60ddff23d8d721c981bfed504fa8bd5cc778cd19d3846152a6deeded7
MD5 c161f6d918b3bd0d64e04de524158994
BLAKE2b-256 5dcc73e2072bbbeb08e1dc76da99d49ee206e9c778eba1a2e56215c79921e26c

See more details on using hashes here.

File details

Details for the file pdf_compressor-0.4.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pdf_compressor-0.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3bd0634827242e3f999b969230ba1cd69577028085dd8f909c111d399a951b1b
MD5 8bdc3c2492c856c9d805a2c7b68cfcf2
BLAKE2b-256 6253209ddc1a7519a02f7c42e9524a7df1f1e560f50b8ffb6e71fdd1c8831dd9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page