From 53061357db2ea6ec4ddbc97d6245a757e55ce680 Mon Sep 17 00:00:00 2001 From: Kees Date: Mon, 25 Nov 2024 07:52:00 +0100 Subject: [PATCH] Fix object reference error when trying to detect encoding --- ChromiumHtmlToPdfLib/Helpers/PreWrapper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChromiumHtmlToPdfLib/Helpers/PreWrapper.cs b/ChromiumHtmlToPdfLib/Helpers/PreWrapper.cs index 5aa2cf8..12f36ea 100644 --- a/ChromiumHtmlToPdfLib/Helpers/PreWrapper.cs +++ b/ChromiumHtmlToPdfLib/Helpers/PreWrapper.cs @@ -138,7 +138,7 @@ public string WrapFile(string inputFile, Encoding? encoding) using var fileStream = File.OpenRead(inputFile); _logger?.Info("Trying to detect encoding"); var result = CharsetDetector.DetectFromStream(fileStream); - if (result.Detected.Encoding != null) + if (result.Detected?.Encoding != null) { encoding = result.Detected.Encoding; _logger?.Info("Encoding detection status log: {statusLog}", result.Detected.StatusLog);