MoonBit booklet imposition plans with signature boundaries, blank-page accounting and SVG previews.

npm ci
moon build --target js cmd/main
moon run cmd/main -- --pages 20 --signature 16
moon run cmd/main -- --pages 20 --out plan.json --svg preview.svgnpm run impose -- --input source.pdf --output booklet.pdf --signature 16 --duplex shortnpm run demonode _build/js/debug/build/cmd/main/main.js --pages 40 --select "21-24,1" --binding right --duplex long --json| 纸张(外到内) | 正面左 | 正面右 | 背面左 | 背面右 |
|---|---|---|---|---|
| 1 | 8 | 1 | 2 | 7 |
| 2 | 6 | 3 | 4 | 5 |
| 选项 | 契约 |
|---|---|
| --pages N | 必填,原稿页数 1–10,000 |
| --select "1-8,13-20" | 可选,默认全选;保留列举顺序;拒绝重复、倒序范围和越界 |
| --signature N | 每册最多 N 页,4–64 且为 4 的倍数,默认 16 |
| --binding left/right | 默认 left;right 交换每面左右页槽 |
| --duplex short/long | 横向纸张翻转边,默认 short;long 要对背面整体旋转 180° |
| --out PATH | 完整 JSON 计划,0 表示补白 |
| --svg PATH | 最多显示前 24 张纸的预览,标明截断;JSON 永远完整 |
| --json | stdout 只输出 JSON,方便管道 |
match @fold.parse_selection("1-8,13-16", 20) {
Err(message) => println(message)
Ok(pages) => match @fold.make_plan(20, pages, @fold.default_config()) {
Err(message) => println(message)
Ok(plan) => println(@fold.plan_to_json(plan))
}
}node scripts/verify.mjspub(all) struct Sheet {
signature : Int
depth : Int
front_left : Int
front_right : Int
back_left : Int
back_right : Int
back_rotation : Int
}fn parse_positive(text : String, maximum : Int) -> Result[Int, String]Install
Download zipMoonBit booklet imposition plans with signature boundaries, blank-page accounting and SVG previews.