NPM module for creating PDF booklets, based on jywarren/bookletize.js.
Rewritten as a NPM module.
npm install
For creating a pdf booklet that duplex prints along the short edge
import { shortEdge } from ''
imoprt fs from 'fs'
const srcFile = fs.readFileSync('input.pdf')
const { booklet, saved } = await shortEdge(srcFile)
fs.saveFileSync('output-short-edge.pdf', saved)
For creating a pdf booklet that duplex prints along the long edge
import { longEdge } from ''
imoprt fs from 'fs'
const srcFile = fs.readFileSync('input.pdf')
const { booklet, saved } = await longEdge(srcFile)
fs.saveFileSync('output-long-edge.pdf', saved)
import { createBookPDF } from ''
imoprt fs from 'fs'
const srcFile = fs.readFileSync('input.pdf')
const { booklet, saved } = await createBookPDF(srcFile)
fs.saveFileSync('output-short-edge.pdf', saved)
The object returned from createBookPDF
contains both a raw
PDFDocument { booklet }
and a saved { saved }
version. The booklet
can be manipuated further, where as saved
is the
array of bytes that can be written to file or downloaded as a Blob.
Primarily for rotating every other page for duplex printing along the "long-edge".
import { createBookPDF, rotatePDF } from ''
imoprt fs from 'fs'
const srcFile = fs.readFileSync('input.pdf')
const { booklet } = await createBookPDF(srcFile)
const { booklet, saved } = await rotatePDF(booklet)
fs.saveFileSync('output-long-edge.pdf', saved)