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.8+ 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-pdfs 'ignore' What to do when no input PDFs received. One of 'ignore' or 'error', former exits 0, latter throws 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'.

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.2.0.tar.gz (12.0 kB view details)

Uploaded Source

File details

Details for the file pdf-compressor-0.2.0.tar.gz.

File metadata

  • Download URL: pdf-compressor-0.2.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.10

File hashes

Hashes for pdf-compressor-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f72f8c685c7c4af1df301b8002ecfc3105865e1b289682c10d7bc13c1aef5a78
MD5 7e732f516d36a8891238965a225a4e7b
BLAKE2b-256 bc4122b7c487c8ab2e90ea49adb265b5f142516d4242cf46d33ca1dbaccc9028

See more details on using hashes here.

Supported by

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