We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Advanced formatting of mail merge fields.

Thread ID:

Created:

Updated:

Platform:

Replies:

59562 Apr 17,2007 08:43 AM Apr 27,2007 08:19 AM ASP.NET Web Forms (Classic) 5
loading
Tags: DocIO
Srdjan Zivojinovic
Asked On April 17, 2007 08:43 AM

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.

Bhuvaneswari P [Syncfusion]
Replied On April 18, 2007 06:13 AM

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.

Bhuvaneswari P [Syncfusion]
Replied On April 18, 2007 09:02 AM

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

Srdjan Zivojinovic
Replied On April 25, 2007 10:21 AM

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

Bhuvaneswari P [Syncfusion]
Replied On April 27, 2007 08:01 AM

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.

Bhuvaneswari P [Syncfusion]
Replied On April 27, 2007 08:19 AM

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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;