Font formatting is changed after appending one document to another using C#

Hi,
I have included file TrackChange_Input.docm as a source file to the package. When run application, new file TrackChange_Output.docm will be generated. It has different Normal Style font comparing with source (TrackChange_Input.docm) document. Also all ‘Track Changes’ labels are shown the right panel which is not expected.
Thank you for help!

Hi Inga,

Thanks for your query. Please call Document.AcceptAllRevisions() method to accepts all tracked changes in the your document.

Please read following documentation link for your kind reference.

https://docs.aspose.com/words/net/track-changes-in-a-document/

string fileNameInput = MyDir + "TrackChange_Input.docm";
string fileNameOutput = MyDir + "TrackChange_Output.docm";
Document outdoc = new Aspose.Words.Document();
CompositeNode outCompositeNode = outdoc.LastSection.Body.LastParagraph.ParentNode;
Node outNode = outdoc.LastSection.Body.LastParagraph as Node;
Document inputDoc = new Aspose.Words.Document(fileNameInput);
inputDoc.AcceptAllRevisions();
Aspose.Words.Section inputSec = inputDoc.LastSection;
NodeImporter importer = new NodeImporter(inputDoc, outdoc, ImportFormatMode.KeepSourceFormatting);
foreach (Node srcNode in inputSec.Body)
{
    Node newNode = importer.ImportNode(srcNode, true);
    outCompositeNode.InsertAfter(newNode, outNode);
    outNode = newNode;
}
outdoc.Save(fileNameOutput);
inputDoc = null;
outdoc = null;

Hope this helps you. Please let us know if you have any more queries.

Hi Tahir,
This sounds as a workaround for us. But, unfortunately, it is not acceptable by our client. Client is complaining about font changes from Times New Roman to Calibri/11 for highlighted text. They expect to have the same font as in source document.
Can you please fix it?

Hi Inga,

Thanks for sharing the more information. I have tested the scenario and have not found the issue while using latest version of Aspose.Words for .NET. Please us the latest version of Aspose.Words for .NET.

Please find the output file in attachment. I have used your code to generate this file.

Hi Tahir,
New version Words.dll 11.5 does not help. (I do not have to use method AceptAllRevisions()). I have attached my Output document and image.

Hi Inga,

Thanks for your inquiry.

While using the latest version of Aspose.Words i.e. v11.5.0, I was unable to reproduce this issue on my side either. Could you please double check if you are using the latest version (11.5.0)? You can dynamically check if you’re referencing the correct DLL by using the following code snippet:

System.Reflection.Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach(System.Reflection.Assembly assembly in assemblies)
{
    System.Reflection.AssemblyName assemblyName = assembly.GetName();
    if (assemblyName.Name.Contains("Aspose.Words"))
        Console.WriteLine("Aspose.Words Version Number: " + assemblyName.Version.ToString());
}

Moreover, I have attached the Word document (out.docx), i.e. generated on my side, here for your reference.

If we can help you with anything else, please feel free to ask.

Best Regards,

Hi,
I am using the Word.dll 11.5. We do not have to use AcceptAllRevisions() method.
Can you check please whether your Word Normal Style font is Calibri, size 11?
I have Calibri/11 font for Normal style. So the highlighted text also have Calibri/11 font, but it should not be. (Since the source file has only Times New Roman).
Thank you!

Hi Inga,

I have managed to reproduce the same issue at my side. I have logged this issue as WORDSNET-6607 in our issue tracking system. 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-6607) have been fixed in this .NET update and this Java update.

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