From 677e952450076a5e746d778a96e9d5965ee9403c Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Sun, 21 Sep 2014 08:36:08 +0930 Subject: [PATCH 13/13] pdftocairo: fix/add some error messages --- utils/pdftocairo-win32.cc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/utils/pdftocairo-win32.cc b/utils/pdftocairo-win32.cc index 8a9a312..0b056f5 100644 --- a/utils/pdftocairo-win32.cc +++ b/utils/pdftocairo-win32.cc @@ -155,7 +155,7 @@ cairo_surface_t *win32BeginDocument(GooString *inputFileName, GooString *outputF LONG szProp = DocumentPropertiesA(NULL, NULL, printerName, NULL, NULL, 0); if (szProp < 0) { - fprintf(stderr, "Error: Printer \"%s\" not found", printerName); + fprintf(stderr, "Error: Printer \"%s\" not found\n", printerName); exit(99); } devmode = (DEVMODEA*)gmalloc(szProp); @@ -165,16 +165,20 @@ cairo_surface_t *win32BeginDocument(GooString *inputFileName, GooString *outputF //Load the current default configuration for the printer into devmode if (DocumentPropertiesA(NULL, NULL, printerName, devmode, devmode, DM_OUT_BUFFER) < 0) { - fprintf(stderr, "Error: Printer \"%s\" not found", printerName); + fprintf(stderr, "Error: Printer \"%s\" not found\n", printerName); exit(99); } fillCommonPrinterOptions(w, h, duplex); fillPrinterOptions(duplex, printOpt); - DocumentPropertiesA(NULL, NULL, printerName, devmode, devmode, DM_IN_BUFFER | DM_OUT_BUFFER); + if (DocumentPropertiesA(NULL, NULL, printerName, devmode, devmode, DM_IN_BUFFER | DM_OUT_BUFFER) < 0) + { + fprintf(stderr, "Error: Printer \"%s\" not found\n", printerName); + exit(99); + } hdc = CreateDCA(NULL, printerName, NULL, devmode); if (!hdc) { - fprintf(stderr, "Error: Printer \"%s\" not found", printerName); + fprintf(stderr, "Error: Printer \"%s\" not found\n", printerName); exit(99); } @@ -190,7 +194,7 @@ cairo_surface_t *win32BeginDocument(GooString *inputFileName, GooString *outputF docinfo.lpszOutput = outputFileName->getCString(); } if (StartDocA(hdc, &docinfo) <=0) { - fprintf(stderr, "Error: StartDoc failed"); + fprintf(stderr, "Error: StartDoc failed\n"); exit(99); } @@ -200,7 +204,11 @@ cairo_surface_t *win32BeginDocument(GooString *inputFileName, GooString *outputF void win32BeginPage(double *w, double *h, GBool useFullPage) { fillPagePrinterOptions(*w, *h); - DocumentPropertiesA(NULL, NULL, printerName, devmode, devmode, DM_IN_BUFFER | DM_OUT_BUFFER); + if (DocumentPropertiesA(NULL, NULL, printerName, devmode, devmode, DM_IN_BUFFER | DM_OUT_BUFFER) < 0) + { + fprintf(stderr, "Error: Printer \"%s\" not found\n", printerName); + exit(99); + } ResetDCA(hdc, devmode); // Get actual paper size or if useFullPage is false the printable area. -- 2.1.0