From 686a556884238545f3f1b189e71817c700a94173 Mon Sep 17 00:00:00 2001 From: Martin Mares <mj@ucw.cz> Date: Wed, 29 Jun 2016 18:48:59 +0200 Subject: [PATCH] We get dimensions in points, but send them in 100ths of mm --- xcpt.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/xcpt.c b/xcpt.c index 708ad34..4b8c382 100644 --- a/xcpt.c +++ b/xcpt.c @@ -88,8 +88,8 @@ static char *xstrdup(const char *x) O(INPUTTRAY, "automatic") \ O(TRAYFEED, "stack") \ O(MEDIATYPE, "system-default") \ - O(MEDIAXSIZE, "21000") \ - O(MEDIAYSIZE, "29700") \ + O(MEDIAXSIZE, "595") \ + O(MEDIAYSIZE, "842") \ O(FINISH_STAPLE, "") \ O(FINISH_PUNCH, "") \ O(FINISH_FOLD, "") \ @@ -307,6 +307,17 @@ static void xcpt_integer(const char *name, int value) xcpt_printf("<%s syntax=\"integer\">%d</%s>", name, value, name); } +static void xcpt_dimension(const char *name, int pt) +{ + /* + * We get dimensions in PostScript points (1/72 in). + * Xerox printers expect them in 100th's of mm, but + * last two digits must be 0. + */ + double m = pt * (25.4 / 72.) + 0.5; + xcpt_integer(name, 100 * (int)m); +} + static void xcpt_keyword(const char *name, const char *value) { xcpt_printf("<%s syntax=\"keyword\">%s</%s>", name, value, name); @@ -456,8 +467,8 @@ static void gen_job_template(void) xcpt_keyword("tray-feed", OPT(TRAYFEED)); xcpt_keyword("media-color", OPT(MEDIACOLOR)); xcpt_collection_open("media-size"); - xcpt_integer("x-dimension", OPT_INT(MEDIAXSIZE)); - xcpt_integer("y-dimension", OPT_INT(MEDIAYSIZE)); + xcpt_dimension("x-dimension", OPT_INT(MEDIAXSIZE)); + xcpt_dimension("y-dimension", OPT_INT(MEDIAYSIZE)); xcpt_close(); xcpt_keyword("media-type", OPT(MEDIATYPE)); xcpt_close(); -- GitLab