in another post I already described a very simlar problem, but the former solution doesn't help here.
What I am doing is generate a paragraph, get a style (called "SectionContent") from the documents StyleCollection and apply it to this paragraph.
After that, I append html to the paragraph. If I inspect the paragraph object, I can find the style and the character format.
In our case: FontName = Arial Narrow Size = 12.
When I save the document and open it in word, the added text (html) has a copied style-format ("SectionContent + 12px") with fontsize set to 12.
! Looks like the generated TextRange items are not affected by the paragraph style !
Please find the related code below:
- Code: Select all
var outputDoc = new Spire.Doc.Document();
outputDoc.LoadFromFileInReadMode(templatePath, Spire.Doc.FileFormat.Docx);
var contentStyle = outputDoc.Styles.FindByName("SectionContent");
var docSection = (Spire.Doc.Section)outputDoc.Sections.FirstItem;
docSection.Paragraphs.Clear();
var pContent = docSection.AddParagraph();
pContent.ApplyStyle(contentStyle.StyleId);
pContent.AppendHTML("<div>Is this Arial Narrow 9 Pt?</div>");
var docStream = new MemoryStream();
outputDoc.SaveToStream(docStream, Spire.Doc.FileFormat.Docx);
Best regards,
Arne Weber