Object reference not set - Error

We are generating PDF from HTML with below code but some time randomly we got attached error.

HtmlLoadOptions objLoadOptions = new HtmlLoadOptions();

                objLoadOptions.PageInfo.Margin.Bottom = 1;
                objLoadOptions.PageInfo.Margin.Top = 1;
                objLoadOptions.PageInfo.Margin.Left = 1;
                objLoadOptions.PageInfo.Margin.Right = 1;
                objLoadOptions.PageInfo.IsLandscape = false;
                objLoadOptions.PageInfo.Width = PageSize.PageLetter.Width;
                objLoadOptions.PageInfo.Height = PageSize.PageLetter.Height;

                MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(File.ReadAllText(file)));
                Document doc = new Document(ms, objLoadOptions);
                doc.Save(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Pdf", Guid.NewGuid().ToString() + ".pdf"));

error Image.png (98.5 KB)

Error in aspose.zip (120.1 KB)

@serversupport

Thank you for contacting support.

Would you please share the source HTML file with us by zipping it, so that we may try to reproduce and investigate it in our environment.

Please find attached HTML file.

Please be noted that we are getting this error randomly when we process multiple HTML file in the loop (Approx 15 to 25). HTML.zip (28.1 KB)

@serversupport

Thank you for sharing requested data.

Would you please elaborate the issue while mentioning the attachments and sharing screenshots as well as respective code snippets reproducing the problem. We have tried to convert 7 attached HTML files with Aspose.PDF for .NET 18.8 but mentioned exception did not occur in our environment. Generated PDF files have been attached for your kind reference. Aspose.PDF_18.8.zip

Before sharing requested data and information, please ensure using latest versions of respective APIs in your environment because they include more enhancements and bug fixes.