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

Free Support Forum - aspose.com

Existing style fonts change after html is inserted

Using the below code the heading that is in before.docx comes though as Arial. In the after.docx it has become Times New Roman.

Using Aspose.Words 14.3

var doc = new Aspose.Words.Document();
Paragraph paragraph = new Paragraph(doc);
paragraph.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;
paragraph.AppendChild(new Run(doc, “Test”));
Paragraph paragraph2 = new Paragraph(doc);
paragraph2.AppendChild(new Run(doc, “Test2”));

doc.FirstSection.Body.AppendChild(paragraph);
doc.FirstSection.Body.AppendChild(paragraph2);

doc.Save(@“c:\temp\before.docx”);

var builder = new Aspose.Words.DocumentBuilder(doc);
builder.MoveToDocumentEnd();
builder.InsertHtml(“

x

”);

doc.Save(@“c:\temp\after.docx”);
Hi Phillip,

Thanks for your inquiry. We had already logged this issue as WORDSNET-9320 (InsertHtml method changes formatting of Heading styles) in our issue tracking system. Actually this is a missing feature. While using InsertHtml method there is no control over merging of styles of the HTML fragment and the target document.

You will be notified via this forum thread once this feature is available. We apologize for your inconvenience.

Thanks Tahir,


This is mainly a problem for us because it didn’t used to function this way. It looks like the change was made in 13.10 because 13.9 leaves the existing styles untouched.
Hi Phillip,

Thanks for your inquiry.

Please accept my apologies for your inconvenience. Yes, InsertHtml works in 13.9.0. However, there is a problem with this method. The problem with InsertHtml is that there is no control over merging of styles of the HTML fragment and the target document. This is a missing feature in Aspose.Words. We will add this missing feature in Aspose.Words and update you via this forum thread once this feature is available.

Thanks for your patience.

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


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