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.

Metadata

Release files for scan-pdf-cleaner-cli 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scan-pdf-cleaner-cli 1.0.0
File Size Uploaded
scan_pdf_cleaner_cli-1.0.0.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scan-pdf-cleaner-cli 1.0.0
File Interpreter ABI Platform
scan_pdf_cleaner_cli-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.5 kB

Release files / scan_pdf_cleaner_cli-1.0.0.tar.gz

Download URL scan_pdf_cleaner_cli-1.0.0.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
49c24635ed66527e3534214f7c7824da75240c542eb070bcf617f0e1e81d78e0
BLAKE2b-256 checksum
How to use checksums
2ca4971b2706023db96aa4811e4b2f32639294d8c03a6a458587b321b37b412c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / scan_pdf_cleaner_cli-1.0.0-py3-none-any.whl

Download URL scan_pdf_cleaner_cli-1.0.0-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5febf48b26a23f2f37893dac8b31c6203d3610a857a2aca2e860a5ad7fe7ab11
BLAKE2b-256 checksum
How to use checksums
1bc2fa31dd089408c5cb6961839346228407db8a91a87386451870fdcc88e89e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page