- Home
- Forum
- ASP.NET Web Forms (Classic)
- Advanced formatting of mail merge fields.
Advanced formatting of mail merge fields.
Hello.
I am currently evaluating DocIO.
I would like to know if there is a way to find a merge field in the document, delete it and on its location write formatted text (superscript, striketrough, red, blue...).
E.g. find FirstName field, replace it with actual value, and format it so that first character is red.
If this is not possible with merge fields can it be done with bookmarks or find replace option.
These fields can be located inside tables too.
Thanks in advance.
I am currently evaluating DocIO.
I would like to know if there is a way to find a merge field in the document, delete it and on its location write formatted text (superscript, striketrough, red, blue...).
E.g. find FirstName field, replace it with actual value, and format it so that first character is red.
If this is not possible with merge fields can it be done with bookmarks or find replace option.
These fields can be located inside tables too.
Thanks in advance.
SIGN IN To post a reply.
7 Replies
BP
Bhuvaneswari P
Syncfusion Team
April 18, 2007 10:13 AM UTC
Hi Srdjan,
Currently we do not have support to replace a merge field with formatting. But we can replace the text without formatting in the merge field.
Herewith I have attached a sample for you reference.
http://websamples.syncfusion.com/samples/DocIO.Windows/F59562/main.htm
Regarding delete the merge field. We do not have any direct method. However, this can be done by using the below code:
document.Replace( new Regex( a[3].ToString() ), "");
Please let me know if you have any other queries.
Thank you for your interest in Syncfusion products.
Best Regards,
Bhuvaneswari.
Currently we do not have support to replace a merge field with formatting. But we can replace the text without formatting in the merge field.
Herewith I have attached a sample for you reference.
http://websamples.syncfusion.com/samples/DocIO.Windows/F59562/main.htm
Regarding delete the merge field. We do not have any direct method. However, this can be done by using the below code:
document.Replace( new Regex( a[3].ToString() ), "");
Please let me know if you have any other queries.
Thank you for your interest in Syncfusion products.
Best Regards,
Bhuvaneswari.
BP
Bhuvaneswari P
Syncfusion Team
April 18, 2007 01:02 PM UTC
Hi Srdjan,
Formatting of mail merge fields can be done by using the MergeField event handler.
Code Snippet:
document.MailMerge.MergeField += new MergeFieldEventHandler(MailMerge_MergeField);
document.MailMerge.Execute ( dataView );
void MailMerge_MergeField(object sender, MergeFieldEventArgs args)
{ //Formatting the text
args.CharacterFormat.TextColor = Color.Red;
}
Herewith I have attached the sample for your reference:
http://websamples.syncfusion.com//samples/DocIO.Windows/F59562_1//main.htm
Sorry for the confusions.
Please let me know if you have any other queries.
Best Regards,
Bhuvaeswari
Formatting of mail merge fields can be done by using the MergeField event handler.
Code Snippet:
document.MailMerge.MergeField += new MergeFieldEventHandler(MailMerge_MergeField);
document.MailMerge.Execute ( dataView );
void MailMerge_MergeField(object sender, MergeFieldEventArgs args)
{ //Formatting the text
args.CharacterFormat.TextColor = Color.Red;
}
Herewith I have attached the sample for your reference:
http://websamples.syncfusion.com//samples/DocIO.Windows/F59562_1//main.htm
Sorry for the confusions.
Please let me know if you have any other queries.
Best Regards,
Bhuvaeswari
SZ
Srdjan Zivojinovic
April 25, 2007 02:21 PM UTC
Hi,
Thanks for the quick reply.
Can I differently format parts of the replaced field using Merge Field event handler.
I have attached how I would like template to look like and what output will be.
Notice how characters are differently formatted. This is based on some rules in the application.
Is there any way to accomplish this. If so can you please explain how (bookmarks, find replace).
I have partially made it work with the bookmarks, but bookmarks are not working for last two cells (no value is filled in place of bookmark).
Here is the code example:
foreach (Bookmark bookmark in document.Bookmarks)
{
bk.MoveToBookmark(bookmark.Name,false,true);
text = "Red, strikethrough";
range = bk.InsertText (text);
range.CharacterFormat.Strikeout = true;
range.CharacterFormat.TextColor = System.Drawing.Color.Red;
range = bk.InsertText("Blue, underline");
range.CharacterFormat.UnderlineStyle = UnderlineStyle.Single;
range.CharacterFormat.TextColor = System.Drawing.Color.Blue;
}
Thanks in advance.
field_format_example.zip
Thanks for the quick reply.
Can I differently format parts of the replaced field using Merge Field event handler.
I have attached how I would like template to look like and what output will be.
Notice how characters are differently formatted. This is based on some rules in the application.
Is there any way to accomplish this. If so can you please explain how (bookmarks, find replace).
I have partially made it work with the bookmarks, but bookmarks are not working for last two cells (no value is filled in place of bookmark).
Here is the code example:
foreach (Bookmark bookmark in document.Bookmarks)
{
bk.MoveToBookmark(bookmark.Name,false,true);
text = "Red, strikethrough";
range = bk.InsertText (text);
range.CharacterFormat.Strikeout = true;
range.CharacterFormat.TextColor = System.Drawing.Color.Red;
range = bk.InsertText("Blue, underline");
range.CharacterFormat.UnderlineStyle = UnderlineStyle.Single;
range.CharacterFormat.TextColor = System.Drawing.Color.Blue;
}
Thanks in advance.
field_format_example.zip
BP
Bhuvaneswari P
Syncfusion Team
April 27, 2007 12:01 PM UTC
Hi Srdjan,
Thanks a lot for your file.
I was able to reproduce the issue bookmarks are not working for last two cells. This issue has been fixed in our new version 5.1. Could you please open a Direct-Trac incident with regard to this issue, so that we can provide you the link to download the v5.1 version. Please open the new incident with the below subject.
Subject: 59969 - Advanced formatting of mail merge fields.
Herewith I have attached the correct output document that was generated using the new version 5.1
http://www.syncfusion.com/Support/user/uploads/Sample_468e0563.doc
It is not possible to format the part of the Merge Field.
Please let me know if you have any other queries.
Thank you for your interest in Syncfusion products.
Best Regards,
Bhuvaneswari.
Thanks a lot for your file.
I was able to reproduce the issue bookmarks are not working for last two cells. This issue has been fixed in our new version 5.1. Could you please open a Direct-Trac incident with regard to this issue, so that we can provide you the link to download the v5.1 version. Please open the new incident with the below subject.
Subject: 59969 - Advanced formatting of mail merge fields.
Herewith I have attached the correct output document that was generated using the new version 5.1
http://www.syncfusion.com/Support/user/uploads/Sample_468e0563.doc
It is not possible to format the part of the Merge Field.
Please let me know if you have any other queries.
Thank you for your interest in Syncfusion products.
Best Regards,
Bhuvaneswari.
BP
Bhuvaneswari P
Syncfusion Team
April 27, 2007 12:19 PM UTC
Hi Srdjan,
Thanks a lot for your file.
I was able to reproduce the issue bookmarks are not working for last two cells. This issue has been fixed in our new version 5.1. Could you please open a Direct-Trac incident with regard to this issue, so that we can provide you the link to download the v5.1 version. Please open the new incident with the below subject.
Subject: 59562 - Advanced formatting of mail merge fields.
Herewith I have attached the correct output document that was generated using the new version 5.1
http://www.syncfusion.com/Support/user/uploads/Sample_468e0563.doc
It is not possible to format the part of the Merge Field.
Please let me know if you have any other queries.
Thank you for your interest in Syncfusion products.
Best Regards,
Bhuvaneswari.
Thanks a lot for your file.
I was able to reproduce the issue bookmarks are not working for last two cells. This issue has been fixed in our new version 5.1. Could you please open a Direct-Trac incident with regard to this issue, so that we can provide you the link to download the v5.1 version. Please open the new incident with the below subject.
Subject: 59562 - Advanced formatting of mail merge fields.
Herewith I have attached the correct output document that was generated using the new version 5.1
http://www.syncfusion.com/Support/user/uploads/Sample_468e0563.doc
It is not possible to format the part of the Merge Field.
Please let me know if you have any other queries.
Thank you for your interest in Syncfusion products.
Best Regards,
Bhuvaneswari.
PI
Pablo Islas
September 3, 2019 03:47 PM UTC
Is it still the case that we can not format the text to be merged? I am trying to merge rich text into a word document and cant seem to find any documentation on how to do so aside from this.
PR
Poorani Rajendran
Syncfusion Team
September 4, 2019 10:01 AM UTC
Hi Pablo,
Thank you for contacting Syncfusion support.
To meet your requirement, we suggest you use ImportContent API to merge the RTF document into Word document and the text of the RTF Word document can be formatted before merging into Word document. We have prepared a sample application for the same and it can be downloaded from the below link:
https://www.syncfusion.com/downloads/support/forum/59562/ze/CreateWordSample1812251132
Note: Please find the input Word document template in the “Data” folder of above sample application.
Please refer the below UG documentation link to know more about working with merging Word documents using DocIO:
https://help.syncfusion.com/file-formats/docio/working-with-word-document?cs-save-lang=1&cs-lang=csharp#merging-word-documents
Please let us know if you have any other questions.
Regards,
Poorani Rajendran
Thank you for contacting Syncfusion support.
To meet your requirement, we suggest you use ImportContent API to merge the RTF document into Word document and the text of the RTF Word document can be formatted before merging into Word document. We have prepared a sample application for the same and it can be downloaded from the below link:
https://www.syncfusion.com/downloads/support/forum/59562/ze/CreateWordSample1812251132
Note: Please find the input Word document template in the “Data” folder of above sample application.
Please refer the below UG documentation link to know more about working with merging Word documents using DocIO:
https://help.syncfusion.com/file-formats/docio/working-with-word-document?cs-save-lang=1&cs-lang=csharp#merging-word-documents
Please let us know if you have any other questions.
Regards,
Poorani Rajendran
SIGN IN To post a reply.
- 7 Replies
- 4 Participants
-
SZ Srdjan Zivojinovic
- Apr 17, 2007 12:43 PM UTC
- Sep 4, 2019 10:01 AM UTC