From 3a1ae9b3db655efc98965bcc82ad545f6572158d Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 15 Sep 2016 17:13:07 +0100 Subject: Update gproof device to invoke gs better. When invoking gs, pass in -gWIDTHxHEIGHT -dFitPage. This avoids any possible mismatch betwen the page size we expect and the page size that gs returns. --- source/gprf/gprf-doc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source/gprf') diff --git a/source/gprf/gprf-doc.c b/source/gprf/gprf-doc.c index 3b8aa745..5ca14aea 100644 --- a/source/gprf/gprf-doc.c +++ b/source/gprf/gprf-doc.c @@ -555,10 +555,11 @@ generate_page(fz_context *ctx, gprf_page *page) #ifdef USE_GS_API void *instance; int code; - char *argv[] = { "gs", "-sDEVICE=gprf", "-dUsePDFX3Profile", NULL, "-o", NULL, NULL, NULL, NULL, NULL, NULL, NULL}; + char *argv[] = { "gs", "-sDEVICE=gprf", "-dUsePDFX3Profile", NULL, "-o", NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-dFitPage", NULL}; char arg_res[32]; char arg_fp[32]; char arg_lp[32]; + char arg_g[32]; sprintf(arg_res, "-r%d", doc->res); argv[3] = arg_res; @@ -570,7 +571,9 @@ generate_page(fz_context *ctx, gprf_page *page) argv[8] = disp_profile; argv[9] = print_profile; argv[10] = "-I%rom%Resource/Init/"; - argv[11] = doc->pdf_filename; + sprintf(arg_g, "-g%dx%d", page->width, page->height); + argv[11] = arg_g; + argv[13] = doc->pdf_filename; code = gsapi_new_instance(&instance, ctx); if (code < 0) @@ -585,8 +588,8 @@ generate_page(fz_context *ctx, gprf_page *page) fz_throw(ctx, FZ_ERROR_GENERIC, "GS run failed: %d", code); #else /* Invoke gs to convert to a temp file. */ - sprintf(gs_command, "gswin32c.exe -sDEVICE=gprf -r%d -o \"%s\" %s %s -I%%rom%%Resource/Init/ -dFirstPage=%d -dLastPage=%d \"%s\"", - doc->res, filename, disp_profile, print_profile, page->number+1, page->number+1, doc->pdf_filename); + sprintf(gs_command, "gswin32c.exe -sDEVICE=gprf -r%d -o \"%s\" %s %s -I%%rom%%Resource/Init/ -dFirstPage=%d -dLastPage=%d -g%dx%d -dFitPage \"%s\"", + doc->res, filename, disp_profile, print_profile, page->number+1, page->number+1, page->width, page->height, doc->pdf_filename); fz_system(ctx, gs_command); #endif -- cgit v1.2.3