]> mj.ucw.cz Git - paperjam.git/commitdiff
Implemented common
authorMartin Mares <mj@ucw.cz>
Sun, 22 Apr 2018 20:05:16 +0000 (22:05 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 22 Apr 2018 20:05:16 +0000 (22:05 +0200)
cmds.cc

diff --git a/cmds.cc b/cmds.cc
index 9ce9e03ac70d34615b939dddeb87a3fc95e3e8c4..a0be5731a04188d1c7792007003c9bbfd628a0da 100644 (file)
--- 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<page *> process(vector<page *> &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<page *> 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<typename T> 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<clip_cmd>,
                "Suppress page contents drawn outside the image box" },
+  { "common",  no_args,        0,      &ctor<common_cmd>,
+               "Use a common page size and image box for all pages" },
   { "cropmarks",cropmarks_args,        0,      &ctor<cropmarks_cmd>,
                "Draw cropping marks around the image box" },
   { "debug",   no_args,        0,      &ctor<debug_cmd>,