From 432b59c7a1974f1f874caaa914f1f417ea66cb09 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 22 Apr 2018 22:05:16 +0200 Subject: [PATCH] Implemented common --- cmds.cc | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/cmds.cc b/cmds.cc index 9ce9e03..a0be573 100644 --- a/cmds.cc +++ b/cmds.cc @@ -1416,6 +1416,40 @@ static const arg_def clip_args[] = { { NULL, 0, NULL } }; +/*** common ***/ + +class common_cmd : public cmd_exec { + vector process(vector &pages) override + { + if (!pages.size()) + return pages; + + const page *first = pages[0]; + BBox pbox(first->width, first->height); + BBox ibox = first->image_box; + for (auto p: pages) + { + BBox pg(p->width, p->height); + pbox.join(pg); + ibox.join(p->image_box); + } + + vector out; + for (auto p: pages) + { + page *q = new xform_page(p, pdf_matrix()); + q->width = pbox.width(); + q->height = pbox.height(); + q->image_box = ibox; + out.push_back(q); + } + + return out; + } +public: + common_cmd(cmd *c UNUSED) { } +}; + /*** Command table ***/ template cmd_exec *ctor(cmd *c) { return new T(c); } @@ -1429,6 +1463,8 @@ const cmd_def cmd_table[] = { "Prepare booklets for book binding" }, { "clip", clip_args, 0, &ctor, "Suppress page contents drawn outside the image box" }, + { "common", no_args, 0, &ctor, + "Use a common page size and image box for all pages" }, { "cropmarks",cropmarks_args, 0, &ctor, "Draw cropping marks around the image box" }, { "debug", no_args, 0, &ctor, -- 2.39.2