Free Support Forum - aspose.com

Add Image to xml

Hi

I want to add image to xml file and bind with Word template document and i use xsd
i tried to use the base64Binary in xsd and image mail merge field in the template


Document doc = new Document(HttpContext.Current.Server.MapPath("~/Data/SitePlanIndustrialDocument.doc"));
DataSet dataSet = GetDataSet();
doc.MailMerge.ExecuteWithRegions(dataSet);

private DataSet GetDataSet()
{
DataSet dataSet = new DataSet();
dataSet.ReadXml(HttpContext.Current.Server.MapPath("~/Data/SiteplanData.xml"));
return dataSet;
}

and give me this error
"Cannot load image from field ‘image’. The field contains data in unsupported
format. The URI prefix is not recognized.

"

please give me the best solution for this
chk the attached file!

Regards
Omar
Hi Omar,

Thanks for your inquiry.

Can you also please attach the input word template document for which the error is experienced. To be specific, a document named "SitePlanIndustrialDocument.doc". I have tried reproducing the issue on my side but was not able to do so. It will really help us analyse the issue in a better way.


We apologize for your inconvenience.


Kindly find attached file


Please my question is how to bind from XML to word template there is any guide

Many thanks
omar
Hi Omar,

Thanks for your reply.

Binding XML to Word template is easy using Aspose.Words. The best way to understand how to bind from XML dataset to word template is to go through the documentation available here. You can also have a look at use of Mail Merge from XML dataset using LINQ to XML here. You can also find the sample source code (both for VB.Net and CSharp) attached to the articles that will help you understand Mail Merge features of Aspose.Words API in a really fine way.

Apart from this, loading base64 image data from XML document into the Word template could be best understood using the following documentation reference here. You can use database to store images as well as XML data to contain the image data and then use it in IFieldMergingCallback to load and set image data as a stream in the final document.

Attached is the sample source project which explains the XML data set usage with base64 images and inclusion of images in the word template using the IFieldMergingCallback interface.

Hope this helps. Please let us know if you have any more queries.