[Tool] typst-post: Post-compilation utilities (booklets, page rotation, reordering, and project packing)

Hello everyone,

I kept running into small workflow needs that fall outside what the compiler is meant to do. The most common one for me was printing a document as a booklet: fold a stack of double-sided pages in half and have it read in order. That’s a page-imposition problem, so it makes sense the compiler doesn’t handle it (see e.g. typst#5092) but I still needed it, so I built a small command-line tool to sit after compilation and handle it.

typst-post works on the compiled PDF directly (or your source tree, for the packing command), using vector transformations only, nothing gets rasterized, and text layers and links stay intact.

It does four things:

  • booklet — impose pages as a 2-up saddle-stitch booklet, with sheet scaling and signature grouping for thicker bindings

  • rotate — rotate individual pages or ranges by 90/180/270 degrees

  • reorder — reorder, duplicate, or drop pages from a page list

  • pack — zip a project together with every file it actually depends on, using the compiler’s own --deps output rather than guessing from source text

A booklet, for example, is just:


typst-post booklet thesis.pdf

typst-post booklet zine.pdf --sheet a4

Install with pipx install typst-post (or plain pip install). MIT licensed.

Happy to hear if this is useful to anyone else, or if there’s a related pain point worth covering next.

3 Likes

Thanks for sharing this project with us.

Personally I would use typst-post when you’ve implemented 4-up printing. My booklets are such that four pages print on one side of a letter sheet of paper and four more print on the other side of the paper sheet. That’s my signature size. Then another signature will include the next 8 logical pages. This repeats until all 8N logical pages are printed, hopefully with no empty pages at the end, but not necessarily. Then I take each signature sheet and fold/cut the paper and stack it it with each other signature to assemble the booklet.

Frankly it’s magical when the imposition software works sensibly and I can figure out the order in which to fold and cut the signatures.

Again, thanks for sharing this project with us.

Thank you, this is exactly the kind of case I was hoping to hear about.

What you’re describing is different from what booklet does now. Each sheet is its own 8-page signature, folded independently, then gathered with the others. Right now booklet does 2-up spreads with --signature just grouping sheets for nesting. Different layout, different rotation pattern per page.

I opened an issue with your description: Support 4-up-per-side single-sheet signatures (8 pages per sheet) · Issue #2 · BashfulHippo/typst-post · GitHub. I don’t want to guess at the fold order and get it wrong, so if you’re willing, a diagram or photo of a hand-folded, numbered dummy sheet would help a lot.

Thanks for the detailed writeup!

My ability to describe the proper folding and cutting order is limited as I have difficulty visualizing the process.

So I did find a PDF I made a while back using some hard-to-use imposition tool long forgotten that gives the ordering I’ve come to be somewhat familiar with. I’ve saved it at Imposition-Example. I print this double-sided and then figure out the folding cutting order from there.

2 Likes

Thanks for digging that up by the way! That’s exactly what I needed. I was able to work out the full page position and rotation pattern directly from the file, verified against every sheet. On the list now.

1 Like

Update: built this out.
typst-post booklet chapbook.pdf --layout 4up --signature 16

@Johannes_Rexx I worked out the page position and rotation pattern directly from the file you shared, and checked it against every quadrant of every sheet, so it should match what you’re used to. But I’d really like to know if it holds up for you in practice. Real print/fold/cut is a better test than anything I can verify on my end. No rush, whenever you get a chance.

Version 0.2 of typst-post did the 4-up imposition perfectly. This is awesome. Thanks much for adding this feature.

1 Like

That’s exactly what I was hoping for. Thanks for the update, and for the file that made this possible in the first place.