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.3.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.3-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pdf_to_book-0.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 9ce8eee7ff5bfe6cc952366ffe3bcb080dd35ccaac320d444f2b22910e770f1b
MD5 ac1c7b92be789e83ae3f1832bcd62474
BLAKE2b-256 31ea9dae73dd09e82c76976ffd9af9665bff9f339011ac62c4c1eb97ed0aafdb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pdf_to_book-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.8 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 17a69ca5310c7652baeaf434d6aba37ec834fd54033c27e324661a6d93fef050
MD5 ae449d8a5f67798a52cf4a027edfdaf1
BLAKE2b-256 c579b10ef634c6340d774e87013b0d9639dd1b249ecd4641ad660e88d0bab0ae

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