Skip to main content
http://badge.fury.io/py/scanpdf.png http://pypip.in/d/scanpdf/badge.png

If you’re looking for a simple way to use a multi-page scanner and get your document into a PDF in Linux without any proprietary or commercial software, then ScanPDF might be the solution. I wrote it to quickly take the Linux SANE scanner system output image files, and process them into usable PDFs. By usable, I mean PDFs that maintain their original scanned resolution, omit blank pages (if you’re scanning in duplex mode, for example), preserve color unless the original is greyscale/black and white, in which case they are intelligently down-converted to B/W PDFs to save space.

Features

  • Uses SANE/scanadf to automatically scan to multi-page compressed PDFs

  • Integrates with ScanBd to respond to hardware button presses

  • Automatically removes blank pages.

  • Scans in color, and automatically down-converts into 1-bit B/W image for text/greyscale images

  • Auto-crops to the proper page size.

Usage:

The simplest way to use this is:

scanpdf scan pdf <pdffile>

This will first perform the scan, and then the conversion to PDF. If you want to split up the scan and the PDF conversion into two separate invocations (for reasons clarified below), then you can do:

scanpdf --tmpdir=tmp scan
scanpdf --tmpdir=tmp pdf <pdffile>

One reason for the separation might be if you want to keep scanning documents (very quick) while the post-processing (slower) for the PDF conversion is taking place in the background. For instance, if you’re using the hardware button on the scanner to initiate scans (as detailed in this document), then you want to return immediately after the scan instead of waiting for the full conversion to PDF has taken place.

You can optionally use the following switches to control if you’re putting pages face up or face down in the auto document feeder, if you want to skip the blank page processing, adjust the blank page detection threshold, or add additional post-processing using unpaper:

--dpi=<dpi>                 DPI to scan in [default: 300]
--face-up=<true/false>      Face-up scanning [default: True]
--keep-blanks               Don't check for and remove blank pages
--blank-threshold=<ths>     Percentage of white to be marked as blank [default: 0.97]
--post-process              Run unpaper to deskew/clean up

Right now, I’m assuming this is getting called via ScanBD, so I don’t have the option to manually specify the scanner. If you really want to use this standalone, for now, please just set the SCANBD_DEVICE environment variable to your scanner device name before running this script.

Installation

$ pip install scanpdf

Requires ImageMagick and SANE to be installed, for the command line tools:

  • convert

  • identify

  • ps2pdf

  • scanadf

Also requires epstopdf.

Disclaimer

The software is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

Metadata

Release files for scanpdf 0.3.1

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

Source distribution (sdist)

Source distribution for scanpdf 0.3.1
File Size Uploaded Provenance
scanpdf-0.3.1.tar.gz 13.0 kB Without provenance Details

Release files / scanpdf-0.3.1.tar.gz

Download URL scanpdf-0.3.1.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2f7d64d4a9ea0bffbe0946bc03011d2305904e74658f4987723eaac08bd1bf20
BLAKE2b-256 checksum
How to use checksums
c0ce7aa617a7a6c4a11a8f80ff4d73f47b8e3720f0203ed62bb19a0a32386c8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for scanpdf 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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