-
Notifications
You must be signed in to change notification settings - Fork 67
Fix quarto layout to allow folding the whole stack #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix quarto layout to allow folding the whole stack #143
Conversation
You've never seen this codebase before. I want you to study the codebase and learn what you can about the domain and the codebase, then save what you learned in a new file "cursor_context.md". Some hints to get started: - This is "A Javascript-based app for formatting PDFs for bookbinding-- a process called imposition". - A signature in bookbinding is a group of folded sheets of paper that form a section of the book. These are created by printing multiple pages on a single large sheet, which is then folded multiple times and often cut to the correct size. Once assembled, signatures are sewn together to form the complete book block. - The JS files in the top level of `src/` appear to be the core biz logic. - A folio layout is the simplest way of printing. It imposes 2 pages (from the original input PDF) side by side on the output PDF. It creates a stack of paper, which you fold in half - no cutting required. - See `Folding instructions for quarto/octavo` in @page_layout.html (14-36) to understand what a "quarto" layout is. ----- then ----- Note the variable `pagelistdetails` in @signatures.js . Please study how `pagelistdetails` is consumed in other files, and how the various attributes inside it (like info, isSigStart, etc) get consumed in calling code. Try to understand how `pagelistdetails` is ultimately converted into a folio vs quarto layout. Then add a section to "cursor_context.md" with your findings.
| info: chunk[i], | ||
| isSigStart: isOuterMost && isBackSide && i === 0, | ||
| isSigEnd: isOuterMost && isBackSide && i === chunk.length - 1, | ||
| isSigMiddle: isBackSide && i === 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll admit, I haven't scrutinized the "isSig..." values. This whole function was vibecoded with some test driven development.
If someone wants to give me pointers on how these values are used, I don't mind doing some more testing. Maybe I need to run a conversion that generates multiple signatures, then make sure they physically assemble with pages in the correct order?
Fixes #129.
There's an existing function
bookletthat arranges pages into signatures/sheets. It tries to use the BOOKLET_LAYOUTS const to lay them out correctly. But the existing algorithm is too simple to handle the "quarto" layout, due to the additional fold.So this PR introduces a new function in
signatures.jswhich handles quarto specifically. Now you can choose "quarto", print the result, and it "just works" when you fold the entire stack together 🎉. This is in contrast with the existing version, which requires you to fold one sheet at a time.Manual testing
docs/example_page_numbers.pdfvia chrome printing to create example_page_numbers 1-32.pdfsettings.txt
Folding instructions for quarto/octavo. The printed booklet pages correctly increase from 1 to 32.