Booklet creator using NodeJS and PDF file as source
The goal of this project is to reorder PDF pages in order to print them and create a book using multiple signatures.
This script has been done with NodeJS, mainly because I like javascript and also Iām familiar with it more than anything else.
The full code is available here: https://github.com/yet-another-tool/booklet
Installation
You need NodeJS 14 or later, then you can simply do : npm install -g @yetanothertool/booklet
then you are all set to generate your book !
Usage
The tool options are the following
In your terminal you can launch the yat-booklet
command
yat-booklet <source> <signature_count> [output]
yat-booklet <source.pdf> <number> [output.pdf]
The source must be a PDF with the normal page order.
The signature count should be determine based on the total nomber of pages, meaning that the result of totalPages / signatureCount = EVEN number
, Otherwise it will simply not work.
The output is the filename that will contain the new order
What is a signature ? https://en.wikipedia.org/wiki/Section_(bookbinding)
In bookbinding, a section, gathering, or signature is a group of sheets folded in half, to be worked into the binding as a unit.
And this is the thing that the script will generate for you.
Example of the output:
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 ] ], --> First signature containing 10 pages
[ [ 20, 11 ], [ 12, 19 ], [ 18, 13 ], [ 14, 17 ], [ 16, 15 ] ], --> Second signature containing 10 pages
[ [ 30, 21 ], [ 22, 29 ], [ 28, 23 ], [ 24, 27 ], [ 26, 25 ] ], --> and etc.
[ [ 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 ] ]
]
Once generated you will get a new PDF, in this example named output.pdf That document can be print, be careful to keep the same print order, otherwise it might be hard to assemble the book.
Plus I had issues with my printer, so start with only one signature to determine if the page orientation is good and that your printer is able to do double-sided print. (That was the hardest part of that project :/)
Conclusion
That was really nice to play along with this script and even more with the book binding part !
Let me know if you had issues and share your creations !
Have fun !