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

Free Support Forum - aspose.com

Relative path while inserting images

Hi,

I am using xml template to generate a PDF file. We need to add some images in the PDF file. And this is how I am adding them.

Image img =(Image)section1.getObjectByID("imageID1");
img.getImageInfo().setFile(".\\images\\49312.jpeg");

It is throwing error if I specify relative path. But works fine for absolute path.

Can you please tell me how we can insert images using relative path.

Thanks

Mamatha

Hello,

Can somebody please reply to this.

Thanks

Mamatha

Hi Mamatha,

First of all please accept my apologies for replying you so late.

You may use a relative file name like this:

File f = new File("images\\49312.jpeg");

To use this format you'll have to know the "current user directory", which most often is where the Java Virtual Machine is invoked. If you are in doubt you can get the name of the current user directory like this:

String userdir = System.getProperty("user.dir");

Please feel free to contact support in case you need any further assistance.

Thanks & Regards,