ASPOSE Word & Chart Integration


I’m not too sure where I should be posting this enquiry but I guess will have to try my luck here. Kindly direct me to the correct thread if I have posted in the wrong thread. Thanks.

I am currently doing a product evaluation for a project we will be doing.

Requirements: We have to generate a chart in a report and export them as a word document to be attached into an email. (Hope this doesn’t sound too complicated.)

For the chart, we are intending to use the ASPOSE chart and word component for the generation of the chart and the word document. I would like to know if there is any suggestions for a implementation on how to integrate the chart into the word document, via the components if possible. Thanks.


Hi jonguil,

I’m not very familar with Aspose.Chart but I expect you can produce an Image from it.
As soon as you have an image you can insert it into the Word document using Aspose.Word.
I think this answers your question in general.

Please note that Aspose.Word does not expose rich API to manipulate document content and you will not find methods to insert image or other content directly. Instead, Aspose.Word works like a mail merge engine that can insert data including images into a document into mail merge fields.

Basically what you need to do is:
1. Create a .doc report template and insert mail merge fields. The field that will contain the image must have a special name such as “Image:MyChart”.
2. Open the document in Aspose.Word and run Document.MailMerge.Execute
3. Respond to MergeImageField event and give filename, stream or Image of your chart back to Aspose.Word when requested data for the “MyChart” field. Aspose.Word will insert the image into the document.

Merging images into the document is a very new feature and demo and sample source code is not yet available in the current release. But online documentation is already available.

Please let me know if you need further guidance. I might even be able to build a fully working demo just for this purpose and include it into the release later.


Hi romank,

Thanks for the prompt reply. Am very relieved to know that there is a MergeImage function. Solves all my problems.

3. Respond to MergeImageField event and give filename, stream or Image of your chart back to Aspose.Word when requested data for the “MyChart” field. Aspose.Word will insert the image into the document.

–> Sorry but I’m not too sure what you are refering to. I have no issue doing a simple merge,
e.g. Document mergeDoc = mainDoc.MailMerge.Execute(
new string[] {“MyName”},
new object[] {txtName.Text});

I don’t really understand what you mean by respond to the MergeImageField event. Will it be ok if you can show me a simple MergeImage example. Like how to call the method and when to call the method. Will appreciate any help you can render me. Thanks!



You need to:

//Subscribe to the event
doc.MailMerge.MergeImageField += new MergeImageFieldEventHandler(HandleMergeImageFieldEvent);

//Define the event handler
private void HandleMergeImageFieldEvent(object sender, MergeImageFieldEventArgs e)
//e.FieldName will contain name of the field. Will be “MyImage” if you had “Image:MyImage” field in the document.
//e.FieldValue will contain value that comes from your data source. Could be some Id that you will use to get or generate the chart.
//Something that a user should do here. Take field value and return image, stream of filename.
//If my field value had file name I could do this:
e.Image = System.Drawing.Image.FromFile(e.FieldValue.ToString());
//If my field value was some sort of chart id:
e.Image = System.Drawing.Image.FromFile(GenerateMyChart(e.FieldValue));

See for more details.

Ask if you need more information.

Fully working demo will be available in Aspose.Word 1.3 at the end of the month.



Thanks for the demo! Still having a little problem here though…

“The type or namespace name ‘MergeImageFieldEventArgs’ could not be found (are you missing a using directive or an assembly reference?)”

–> I have already reference the Aspose.Word namespace. The version I downloaded as trial is the copy that is currently available for download in your site. I am inclined to believe that the version I have does not have the API for merging image perhaps? This could explain why I was not able to find anything from the API locally and that’s why I had to post here for help.

Thanks for all the help so far…


Hi Roman,

Me & my stupidity… I’ve found the dll for version 1.2.2… Everything is going well so far. Thank you so much for your help and sorry for being such a hassle!!



Aspose.Word 2.1.3 is released with new demos, for more info see