Skip to main content

Scan PDF Cleaner CLI

PyPI version License: MIT Web Tool

A high-speed CLI utility and Python library to automatically detect and delete blank pages from scanned PDFs, remove whitespace borders, and clean multi-page document batches.

An online browser-based version is available at TheFreeConverter PDF Tools.


Features

  • Blank-Page Detection: Evaluates ink density and page bitmap intensity to accurately remove blank scan backs and separator pages.
  • Margin Auto-Cropping: Automatically trims outer scanner borders and non-printable margins.
  • Batch Processing: Clean entire folders of digitized contracts, scans, or receipts quickly.
  • Local Execution: Runs entirely on your local machine without third-party network requests.

Installation

pip install scan-pdf-cleaner-cli

Or install from source:

git clone https://github.com/The-Free-Converter/scan-pdf-cleaner.git
cd scan-pdf-cleaner
pip install -r requirements.txt
pip install -e .

Quickstart & CLI Usage

1. Remove blank pages from a PDF

scan-pdf-cleaner scanned_document.pdf
# Outputs: scanned_document_cleaned.pdf

2. Remove blank pages AND crop margins

scan-pdf-cleaner document.pdf --crop -o ./clean_doc.pdf

3. Adjust blank-page sensitivity threshold

# Higher threshold (e.g. 1.0) considers pages with light scanner noise as blank
scan-pdf-cleaner document.pdf --threshold 1.0

Python API Usage

from scan_pdf_cleaner import remove_blank_pages, crop_pdf_margins

# Remove blank pages
retained, removed = remove_blank_pages("scanned_batch.pdf", "output_cleaned.pdf")
print(f"Kept {retained} pages; discarded {removed} blank pages.")

# Crop margins
crop_pdf_margins("output_cleaned.pdf", "final_cropped.pdf", margin_pt=36.0)

Online Web Tools

Browser-based PDF processing tools:


License

This project is licensed under the MIT License - see the LICENSE file for details.

Download files

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

Source Distribution

scan_pdf_cleaner_cli-1.0.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

scan_pdf_cleaner_cli-1.0.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file scan_pdf_cleaner_cli-1.0.0.tar.gz.

File metadata

  • Download URL: scan_pdf_cleaner_cli-1.0.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for scan_pdf_cleaner_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 49c24635ed66527e3534214f7c7824da75240c542eb070bcf617f0e1e81d78e0
MD5 c6d67cf16f7683f7f6cc9f3e1e865937
BLAKE2b-256 2ca4971b2706023db96aa4811e4b2f32639294d8c03a6a458587b321b37b412c

See more details on using hashes here.

File details

Details for the file scan_pdf_cleaner_cli-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for scan_pdf_cleaner_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5febf48b26a23f2f37893dac8b31c6203d3610a857a2aca2e860a5ad7fe7ab11
MD5 f1abbca69f1594a1cbddb7c20e521751
BLAKE2b-256 1bc2fa31dd089408c5cb6961839346228407db8a91a87386451870fdcc88e89e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

Supported by

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