From e4789c6e88cb04598dfea705ba668e952748e998 Mon Sep 17 00:00:00 2001 From: Sooraj Parameswaran Date: Fri, 26 Oct 2018 16:14:01 +0530 Subject: [PATCH 1/2] Throwing standard error if the wkhtml has returned an error code --- Rotativa.AspNetCore/WkhtmlDriver.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Rotativa.AspNetCore/WkhtmlDriver.cs b/Rotativa.AspNetCore/WkhtmlDriver.cs index 48b3bb6..566ca0c 100644 --- a/Rotativa.AspNetCore/WkhtmlDriver.cs +++ b/Rotativa.AspNetCore/WkhtmlDriver.cs @@ -21,7 +21,7 @@ protected static byte[] Convert(string wkhtmlPath, string switches, string html, // "-q" - silent output, only errors - no progress messages // " -" - switch output to stdout // "- -" - switch input to stdin and output to stdout - switches = "-q " + switches + " -"; + switches = switches + " -"; // generate PDF from given HTML string, not from URL if (!string.IsNullOrEmpty(html)) @@ -68,7 +68,7 @@ protected static byte[] Convert(string wkhtmlPath, string switches, string html, } } - string error = proc.StandardError.ReadToEnd(); + var error = proc.StandardError.ReadToEnd(); if (ms.Length == 0) { @@ -77,7 +77,8 @@ protected static byte[] Convert(string wkhtmlPath, string switches, string html, proc.WaitForExit(); - return ms.ToArray(); + if(proc.ExitCode == 0 || proc.ExitCode == 2) + return ms.ToArray(); } } From 8ab5c5c572364216f0ccbcff2312c93afe2d17d2 Mon Sep 17 00:00:00 2001 From: Sooraj Parameswaran Date: Mon, 29 Oct 2018 11:47:48 +0530 Subject: [PATCH 2/2] Throwing error if there is error --- Rotativa.AspNetCore/WkhtmlDriver.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Rotativa.AspNetCore/WkhtmlDriver.cs b/Rotativa.AspNetCore/WkhtmlDriver.cs index 566ca0c..0d3aee5 100644 --- a/Rotativa.AspNetCore/WkhtmlDriver.cs +++ b/Rotativa.AspNetCore/WkhtmlDriver.cs @@ -79,6 +79,7 @@ protected static byte[] Convert(string wkhtmlPath, string switches, string html, if(proc.ExitCode == 0 || proc.ExitCode == 2) return ms.ToArray(); + throw new Exception(error); } }