We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Html with svg images to Pdf

Hi,

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)

Html:


Thanks in advance.

Hi There,


Thanks for contacting support.

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.

We are sorry for this inconvenience.

Best Regards,

Thanks for the reply


Interestingly the problem did not occur, when the image is nested in a span.
I added the html I did get the error with and stacktrace.

Hi There,


Thanks for sharing further details.

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.

Best Regards,