margins_cmd(cmd *c) : marg(c, "size", "") { }
page *process_page(page *p) override
{
- pdf_matrix xf;
- xf.shift(-p->image_box.x_min, -p->image_box.y_min);
- xf.shift(marg.l, marg.b);
- page *q = new xform_page(p, xf);
- q->width = p->image_box.width() + marg.l + marg.r;
- q->height = p->image_box.height() + marg.t + marg.b;
- if (q->width < 0.001 || q->height < 0.001)
- err("Margins must result in positive page dimensions");
+ page *q = new xform_page(p, pdf_matrix());
+ q->image_box = BBox(marg.l, marg.t, p->width - marg.r, p->height - marg.b);
+ if (q->image_box.width() < 0.001 || q->image_box.height() < 0.001)
+ err("Margins must result in positive image dimensions");
return q;
}
};