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

Free Support Forum - aspose.com

NullReferenceException when adding Image through XSLT


When I am trying to output the image via XSLT without any wrapper container around it, i.e. like that:
<xsl:template match=“img”>
< Image File="{text()}" Type="{@type}" FixHeight="{@height}" FixWidth="{@width}" />
(Space between the < and Image intended, otherwise it would show in this post)

the Aspose PDF throws error:

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.

at Aspose.Pdf.Page.#=zvjHewFY=(XmlReader #=zNI6$7Kk=)
at Aspose.Pdf.Document.BindXml(Stream stream)
at Aspose.Pdf.Document.BindXml(Stream xmlStream, Stream xslStream, XmlReaderSettings settings)
at Aspose.Pdf.Document.BindXml(Stream xmlStream, Stream xslStream)

The error is not thrown if the image is wrapped in some sort of a container, i.e. Floating Box, but I can’t use it either as there is an issue with positioning Floating Box next to tables.

How could I fix the error thrown when the image is not wrapped by a container?
Test case code here: image-nullpointerexception-code-sample.zip (141.9 KB)


It seems like API is generating issue with <image> tag inside XSLT file and throwing an exception. We have also noticed this behavior in our environment. For the sake of correction, it has been logged as PDFNET-46604 in our issue tracking system. We will surely look into details of the issue and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

Hi, is there any workaround for this issue?


We regret to share that we cannot share any workaround at the moment as logged ticket is pending for investigation. As soon as investigation of the logged ticket is complete, we will be able to share further feedback on this issue. We will surely let you know as soon as we have some certain news on this. Please spare us little time.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PDFNET-46604) have been fixed in Aspose.PDF for .NET 19.8.