Skip to content

quickbulletins/bookletize

Repository files navigation

bookletize

Turn ordinary PDFs into press-ready folded booklets.

CI

bookletize reorders and places the pages of a PDF so that when you print it duplex, fold it, and (optionally) staple it, the pages read in the right order. That's imposition — the oldest problem in printing, and somehow still unsolved on npm.

An 8-page half-letter booklet on two letter sheets:

  sheet 1  front: [ 8 │ 1 ]      back: [ 2 │ 7 ]
  sheet 2  front: [ 6 │ 3 ]      back: [ 4 │ 5 ]

Fold the stack in half → pages 1,2,3,4,5,6,7,8. Magic, but it's just arithmetic:
  sheet s of N pages (N a multiple of 4, 0-indexed):
  front: [ N−2s, 1+2s ]   back: [ 2+2s, N−1−2s ]
  • Zero-dependency core. The mappings are pure functions: page count in, sheet layout out.
  • Optional PDF applier. The bookletize/pdf entry point applies a mapping to real PDF bytes (via @cantoo/pdf-lib, a maintained pdf-lib fork), draws dashed fold guides, and pads to a multiple of 4 with blanks.
  • Golden-file tested. Every mapping is locked by tests; the letter-size layouts have been print-verified on physical duplex printers.
  • MIT licensed.

Install

npm install bookletize        # pnpm add / yarn add / bun add

CLI

# Half-letter saddle booklet on letter landscape sheets:
npx bookletize booklet service.pdf -o booklet.pdf

# Letter tri-fold (outside panels 5,6,1 / inside 2,3,4, with flap allowance):
npx bookletize trifold flyer.pdf -o trifold.pdf

Options: --sheet letter-landscape|legal-landscape|a4-landscape|a3-landscape|tabloid-landscape (booklet), --bleed <points> + --crop-marks (booklet trim workflow — print on oversized stock, cut at the marks), --two-up (stack two copies per sheet — flips on LONG edge), --no-guides, -o/--out (defaults to <input>.<command>.pdf).

Then print duplex, "flip on short edge" for booklets. (This one printer-dialog setting causes more upside-down back pages than everything else combined — see PRINTING.md.)

API

import { imposeSaddle } from "bookletize";

// Pure math — which logical page lands on which sheet face and slot.
// Pads to a multiple of 4; blank (padding) slots are null.
const sheets = imposeSaddle(5);
// → [
//     { front: [null, 1], back: [2, null] },   // pages 6–8 of the padded book are blank
//     { front: [null, 3], back: [4, 5] },
//   ]
import { applySaddle } from "bookletize/pdf";

// Real PDFs in, imposed sheet faces out (Uint8Array).
// bleed/cropMarks are the trim workflow, twoUp is step-and-repeat — three
// independent options; omit all three for a plain booklet.
const bytes = await applySaddle(pdfBytes, {
  sheet: "letter-landscape",   // or "legal-landscape" | "a4-landscape" | "a3-landscape", or { width, height } in points
  foldGuides: true,            // dashed tick marks on the spine (default true)
  bleed: 9,                    // pages arrive at trim+bleed; scale locks to 1 (optional)
  cropMarks: true,             // black hairlines at the trim corners (optional)
  twoUp: true,                 // stack two copies per sheet — flips on LONG edge (optional)
});

Lower-level entry points (imposeSaddlePdf, imposeTrifoldPdf, imposeTwoUpPdf, fitSlot, bleedLayout, SHEETS, TRIFOLD_LETTER) are exported from bookletize/pdf for callers who already hold a PDFDocument.

What it does / doesn't do

Does Doesn't
Saddle-fold booklets (half-letter, half-legal, A5, A4) Render or lay out your content
Tri-folds with correct narrow-flap allowance Edit PDF content
Fold guides, crop marks + bleed, 2-up, blank padding, page-slot math Compress, encrypt, or sign PDFs
(v0.2) creep compensation, cut-and-stack Anything that isn't imposition

That last row is a promise: scope is imposition only. Issues asking for rendering or layout features will be closed kindly. This keeps the library small enough to trust and small enough for one maintainer to keep excellent.

Why this exists

We build QuickBulletins, which turns church worship bulletins into folded, stapled booklets every week. The imposition layer had no home on npm — prepress RIP software costs four figures and the classic desktop tools are abandoned — so we extracted ours. If you're printing zines, concert programs, wedding orders of service, or school booklets: it's the same arithmetic. Enjoy.

Roadmap

  • 0.1 — saddle + tri-fold (letter/legal), CLI, fold guides ← you are here
  • 0.2 — A4/A5 (landed), crop marks + bleed (landed), 2-up (landed), cut-and-stack, creep/shingling compensation
  • 0.3 — browser build + a free in-browser Booklet this PDF tool (your PDF never leaves your machine)
  • 1.0 — API freeze, semver promise

Scope detail, build order, and acceptance gates: ROADMAP.md.

License

MIT © Heavenly Technologies LLC

About

Turn ordinary PDFs into press-ready folded booklets — saddle and tri-fold imposition with fold guides

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors