- rename page->bbox to page->image_box?
- "-f" switch
- nup(crop): take max of all bboxes first?
-- nup: apply pos to placement of images in tiles
| # Position bbox on a new paper
| paper("a4")
by=tile # Tile with copies of a single page
paper / w / h # Specify paper size, default=copy from 1st image
+ fit options (*margin, pos)
+ tpos=... # Position of images inside their tiles (default: tl)
crop # Crop to image
rotate=1 # Override rotation decision
scale=1 # Override scaling factor
paper_spec paper;
margin_spec marg;
pos_spec pos;
+ pos_spec tpos;
double hspace, vspace;
// Processing state
bool found_solution;
public:
- nup_cmd(cmd *c) : paper(c), marg(c, "margin", "margin"), pos(c)
+ nup_cmd(cmd *c) : paper(c), marg(c, "margin", "margin"), pos(c), tpos(c->arg("tpos")->as_string("tl"))
{
grid_n = c->arg("n")->as_int(0);
grid_m = c->arg("m")->as_int(0);
}
}
- debug_indent -= 4;
if (!found_solution)
die("Nup did not find a feasible solution");
+ debug("Best: %dx%d on %.3f x %.3f", best.cols, best.rows, best.paper_w, best.paper_h);
+ debug_indent -= 4;
}
class nup_page : public page {
{
BBox page_boxes[num_tiles];
find_config(in, page_boxes);
+ double tw = best.scale * best.tile_w;
+ double th = best.scale * best.tile_h;
- // Construct transform from paper to window with tiles
+ // Construct transform from paper to grid of tiles
BBox paper_box(best.paper_w, best.paper_h);
marg.shrink_box(&paper_box);
- BBox tile_box(best.cols * best.scale * best.tile_w + (best.cols-1) * hspace,
- best.rows * best.scale * best.tile_h + (best.rows-1) * vspace);
- pdf_matrix place_xform = pos.place(tile_box, paper_box);
+ BBox grid_box(best.cols * tw + (best.cols-1) * hspace,
+ best.rows * th + (best.rows-1) * vspace);
+ pdf_matrix place_xform = pos.place(grid_box, paper_box);
nup_page *p = new nup_page(best);
- p->bbox = tile_box;
+ p->bbox = grid_box;
p->bbox.transform(place_xform);
for (int i=0; i<num_tiles; i++)
}
pdf_matrix m;
- m.shift(-page_boxes[i].x_min, -page_boxes[i].y_min);
+ BBox &page_box = page_boxes[i];
+ m.shift(-page_box.x_min, -page_box.y_min);
m.scale(best.scale);
- m.shift(c * (best.scale*best.tile_w + hspace), (best.rows-1-r) * (best.scale*best.tile_h + vspace));
+ page_box.transform(m);
+
+ double x = c * (tw + hspace);
+ double y = (best.rows-1-r) * (th + vspace);
+ BBox tile_box = BBox(x, y, x+tw, y+th);
+ m.concat(tpos.place(page_box, tile_box));
p->orig_pages.push_back(in[i]);
p->xforms.push_back(m * place_xform);
MARGIN_ARGS1_NAMED("margin"),
MARGIN_ARGS2("margin"),
POS_ARGS,
+ { "tpos", AT_STRING },
{ "space", AT_DIMEN },
{ "hspace", AT_DIMEN },
{ "vspace", AT_DIMEN },