From 932f7160f80f9c34fcf1dcc41cb2b05b78e54956 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 6 Apr 2018 22:48:33 +0200 Subject: [PATCH] Cropmarks mark=bg --- TODO | 1 + cmds.cc | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index 558dc72..aba6a97 100644 --- a/TODO +++ b/TODO @@ -34,6 +34,7 @@ | mark=cross # Crosses in the corners | mark=out # Out-pointing half-crosses in the corners (default) | mark=in # In-pointing half-crosses +| mark=bg # Colored background | pen=1pt # Line width | len=5mm # Cross arm length | offset=5mm # Distance from border diff --git a/cmds.cc b/cmds.cc index 2082ffe..b6c8eed 100644 --- a/cmds.cc +++ b/cmds.cc @@ -267,6 +267,7 @@ class cropmark_spec { MARK_CROSS, MARK_OUT, MARK_IN, + MARK_BG, } type; double pen_width; double arm_length; @@ -288,6 +289,8 @@ public: type = MARK_IN; else if (t == "out") type = MARK_OUT; + else if (t == "bg") + type = MARK_BG; else die("Invalid cropmark type %s", t.c_str()); @@ -296,6 +299,7 @@ public: offset = c->arg(prefix + "offset")->as_double(0); egstate = QPDFObjectHandle::newNull(); } + bool is_bg() { return (type == MARK_BG); } string pdf_stream(out_context *out, BBox &box, pdf_matrix &xform); }; @@ -326,7 +330,7 @@ string cropmark_spec::pdf_stream(out_context *out, BBox &box, pdf_matrix &xform) return ""; string s = "q "; - s += color.to_string() + " RG "; + s += color.to_string() + (type == MARK_BG ? " rg " : " RG "); s += xform.to_string() + " cm "; if (egstate.isNull()) @@ -374,6 +378,9 @@ string cropmark_spec::pdf_stream(out_context *out, BBox &box, pdf_matrix &xform) s += crop_cross(b.x_max, b.y_max, 0b0110); s += crop_cross(b.x_min, b.y_max, 0b1010); break; + case MARK_BG: + s += b.to_rect() + " re f "; + break; } s += "Q "; @@ -1245,8 +1252,11 @@ void nup_page::render(out_context *out, pdf_matrix parent_xform) { for (int i=0; i < (int) orig_pages.size(); i++) { + if (cmarks->is_bg()) + out->contents += cmarks->pdf_stream(out, tile_boxes[i], parent_xform); orig_pages[i]->render(out, xforms[i] * parent_xform); - out->contents += cmarks->pdf_stream(out, tile_boxes[i], parent_xform); + if (!cmarks->is_bg()) + out->contents += cmarks->pdf_stream(out, tile_boxes[i], parent_xform); } } -- 2.39.5