Hello Support
We have a CKEDITOR WYSIWYG Editor Form Field which stores HTML Format Content in Database along with the embedded Image in the Editor (as HTML ) .
Note Image is as part of HTML since it is uploaded via Editor .
Please let me know if we can show this Content (HTML) along with embedded Image in WORD using ASPOSE Word .net Mail merge and How .
Regards
Atul
Hi Atul,
<span style=“font-size:10.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>// File ‘MailMerge.InsertHtml.doc’ has merge field named
‘htmlField1’ in it.<span style=“font-size:10.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman””><o:p></o:p>
// File 'MailMerge.HtmlData.html' contains some valid Html data.
// The same approach can be used when merging HTML data from database.
public void MailMergeInsertHtml()
{
Document doc = new Document(MyDir + "MailMerge.InsertHtml.doc");
// Add a handler for the MergeField event.
doc.MailMerge.FieldMergingCallback = new HandleMergeFieldInsertHtml();
// Load some Html from file.
StreamReader sr = File.OpenText(MyDir + "MailMerge.HtmlData.html");
string htmltext = sr.ReadToEnd();
sr.Close();
// Execute mail merge.
doc.MailMerge.Execute(new string[] { "htmlField1" }, new string[] { htmltext });
// Save resulting document with a new name.
doc.Save(MyDir + "MailMerge.InsertHtml Out.doc");
}
private class HandleMergeFieldInsertHtml : IFieldMergingCallback
{
///
/// This is called when merge field is actually merged with data in the document.
///
void IFieldMergingCallback.FieldMerging(FieldMergingArgs e)
{
// All merge fields that expect HTML data should be marked with some prefix, e.g. 'html'.
if (e.DocumentFieldName.StartsWith("html"))
{
// Insert the text for this merge field as HTML data, using DocumentBuilder.
DocumentBuilder builder = new DocumentBuilder(e.Document);
builder.MoveToMergeField(e.DocumentFieldName);
builder.InsertHtml((string)e.FieldValue);
// The HTML text itself should not be inserted.
// We have already inserted it as an HTML.
e.Text = "";
}
}
void IFieldMergingCallback.ImageFieldMerging(ImageFieldMergingArgs e)
{
// Do nothing.
}
}
Hello Support
If we have images in Editor Content then how will images go in Mail merge .
Example : I have a content in Editor with few images also . can the images also go in mail merge field as you have given above .
Regards
Atul
Hi Atul,