Metadata-Version: 2.4
Name: pdf-mint
Version: 1.0.1
Summary: Local command-line toolkit to inspect, split, extract, delete, reorder, rotate, merge, and compress PDF files
License: MIT
Requires-Python: >=3.10
Requires-Dist: pillow==12.3.0
Requires-Dist: pydantic==2.13.5
Requires-Dist: pypdf==6.18.1
Provides-Extra: dev
Requires-Dist: fastapi==0.141.1; extra == 'dev'
Requires-Dist: httpx==0.28.1; extra == 'dev'
Requires-Dist: pymysql==1.2.0; extra == 'dev'
Requires-Dist: pytest-cov==7.0.0; extra == 'dev'
Requires-Dist: pytest==9.1.1; extra == 'dev'
Requires-Dist: python-multipart==0.0.32; extra == 'dev'
Requires-Dist: reportlab==4.4.10; extra == 'dev'
Requires-Dist: ruff==0.16.7; extra == 'dev'
Requires-Dist: sqlalchemy==2.0.52; extra == 'dev'
Requires-Dist: tomli==2.4.1; (python_version < '3.11') and extra == 'dev'
Requires-Dist: tzdata==2026.2; extra == 'dev'
Requires-Dist: uvicorn[standard]==0.53.0; extra == 'dev'
Provides-Extra: server
Requires-Dist: fastapi==0.141.1; extra == 'server'
Requires-Dist: pymysql==1.2.0; extra == 'server'
Requires-Dist: python-multipart==0.0.32; extra == 'server'
Requires-Dist: sqlalchemy==2.0.52; extra == 'server'
Requires-Dist: tomli==2.4.1; (python_version < '3.11') and extra == 'server'
Requires-Dist: tzdata==2026.2; extra == 'server'
Requires-Dist: uvicorn[standard]==0.53.0; extra == 'server'
Description-Content-Type: text/markdown

# pdf-mint

A local command-line toolkit for PDF files: page inspection, splitting, extraction, deletion, reordering, rotation, merging PDFs with JPG/PNG images, and size optimization. Everything runs on your machine; no file is uploaded anywhere.

## Installation

Requires Python 3.10 or newer.

```text
python -m pip install pdf-mint
```

## Commands

Every command accepts `--json` and then prints a single JSON result object to stdout; progress and errors go to stderr.

### Inspect

```text
pdf-mint capabilities --json
pdf-mint info INPUT.pdf --json
```

`capabilities` lists the supported operations and compression profiles. `info` reports the page count and detects encryption, digital signatures, interactive forms, or damage.

### Page operations

```text
pdf-mint split INPUT.pdf --each-page --output-dir OUTPUT_DIR --json
pdf-mint split INPUT.pdf --every 5 --output-dir OUTPUT_DIR --json
pdf-mint split INPUT.pdf --groups "1-3;4-8" --output-dir OUTPUT_DIR --json
pdf-mint extract INPUT.pdf --pages "3,1-2" --output OUTPUT.pdf --json
pdf-mint delete INPUT.pdf --pages "2,5" --output OUTPUT.pdf --json
pdf-mint organize INPUT.pdf --order "3,1-2" --rotate "1-2:90;3:180" --output OUTPUT.pdf --json
```

`split` writes one PDF per group plus a ZIP archive; add `--no-zip` to skip the archive, or `--profile`/`--target-size` to compress every output.

### Merge

```text
pdf-mint merge A.pdf PHOTO.jpg B.pdf --pages "1=3,1-2" --output OUTPUT.pdf --json
```

Merge accepts any mix of PDF and JPG/PNG files in the given order. `--pages INDEX=SELECTION` selects pages for a 1-based input position (PDF inputs only); repeat the option for additional inputs. Optional `--profile` and `--target-size` compress the result.

### Compress

```text
pdf-mint compress INPUT.pdf --profile lossless --output OUTPUT.pdf --json
pdf-mint compress INPUT.pdf --profile balanced --target-size 5MB --output OUTPUT.pdf --json
```

Profiles: `lossless` (deduplicate objects and compress streams only), `high`, `balanced` (default), and `small`, which re-encode embedded JPEG images at decreasing quality and resolution caps. With `--target-size`, the JSON result reports whether the target was met.

### Batch task

```text
pdf-mint run-job TASK.json --json
```

Executes a versioned JSON task file:

```json
{
  "schema_version": "1.0",
  "operation": "merge",
  "inputs": [
    {"path": "A.pdf", "pages": "3,1-2"},
    {"path": "photo.png", "pages": null}
  ],
  "output": "result.pdf",
  "options": {"compression_profile": "balanced", "target_size": "5MB"}
}
```

## Conventions

- Page numbers are 1-based. Selections keep the written order, ranges include both ends, and duplicate pages are rejected.
- Output files never overwrite the input or an existing file.
- `MB` means 1,000,000 bytes; `MiB` means 1,048,576 bytes.
- Compression cannot guarantee an arbitrary target size. Check `target_met` and the warnings in the JSON result instead of assuming success from the file's existence.

## Exit codes

| Code | Meaning |
| ---- | ------- |
| 0 | Success |
| 2 | Invalid parameters or unsupported input |
| 3 | Execution failure |
| 4 | Valid output written, but the requested target size was not met |
