We're converting Html to Pdf using Aspose.Pdf for .Net version 17.4.0 and getting a NullReferenceException.
The problem seems to only occur when the html has an image with source to a non-existent svg. If the svg exists or the image is png the conversion works successfully.
C#:
var document = new Document(htmlStream, htmlLoadOptions)
I have tested the scenario and have managed to export HTML to PDF file successfully without any NullReferenceException using Aspose.Pdf for .NET 17.4.0. I have also attached the files for your reference. Please see the following code snippet I used for exporting HTML to PDF.
C#
HtmlLoadOptions options = new HtmlLoadOptions(dataDir); Document pdfDocument = new Document(dataDir + “test.html”, options); pdfDocument.Save(dataDir + “output_generated.pdf”);
If you are still face issue, I will appreciate if you please share your sample HTML file along with the environment details. It will help us to reproduce the problem at our end and address it accordingly.
I have tested the scenario with your provided HTML file and have managed to reproduce the issue that html having non-existent SVG throws exception while converting to PDF. For the sake of correction, I have logged a ticket PDFNET-42578 in our issue tracking system. We will further look into the details of this issue and will keep you updated on the status of its resolution within this forum thread. Please be patient and spare us little time. We are sorry for this inconvenience.