Skip to content

Conversation

@locofocos
Copy link

@locofocos locofocos commented Nov 9, 2025

Fixes #129.

There's an existing function booklet that 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.js which 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

  1. I exported the first 32 pages of docs/example_page_numbers.pdf via chrome printing to create example_page_numbers 1-32.pdf
  2. I used it as input w/ commit 1cf03db, using duplex + flip on short side + quarto + booklet + 0 flyleafs. Full settings:
    settings.txt
  3. It produced this output: example_page_numbers_1_32_typeset.pdf
image
  1. I printed, folded, and cut all 8 sheets together per Folding instructions for quarto/octavo. The printed booklet pages correctly increase from 1 to 32.
image

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.
@locofocos locofocos changed the title Feature/quarto layout order Fix quarto layout to allow folding the whole stack Nov 9, 2025
@locofocos locofocos marked this pull request as ready for review November 9, 2025 09:55
Comment on lines +222 to +225
info: chunk[i],
isSigStart: isOuterMost && isBackSide && i === 0,
isSigEnd: isOuterMost && isBackSide && i === chunk.length - 1,
isSigMiddle: isBackSide && i === 0,
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Output page ordering for booklets

1 participant