Embed images from relative path (Web-App)


#1

Hi,

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
Timo


#2

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.


#3

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”>







#4

Dear Timo,

Thank you for considering Aspose.

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


#5

Dear Timo,

Thank you for considering Aspose.

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


#6

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.


#7

Sorry, please download again.


#8

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

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

And the picture resides in:

C:\projects\uap\kd\gfx\null.gif


#9

Dear Timo,

Thank you for considering Aspose.

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


#10

Works as expected now. Thanks!