Following [https://blog.aspose.com/2021/11/01/copy-content-of-a-word-document-to-another-in-csharp/] we want to copy contents from text file and append it to a final word document. The data is copied but the font is not using it’s default (Times New Roman) and is just keeping the source (text files) one, even though we added the param: ImportFormatMode.UseDestinationStyles. Code:
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Writeln("This is a test paragraph before"); Font font = builder.Font; font.Name = "Arial"; font.Bold = true; builder.Writeln("This is a test paragraph after"); Document docFirstPage = new Document(Path.Combine(pathToTemp, "Townlist.txt")); //docFirstPage.FirstSection.PageSetup.SectionStart = SectionStart.Continuous; //doc.AppendDocument(docFirstPage, ImportFormatMode.UseDestinationStyles); builder.InsertDocument(docFirstPage, ImportFormatMode.UseDestinationStyles); doc.Save(pathToTemp + "TestFont.docx");
Tried to at least change the font (as per lines 5-8) and is not working as well. Tried adding a custom style (instead of font instance) and still didn’t changed.
Just need advise on how to keep the default Aspose.Words font (Times New Roman) and not to change to the source ones.