Free Support Forum - aspose.com

Inserting Image in Word Doc

Hi,

I am working on ASP.Net1.1 usning C# and ASPOSE

I have to Insert Image with every Table Row in the Doc file

To Insert Image in Word Doc I am writting code

quotationDetailDoc.MailMerge.MergeImageField += new MergeImageFieldEventHandler(HandleMergeImage);

private void HandleMergeImage(object sender, MergeImageFieldEventArgs e)
{
if (e.FieldName.Equals("FileName"))
{
//You can do a number of things in this event handler, this is just one scenario.
//In our case the field in the database contains a file name (without path information)
//of the image of the product category.

string shortFileName = e.FieldValue as string;

//We know that the image files are stored in the same folder as the database and
//so we create the full file name.
//Here, we pass the image file name to Aspose.Words mail merge engine.
//Alternatively, we could have passed a .NET Image object or a Stream in
//e.Image or e.ImageStream properties.


e.ImageFileName = System.IO.Path.Combine(strProductImageDir, shortFileName);
}
}

This is not inserting the Image.

What is the problem.

There is bit more detail code in Attachment if it is required.

Thanks

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Your code is correct and it should work fine.

1. Please make sure that path is correct.

e.ImageFileName = System.IO.Path.Combine(strProductImageDir, shortFileName);

2. Make sure that name of your mergefield is “Image:FileName”.

Best regards.

Many Thanks.

The problem was
2. Make sure that name of your mergefield is “Image:FileName”.

Ok, Can we make Http hyperlink to this Image

Thanks again for your co-operation

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Yes of course you can use HTTP link. But I think in this case you should also check whether link is valid.

Best regards.