pdfbook2
Generate printable PDF booklets
TLDR
Create a booklet named file-book.pdf with sane defaults
Create a booklet with the paper size set to A4
Create a booklet that has the inner margin reduced to 50 pixels (default = 150px)
Organize a large file with print signatures for binding into a larger booklet (signatures must be divisible by 4)
SYNOPSIS
pdfbook2 [OPTIONS] <input-pdf> [<output-pdf>]
PARAMETERS
-h, --help
Show program's help message and exit.
-v, --version
Show program's version number and exit.
-o <file>, --output <file>
Specify the output file name. Defaults to input-pdf_book.pdf.
-p <pagespec>, --pages <pagespec>
Select specific pages to include (e.g., 1-10, odd, even).
-s <size>, --paper <size>
Set the paper size for the output PDF (e.g., a4, letter).
-m <margin>, --margin <margin>
Define margins around pages in millimeters (e.g., 10). Can be a single value for all sides, or left:top:right:bottom.
-r, --rotate
Automatically rotate pages by 90 degrees if necessary to fit the layout.
-d, --duplex
Assume duplex printing. Pages will be reordered for double-sided output. This is often the default behavior.
--no-duplex
Do not assume duplex printing; produce output suitable for single-sided printing.
-q, --quiet
Suppress verbose output and warnings during processing.
--odd-front
Ensure odd-numbered pages are on the front side of each printed sheet.
--even-front
Ensure even-numbered pages are on the front side of each printed sheet.
--landscape
Force the output pages to be in landscape orientation.
--portrait
Force the output pages to be in portrait orientation.
--no-crop
Prevent cropping of input pages to their media box, preserving original page dimensions.
--sheet-align <align>
Specify alignment of pages on the sheet (center, top, bottom).
--sheet-size <width>x<height>
Define a custom sheet size in millimeters (e.g., 210x297 for A4).
--sheet-orientation <orientation>
Set custom sheet orientation (portrait or landscape).
--sheet-margins <margin>
Apply a uniform margin to all four sides of the sheet.
--booklet-layout <layout>
Choose the layout of pages on the sheet (e.g., 2-up, 4-up, 1-up-left, etc.).
--bind-left, --bind-right, --bind-top, --bind-bottom
Specify the binding edge for the booklet, affecting imposition.
--inner-margin <margin>
Add an additional margin to the inner side of the booklet.
--outer-margin <margin>
Add an additional margin to the outer side of the booklet.
--front-margin <margin>
Add an additional margin to the front side of the booklet.
--back-margin <margin>
Add an additional margin to the back side of the booklet.
DESCRIPTION
pdfbook2 is a versatile command-line utility designed to transform standard PDF documents into booklet format, suitable for printing and binding. It rearranges the pages of a given PDF file into a 2-up (or other specified layouts) imposition scheme, ensuring that when printed duplex and folded, the pages appear in the correct sequential order. This tool automatically handles page ordering, rotation for optimal layout, and adds customizable margins to facilitate proper printing and trimming.
It is particularly useful for users who need to print long documents in a compact, reader-friendly booklet style from standard PDF viewers. By preparing the PDF for duplex printing, pdfbook2 simplifies what would otherwise be a complex manual rearrangement of pages, making it accessible even to those without specialized desktop publishing software.
CAVEATS
pdfbook2 relies on Python and specific libraries like pypdf (or older PyPDF2) and reportlab. Ensure these dependencies are installed for the command to function correctly. The exact page ordering for duplex printing can vary slightly depending on your printer's duplex mechanism; it's advisable to perform a test print with a few pages to confirm the correct output orientation before printing an entire document.
DEPENDENCIES
pdfbook2 is written in Python. It typically requires the pypdf (or older PyPDF2) library for PDF manipulation and the reportlab library for generating new PDF content. These can usually be installed using pip:
pip install pypdf reportlab
USAGE EXAMPLE
To create a booklet from a file named document.pdf, outputting to document_book.pdf on A4 paper with a 10mm margin:
pdfbook2 -s a4 -m 10 -o document_book.pdf document.pdf
For a more specific duplex booklet, assuming input.pdf:
pdfbook2 --duplex --output booklet.pdf input.pdf
HISTORY
pdfbook2 is a modern Python-based reincarnation and enhancement of earlier tools like pdfbook, which aimed to simplify the process of creating printable PDF booklets. Its development focuses on providing a robust, flexible, and easy-to-use command-line interface for PDF imposition, abstracting away the complexities of page reordering and layout calculations. It leverages modern Python PDF libraries to offer improved stability and feature sets, making it a valuable tool for anyone needing to prepare PDFs for professional-looking booklet printing without relying on complex graphical software.