- Better error messages from instantiation
- page->index: use or remove
- rename page->bbox to page->image_box?
+- "-f" switch
| # Position bbox on a new paper
| paper("a4")
| margins ... params like expand
cropmarks
- style=box # Box around image
- style=cross # Crosses in the corners
- style=halfcross # Half-crosses in the corners (default)
+ mark=box # Box around image
+ mark=cross # Crosses in the corners
+ mark=out # Out-pointing half-crosses in the corners (default)
+ mark=in # In-pointing half-crosses
pen=1pt # Line width
len=5mm # Cross arm length
dist=5mm # Distance from border
crop
bleed=5mm # Allow bleeding over the image box
+# Can be written as: mix(cat) { modulo(2){1}, modulo(2){2} }
duplex
long-edge
# - paper size + margins
# - scale + margins
nup(hnum, vnum)
+ by=row/column # Filling order (default: row)
paper / w / h # Specify paper size, default=copy from 1st image
+ fit options (*margin, pos)
crop # Crop to image
tile # Tile with copies of a single page
hspace / vspace / space # Distance between tiles
+ cropmarks?
+
+# Send pages to multiple pipes and merge their results
+mix { ..., ..., ...}
+ cat # Concatenate results (default is interleave)
+ cycle # When one pipe ends earlier, cycle it from start
+ pad # When one pipe ends earlier, add blank pages
{ NULL, 0 }
};
+/*** book ***/
+
+class book_cmd : public cmd_exec {
+ int n;
+public:
+ book_cmd(cmd *c)
+ {
+ n = c->arg("n")->as_int(0);
+ if (n % 4)
+ die("Number of pages per signature must be divisible by 4");
+ }
+ vector<page *> process(vector<page *> &pages) override;
+};
+
+vector<page *> book_cmd::process(vector<page *> &pages)
+{
+ vector<page *> in, out;
+
+ in = pages;
+ while (in.size() % 4)
+ in.push_back(new empty_page(in[0]->width, in[0]->height));
+
+ int i = 0;
+ while (i < (int) in.size())
+ {
+ int sig = in.size() - i;
+ if (n)
+ sig = min(sig, n);
+ for (int j=0; j<sig/2; j+=2)
+ {
+ out.push_back(in[i + sig-1-j]);
+ out.push_back(in[i + j]);
+ out.push_back(in[i + j+1]);
+ out.push_back(in[i + sig-2-j]);
+ }
+ i += sig;
+ }
+
+ return out;
+}
+
+static const arg_def book_args[] = {
+ { "n", AT_INT | AT_POSITIONAL },
+ { NULL, 0 }
+};
+
/*** Command table ***/
template<typename T> cmd_exec *ctor(cmd *c) { return new T(c); }
{ "expand", expand_args, 0, &ctor<expand_cmd> },
{ "margins", margins_args, 0, &ctor<margins_cmd> },
{ "add-blank",add_blank_args, 0, &ctor<add_blank_cmd> },
+ { "book", book_args, 0, &ctor<book_cmd> },
{ NULL, NULL, 0, NULL }
};