Embed images from relative path (Web-App)



I tried to find an answer in the forums, but wasn’t lucky yet. I am running a web app using aspose.pdf to create reports and need to include images into the report. It’s not an option to use absolute paths and I need to do it using XML only.

There is a way to include the images using FileType and URL but then I have to include additional CCITT parameters (no idea what that is) and the image seems not to be embedded but only linked. If I try to open the pdf I only get an error message.

Is there, or could there be a way to embed images using a relative path?

Cheers and keep up the good work


Dear Timo,

Thank you for considering Aspose.

I am not quite understand your requirement. How do you add the image file path into your XML? If you add it by hand, you certainly know where the image is. If the path is added in program, you can easyly convert the relative path to absolute path. Am I right?

If you want to use URL to specify the image file, you can simply specify the URL of the image in ImageInfo.File. Note that you need not set the ImageInfo.OpenType to ImageOpenType.Url if you don’t use CCITT iamge. The image will be embeded but not just linked.


I want to set the image in the xml by hand, so naturally I know, where the image is as you said. For deployment reasons I don’t want to state it hard-wired like in my example below. The best thing for me would be to define the location of the image relative to the xml-location (but that would be wishful thinking maybe).
Ok, consider the folowing xml:

<Image Type=“gif” File=“C:\images\null.gif” better: File="./images/null.gif" OpenType=“File” Height=“3”>


Dear Timo,

Thank you for considering Aspose.

Your requirement is reasonable. It’s not difficult to support. I will add support for it soon.


Dear Timo,

Thank you for considering Aspose.

Relative path is now supported. Please download hot fix here.


The Link links still to the 1.9.1 Version dated October 21st.
The result is still:

[ApplicationException: Couldn’t open image file: …\gfx\null.gif]
Aspose.Pdf.Figure.a.a(aa A_0, Int32 A_1, ImageFileType A_2, String A_3, String A_4, String A_5, Int32 A_6, Int32 A_7, Boolean A_8, Boolean A_9, Boolean A_10, Byte[] A_11)

Same with forward slashes.


Sorry, please download again.


There still seems to be a problem with it because…

[ApplicationException: Couldn’t open image file: C:\projects\uap\kd~1…\gfx\null.gif]

The xml resides in C:\projects\uap\kd~1\test.xml

<Cell ColumnsSpan=“5” BackgroundColor=“White”>
<Image Type=“gif” File="…\gfx\null.gif" OpenType=“File” Height=“3”></Image>

And the picture resides in:



Dear Timo,

Thank you for considering Aspose.

I have fixed this bug. PLese download hot fix again.


Works as expected now. Thanks!