I have HTML body And when I try convert this html to pdf I have got exception System.NullReferenceException: Object reference not set to an instance of an object.
string docContent = “html contents”;
Code snippet : using (var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(docContent)))
{
// Create HtmlLoadOptions object
HtmlLoadOptions options = new HtmlLoadOptions() { };
// Load HTML string into a temporary Document object
Document tempDocument = new Document(stream, options);
// here it gives null exception
}
Stacktrace :
System.NullReferenceException:
at #=z8074XGYeWGMr_HrrCKLqDNLwzG13w5dAyq2PqdKR9B1v.#=ztLM$ihs= (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=z8074XGYeWGMr_HrrCKLqDNLwzG13w5dAyq2PqdKR9B1v.#=znYHeImhW02GE1ylw4Q== (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=zvQBtUMoE6VMVrLVvSWnPMV48YJsHJIrYWfqZpk$FaESJ1KsiokA6bVdJjpJRdtANfouvOucbnoZb.#=zZockDM3sl7GvK4r8PA== (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=zNlXqjqNz0HpTaLoyRkQsQ_y_26h8lXwTZgG$PFGvALva8lFg9$dCZdE=.#=z8S9jk_KjsG5iiORHzQ== (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=zYtDupo8XpnSo4yHeTWHiljzHXgUnD7PfYxK415nvAmczYQDjjA==.#=zgDzlMgsfpdv1 (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at Aspose.Pdf.Text.TextSegment.set_Text (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at Aspose.Pdf.Text.TextSegment.#=zf96MgCY= (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at Aspose.Pdf.Text.TextBuilder.#=zJwe2oHU= (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at Aspose.Pdf.Text.TextBuilder.AppendText (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=zmoAl9ViSFgn90QkNfZv$7KlfkdJDkvk7Qg==.#=zFWlCz4M= (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=ztgcP9koGTiM9qu1XSXksJHYqGrNB.#=zZlgPytk= (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=ztgcP9koGTiM9qu1XSXksJHYqGrNB.#=zXV7GkF4I3p0L (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=ztgcP9koGTiM9qu1XSXksJHYqGrNB.#=zKP7c6z20mtX1S69L2g== (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=ztgcP9koGTiM9qu1XSXksJHYqGrNB.#=zS$0Fa5Q= (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=z4v3z1qRdqJbhbLKaYQItqp60solEbM2kyg==.Render (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=zuiYSydLjkFhOtxzn2aY9VnlLkSrJSdrpAg==.#=zTURLyzZA3Rmu (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=zjwPbzqLRi75vPPF1kNskXuUJgGBD.Render (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=zjwPbzqLRi75vPPF1kNskXuUJgGBD.Render (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=zu49guH3YXX6Fo4kaMZO30c8zSGyX.Render (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=zu49guH3YXX6Fo4kaMZO30c8zSGyX.Render (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=z9FFaSu_LXOFXJJJLFJID2UMJD_iP.#=zZ1wpC85K6Uqz (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=z9FFaSu_LXOFXJJJLFJID2UMJD_iP.#=zbMvyAyY= (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at #=z9FFaSu_LXOFXJJJLFJID2UMJD_iP.#=zbMvyAyY= (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at Aspose.Pdf.Document.#=zl7VlEV8= (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at Aspose.Pdf.Document.#=zl7VlEV8= (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at Aspose.Pdf.Document…ctor (Aspose.PDF, Version=24.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
Version: PackageReference Include=“Aspose.PDF” Version=“23.0.0”
Note - It works fine one local environment and other server as well but only on one specific container its not working