We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Style-based Fonts Lost in Merge When InsertHtml is Used

We set the “Heading 1” style font to Arial, then did a simple mail merge without regions. Afterwards, the font is set to Times New Roman, even though it should be Arial as defined in the styles. This only occurs when InsertHtml is used – if that line is commented out, the font shows up properly.


Any ideas what’s going on? I’ve attached the input file (WordMerge.docx) and the output file.

Code

            var inputStream = System.IO.File.OpenRead(@“C:\Users\Tim\Dropbox\WordMerge.docx”);
var document = new Aspose.Words.Document(inputStream);

        document.MailMerge.FieldMergingCallback = new HandleMergeField();
        document.MailMerge.Execute(new string[] { 
            "Position Summary:richtext", 
            "Position Title" 
        }, new object[] { 
            "<p>Summary</p>", 
            "Title" 
        });

        document.Save(@"c:\Users\Tim\Dropbox\MergeFieldText_out.docx");</pre></code>

Merge Field Handler

    class HandleMergeField : IFieldMergingCallback
{
void IFieldMergingCallback.FieldMerging(FieldMergingArgs e)
{
var builder = new DocumentBuilder(e.Document);

        if (e.FieldName.ToLower().Contains(":richtext"))
        {
            builder.MoveToMergeField(e.FieldName);
            builder.InsertHtml((string)e.FieldValue);
            return;
        }
    }

    void IFieldMergingCallback.ImageFieldMerging(ImageFieldMergingArgs e)
    {
    }
}</pre></code></div>

Hi Brett,

Thanks for your inquiry.

I have tested the scenario and have manged to reproduce the same issue at my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-9409. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-9409) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(2)