Convert a series of image files, or data from a scanner, to a multi-page bilevel (i.e. black and white) PDF with optional OCR. makebwpdf can also fix the incorrect page positioning for A4 and A5 scans produced by the Brother MFC-L2710DW multifunction device.
Requires: econvert, tiffcp, tiff2pdf, ocrmypdf, pdftk, and PIL.
By Pontus Lurcock, 2017-2023 (pont -at- talvi.net). Released under the MIT license (see accompanying file LICENSE for details).
On Ubuntu 20.04, the requirements can be installed with
sudo apt install python3-pip python3-pil exactimage libtiff-tools ocrmypdf pdftk
The file makebwpdf.py can be run directly. It can also be installed by
running python3 -m pip install makebwpdf/ from the parent directory of
the repository, which will make the command makebwpdf available on the
execution path. python3 -m pip install --user makebwpdf/ will install it
for the current user only.
To uninstall, use python3 -m pip uninstall makebwpdf.
usage: makebwpdf [-h] [--brightness BRIGHTNESS] [--output FILENAME] [--append]
[--papersize ISO_NAME] [--tempdir DIRECTORY]
[--rotate DEGREES] [--languages ISO_639_2_CODES] [--scan]
[--device SANE_DEVICE_NAME] [--correct-position] [--invert]
[--export-repositioned FILENAME] [--colour]
[input_files [input_files ...]]
positional arguments:
input_files input filename
optional arguments:
-h, --help show this help message and exit
--brightness BRIGHTNESS, -b BRIGHTNESS
Brightness adjustment (default: 0)
--output FILENAME, -o FILENAME
Output filename (required, unless -e supplied)
--append, -a Append page(s) to existing PDF output file
--papersize ISO_NAME, -p ISO_NAME
Paper size (A4, A5, or A6)
--tempdir DIRECTORY, -t DIRECTORY
Use DIRECTORY as temporary directory
--rotate DEGREES, -r DEGREES
Rotate pages by the given number of degrees
--languages ISO_639_2_CODES, -l ISO_639_2_CODES
OCR the PDF in these languages (e.g. 'eng+deu')
--scan, -s Acquire image from scanner (ignores input files)
--device SANE_DEVICE_NAME, -d SANE_DEVICE_NAME
Scanner device (implies --scan)
--correct-position, -c
Correct positioning of flatbed scans from Brother
MFC-L2710DW
--invert, -i Invert colours
--export-repositioned FILENAME, -e FILENAME
Don't convert to bilevel or make a PDF. Instead,
export first repositioned page to specified file.
--colour, -C Make initial scan in colour (useful with -e)