Skip to main content

Lightweight Python package for converting a pdf into a print-ready book format.

Project description

pdf-to-book

Lightweight Python package for converting a pdf into a print-ready book format. Takes in portrait orientation pdf file pages and puts two pages onto each side of paper. Handles imposition for easy ordering of pages after folding/cutting (2-up, duplex ready layout)

Features

  • Supports letter and A4 print paper sizes
  • Adjustable gutter and margin to account for space taken up by binding
  • Adjustable zoom level
  • Optional line between pages indicating where to fold/cut

Install dependencies:

pip install PyMuPDF

Install pdf-to-book:

pip install pdf-to-book

Quickstart

If your python Scripts folder is included in PATH, you can directly call pdf-to-book as:

pdf-to-book input.pdf output.pdf

Alternatively you can call it via python:

python -m pdf_to_book input.pdf output.pdf

General usage

usage: pdf-to-book [-h] [--paper PAPER] [--gutter-mm GUTTER_MM] [--margin-mm MARGIN_MM] [--zoom ZOOM] [--line] input output

positional arguments:
  input                 input PDF
  output                output PDF (2-up, duplex-ready)

options:
  -h, --help            show this help message and exit
  --paper PAPER         paper size: 'auto' (default), 'letter', or 'a4'
  --gutter-mm GUTTER_MM
                        inner gutter in mm (default 6 mm)
  --margin-mm MARGIN_MM
                        outer/top/bottom margin in mm (default 4 mm)
  --zoom ZOOM           page zoom factor (e.g. 1.2 = 120%). Default 1.0
  --line                draw vertical fold/cut guide line at center

Example

See the example folder for a conversion of the first four pages of Fyodor Dostoevsky's "Notes from the Underground"

Here are screenshots resulting from the following command:

pdf-to-book --zoom 1.25 --line input.pdf output.pdf

input.pdf

output.pdf

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

pdf_to_book-0.0.2.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

pdf_to_book-0.0.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file pdf_to_book-0.0.2.tar.gz.

File metadata

  • Download URL: pdf_to_book-0.0.2.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for pdf_to_book-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1124d62efa1638539a9420dde32f033829919a7ca936293f1fc460616b2609f7
MD5 85a94cafea6cf65afc58b00aa2861e32
BLAKE2b-256 fab0f2eb96d35e43da5598ba3144874ab8106409e00d8000e454e9e56fe082a7

See more details on using hashes here.

File details

Details for the file pdf_to_book-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pdf_to_book-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for pdf_to_book-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2ab09380703d87efaa37ffa48000c45f8b21c86a0d6fb2b8ea1fd621814e29ad
MD5 2e55aa35f5f684f969b11807d4c3d5c9
BLAKE2b-256 ffc60986a849da717b839ef581e1e1fa459b66ae16b83d2aca2e6c1c4e8696ac

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