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);