Metadata-Version: 2.3
Name: pdf-compressor
Version: 0.4.0
Summary: CLI + Python API for batch compressing PDFs with iLovePDF.com
Keywords: cli,compression,ilovepdf,pdf
Author: Janosh Riebesell
Author-email: Janosh Riebesell <janosh.riebesell@gmail.com>
License: MIT License
         
         Copyright (c) 2021 Janosh Riebesell
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         The software is provided "as is", without warranty of any kind, express or
         implied, including but not limited to the warranties of merchantability,
         fitness for a particular purpose and noninfringement. In no event shall the
         authors or copyright holders be liable for any claim, damages or other
         liability, whether in an action of contract, tort or otherwise, arising from,
         out of or in connection with the software or the use or other dealings in the
         software.
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: requests>=2.25.0
Requires-Dist: pandas ; extra == 'stats'
Requires-Dist: pytest ; extra == 'test'
Requires-Dist: pytest-cov ; extra == 'test'
Requires-Python: >=3.11
Project-URL: Homepage, https://github.com/janosh/pdf-compressor
Project-URL: Package, https://pypi.org/project/pdf-compressor
Provides-Extra: stats
Provides-Extra: test
Description-Content-Type: text/markdown

<p align="center">
  <img src="https://raw.githubusercontent.com/janosh/pdf-compressor/main/assets/pdf-compressor.svg" alt="PDF Compressor" height=150>
</p>

<h3 align="center">

[![Tests](https://github.com/janosh/pdf-compressor/workflows/Tests/badge.svg)](https://github.com/janosh/pdf-compressor/actions)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/janosh/pdf-compressor/main.svg)](https://results.pre-commit.ci/latest/github/janosh/pdf-compressor/main)
[![PyPI](https://img.shields.io/pypi/v/pdf-compressor?logo=pypi&logoColor=white)](https://pypi.org/project/pdf-compressor)
[![Requires Python 3.11+](https://img.shields.io/badge/Python-3.11+-blue.svg?logo=python&logoColor=white)](https://python.org/downloads)
[![PyPI Downloads](https://img.shields.io/pypi/dm/pdf-compressor?logo=icloud&logoColor=white)](https://pypistats.org/packages/pdf-compressor)

</h3>

Command line PDF compression powered by the free [iLovePDF API](https://developer.ilovepdf.com).

**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

```sh
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>):

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

Then start compressing!

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