Hi Aspose,
i m stuck with a problem that while inserting the merge field in a word template i am marking it as Bold…
when in my code i replace it with the value the field loses its formatting(Bold) and appears as normal text where as it should be bold.
can u please guide me on this .
I am also posting the question in forums just in case some other may answer thie.
Thanks
DevCPP
Hello,
Thank you for your inquiry.
Could you please attach your source document and a simple test application, or an example of code used, which could simulate the problem. I will analyze the issue and provide you more detailed information.
Hi there,
Thanks for your inquiry.
Please ensure you are inserting the field using the MERGEFORMAT switch. This switch causes the formatting on the original field to be carried over to the merged result.
i have a sample template attached with this post.Its Name is MasterLetter.rtf.
u must be able to see the Bold and Colored Merge Codes.
but when i expand it using the following code the merge code styles are lost for first sentence ie where there are other styles in the sentence.
whereas «OfficeName» retains** style as it is the only word in that sentence.
can u help me on this.
DocumentBuilder builder = new DocumentBuilder(docsrc);
string fieldname = fieldnames[1]; //fieldNames Array contains all the Mergecode Names
bool found = builder.MoveToMergeField(fieldname);
while (found)
{
Paragraph pg = builder.CurrentParagraph;
if (pg != null)
{
if (!pg.IsInCell)
{
Font fnt = pg.ParagraphBreakFont;
builder.Font.Name = SrcFont.Name;
builder.Font.LocaleId = SrcFont.LocaleId;
builder.Font.LocaleIdFarEast = SrcFont.LocaleIdFarEast;
builder.Font.NameAscii = SrcFont.NameAscii;
builder.Font.Bold = SrcFont.Bold;
builder.Font.Color = SrcFont.Color;
builder.Font.Italic = SrcFont.Italic;
}
}
try
{
string fieldvalue = (string) fieldvalues[i];
builder.Write(fieldvalue);
}
catch (Exception ex)
{}
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.