shithub: neatpost

Download patch

ref: dafbe6554fae68ac34b4a7cd595220cdaff65d9d
parent: 64b7c6f3113a15085c3c8b1861467fa85d0b8efe
author: Ali Gholami Rudi <ali@rudi.ir>
date: Fri Jun 20 12:40:14 EDT 2014

post: save paper dimensions in tenths of a millimetre

--- a/post.c
+++ b/post.c
@@ -11,8 +11,8 @@
 #include <string.h>
 #include "post.h"
 
-static int ps_pagewidth = 216;	/* page width */
-static int ps_pageheight = 279;	/* page height */
+static int ps_pagewidth = 2159;	/* page width (tenths of a millimetre) */
+static int ps_pageheight = 2794;/* page height (tenths of a millimetre) */
 static int ps_linewidth = 40;	/* drawing line thickness in thousandths of an em */
 static int o_pages;		/* output pages */
 
@@ -335,8 +335,8 @@
 	int d1, d2, n;
 	/* predefined paper sizes */
 	if (!strcmp("letter", s)) {
-		ps_pagewidth = 216;
-		ps_pageheight = 279;
+		ps_pagewidth = 2159;
+		ps_pageheight = 2794;
 		return;
 	}
 	/* custom paper size in mm, like 210x297 for a4 */
@@ -351,16 +351,16 @@
 	n = s[1] - '0';
 	switch (tolower(s[0])) {
 	case 'a':
-		d1 = 841;
-		d2 = 1189;
+		d1 = 8410;
+		d2 = 11890;
 		break;
 	case 'b':
-		d1 = 1000;
-		d2 = 1414;
+		d1 = 10000;
+		d2 = 14140;
 		break;
 	case 'c':
-		d1 = 917;
-		d2 = 1297;
+		d1 = 9170;
+		d2 = 12970;
 		break;
 	default:
 		return;
--- a/ps.c
+++ b/ps.c
@@ -96,6 +96,7 @@
 	"	curveto\n"
 	"} bind def\n";
 
+/* pagewidth and pageheight are in tenths of a millimetre */
 void ps_header(int pagewidth, int pageheight, int linewidth)
 {
 	out("%%!PS-Adobe-2.0\n");
@@ -107,8 +108,8 @@
 
 	out("%%%%BeginProlog\n");
 	out("/resolution %d def\n", dev_res);
-	out("/pagesize [%d %d] def\n", (pagewidth * 720 + 127) / 254,
-					(pageheight * 720 + 127) / 254);
+	out("/pagesize [%d %d] def\n", (pagewidth * 72 + 127) / 254,
+					(pageheight * 72 + 127) / 254);
 	out("/linewidth %d.%02d def\n\n", linewidth / 100, linewidth % 100);
 	out("%s", prolog);
 	out("%%%%EndProlog\n");