Skip to main content

Convert design-heavy PDFs into print-friendly versions via hue-preserving lightness inversion.

Project description

print-friendly-pdf

Install

pip install pdf2print

Usage

pdf2print input.pdf
pdf2print input.pdf --dpi 300

Converts design-heavy PDFs (dark backgrounds, white text, colored charts) into print-friendly versions — without destroying chart colors.

Live: https://print-friendly-pdf.indyri.se

Why this exists

Dark-background PDFs are ink-expensive to print. Existing inverters do naive RGB inversion, which makes text readable but flips every chart color (red becomes cyan, orange becomes blue). This tool does neither-or:

  1. Hue-preserving lightness inversion. Lightness is inverted in HSL space, which reduces to a closed-form RGB operation: RGB' = RGB + (1 − max(RGB) − min(RGB)). White text becomes black, dark backgrounds become light, and saturated chart colors — which sit near mid-lightness — pass through nearly unchanged. Provably no clipping.

  2. Surgical page replacement. Only dark-detected pages are rasterized and replaced. Every other page keeps its original vector content — searchable, sharp, and small. A document with no dark pages is returned byte-identical.

Usage

CLI

python cli.py input.pdf [--dpi 150] [--no-invert]

Writes input_print.pdf alongside the input.

Web

Upload a PDF at the live URL. The converted PDF opens in a new tab with the browser's native print button. Chrome-first.

Known limitations

  • Light-panel preservation uses a size threshold. Large white content panels (cards, callout boxes) on dark pages are detected via connected-component analysis and preserved with their original colors. Regions below ~2% of page area (small icons, white text) invert with the page — by design. The threshold is conservative and fails open: if no region qualifies, the page inverts normally.
  • Dark-page detection uses corner sampling — centered dark panels on light pages are not detected (v1.5 adds AI classification)
  • Replaced pages lose their searchable text layer
  • 32MB file ceiling
  • Password-protected PDFs not supported

Stack

PyMuPDF, Pillow, numpy, Flask, Python 3.11 · Cloud Run backend · Vercel static frontend · GoDaddy CNAME

License

License

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

Dependency notice: This project uses PyMuPDF (fitz), which is licensed under the GNU AGPL v3. If you deploy this software as a network service, the AGPL requires you to make the complete source code available to users. This repository satisfies that requirement.

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

pdf2print-0.1.0.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

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

pdf2print-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file pdf2print-0.1.0.tar.gz.

File metadata

  • Download URL: pdf2print-0.1.0.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for pdf2print-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c8eac96deb74aac9a96575181de89a38f8ad8ba6ea9f86c37f02574663a9b62b
MD5 6cc2b83d2dfcdf9f277d009600219b9f
BLAKE2b-256 6853e7ba707bcbda180b02bfcbe8d2921bcab9816888dec35cff15aa380ef856

See more details on using hashes here.

File details

Details for the file pdf2print-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pdf2print-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for pdf2print-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b69f80f8747d77d7b2e0c7aa09325200a090a9e738d9f2547ad70b5c87bd489
MD5 3c5c4e478dbee3572b2e5c88a025cc07
BLAKE2b-256 a278b1c40c5d258fc53c597ee766b1209a3a8dce2eb673dfb47bc9e95f5d803e

See more details on using hashes here.

Supported by

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