[PATCH 2/2] Add optional border around barcodes in table mode

Markus Berg markus@kelvin.nu
Sat Apr 9 16:26:57 CEST 2011


Signed-off-by: Markus Berg <markus@kelvin.nu>
---
 main.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/main.c b/main.c
index c29faf1..7d6d3bd 100644
--- a/main.c
+++ b/main.c
@@ -127,7 +127,7 @@ int xpadding, ypadding;               /* internal padding for "-g" */
 int xmargin0, ymargin0;               /* left bottom page margins */
 int xmargin1, ymargin1;               /* same, but right and top */
 int ximargin, yimargin;               /* "-m": internal margins of table */
-int eps, pcl, ps, noascii, nochecksum; /* boolean flags */
+int eps, pcl, ps, noascii, nochecksum, border; /* boolean flags */
 int page_wid, page_hei;               /* page size in points */
 char *page_name;                      /* name of the media */
 double unit = 1.0;                    /* unit specification */
@@ -389,6 +389,8 @@ struct commandline option_table[] = {
                     "geometry on the page: [<wid>x<hei>][+<padding>+<padding>]"},
     {'t', CMDLINE_S, NULL, get_table, "BARCODE_TABLE", NULL,
                     "table geometry: <cols>x<lines>[+<margin>+<margin>]"},
+    {'B', CMDLINE_NONE, &border, NULL, NULL, NULL,
+                    "print a thin border around barcodes in table mode"},
     {'m', CMDLINE_S, NULL, get_margin, "BARCODE_MARGIN", "10",
                     "internal margin for each item in a table: <xm>[,<ym>]"},
     {'n', CMDLINE_NONE, &noascii, NULL, NULL, NULL,
@@ -597,6 +599,20 @@ int main(int argc, char **argv)
 		exit(1);
 	    }
 	    bc->margin = 0;
+
+	    /* draw a border around the barcode */
+	    if (border) {
+		fprintf(ofile, "0.1 setlinewidth\n");
+		fprintf(ofile, "%d %d newpath moveto\n", xbl, ybl);
+		fprintf(ofile, "%d %d lineto\n", xbl+code_width, ybl);
+		fprintf(ofile, "%d %d lineto\n", xbl+code_width, ybl+code_height);
+		fprintf(ofile, "%d %d lineto\n", xbl, ybl+code_height);
+		fprintf(ofile, "closepath\n");
+		fprintf(ofile, "0.4 setgray\n");
+		fprintf(ofile, "stroke\n");
+		fprintf(ofile, "0 setgray\n");
+	    }
+
 	    if ( (Barcode_Position(bc, code_width - xpadding*2, code_height - ypadding*2,
 				   xbl+xpadding, ybl+ypadding, 0.0) < 0)
 		 || (Barcode_Encode(bc, flags) < 0)
-- 
1.7.4


--=-FsSE40lf5JQiTqOhnCIm--



More information about the barcode mailing list