Table of Contents
|
Simple command to split and reorder PDF Pages into Signatures to print the outputted PDF in a Booklet style.
Reasons for this project:
It is always fun to play with Deno and TypeScript! I needed to split my Apple Pages document into booklet.
npm install -g @yetanothertool/bookletNo installation required! Just run directly:
deno run --allow-read --allow-write --allow-env https://raw.githubusercontent.com/studiowebux/booklet/main/mod.tsOr use the local file:
deno run --allow-read --allow-write --allow-env mod.tsyat-booklet <source.pdf> <signature_count> [output.pdf]deno run --allow-read --allow-write --allow-env mod.ts <source.pdf> <signature_count> [output.pdf] [--layout]Options:
--layout- Creates a 2-up landscape layout (two pages side-by-side per sheet) for double-sided printing on the short edge. Perfect for creating an actual physical book!
Examples:
Standard output (reordered pages only):
# Node.js
yat-booklet mySuperBook.pdf 8 output.pdf
# Deno
deno run --allow-read --allow-write --allow-env mod.ts mySuperBook.pdf 8 output.pdf2-up landscape layout for booklet printing:
# Deno only
deno run --allow-read --allow-write --allow-env mod.ts mySuperBook.pdf 8 output.pdf --layoutPreview Mode
# Node.js
export PREVIEW=1
yat-booklet mySuperBook.pdf 8
# Deno
PREVIEW=1 deno run --allow-read --allow-write --allow-env mod.ts mySuperBook.pdf 8Output:
Document processed with success !
Saved to 'output.pdf'
Summary: '80' pages split into '8' signature(s)
[
[ [ 10, 1 ], [ 2, 9 ], [ 8, 3 ], [ 4, 7 ], [ 6, 5 ] ],
[ [ 20, 11 ], [ 12, 19 ], [ 18, 13 ], [ 14, 17 ], [ 16, 15 ] ],
[ [ 30, 21 ], [ 22, 29 ], [ 28, 23 ], [ 24, 27 ], [ 26, 25 ] ],
[ [ 40, 31 ], [ 32, 39 ], [ 38, 33 ], [ 34, 37 ], [ 36, 35 ] ],
[ [ 50, 41 ], [ 42, 49 ], [ 48, 43 ], [ 44, 47 ], [ 46, 45 ] ],
[ [ 60, 51 ], [ 52, 59 ], [ 58, 53 ], [ 54, 57 ], [ 56, 55 ] ],
[ [ 70, 61 ], [ 62, 69 ], [ 68, 63 ], [ 64, 67 ], [ 66, 65 ] ],
[ [ 80, 71 ], [ 72, 79 ], [ 78, 73 ], [ 74, 77 ], [ 76, 75 ] ]
]The output.pdf file contains all pages in the correct order.
Printing Instructions:
- Standard output: Configure your printer to print double-sided, then manually fold and bind
- With
--layoutflag:- Print double-sided on the short edge (flip on short edge)
- Use landscape orientation
- Stack the printed sheets in order
- Fold in half and bind
Looking for a binding jig? Check out this Book Binding Hole Punching Jig
You must use a signature that matches your total page count. Each signature must have at least 4 pages (divisible by 4).
For example:
- 80 pages with 3 signatures is NOT VALID (would result in 26.67 pages per signature)
- 80 pages with 1 or 2 or 4 or 8 signature(s) is VALID (results in 80, 40, 20, or 10 pages per signature)
- Minimum requirement: 4 pages total (1 signature of 4 pages)
- Create a Feature Branch
- Commit your changes
- Push your changes
- Create a PR
Working with your local branch
Branch Checkout:
git checkout -b <feature|fix|release|chore|hotfix>/prefix-nameYour branch name must starts with [feature|fix|release|chore|hotfix] and use a / before the name; Use hyphens as separator; The prefix correspond to your Kanban tool id (e.g. abc-123)
Keep your branch synced:
git fetch origin
git rebase origin/masterCommit your changes:
git add .
git commit -m "<feat|ci|test|docs|build|chore|style|refactor|perf|BREAKING CHANGE>: commit message"Follow this convention commitlint for your commit message structure
Push your changes:
git push origin <feature|fix|release|chore|hotfix>/prefix-nameExamples:
git checkout -b release/v1.15.5
git checkout -b feature/abc-123-something-awesome
git checkout -b hotfix/abc-432-something-bad-to-fixgit commit -m "docs: added awesome documentation"
git commit -m "feat: added new feature"
git commit -m "test: added tests"Distributed under the MIT License. See LICENSE for more information.
- Tommy Gingras @ [email protected]