I have a word document with some existing content. In the document I already have a table with rows and cells and structed document tags. Now I am manipulating the document in C# by using Aspose.Words. I have a couple of pre-formatted contents as RTF which I have to insert into the document in various positions.
According to my understand I think I have to created another structed document tag of type “RichText”. This has a Paragraph inside which as a Run inside. In the Run element I am setting the text property to the RTF content. I thought because of type “RichText” the content is then transformed with all its styling and formatting. But instead the RTF content is printed with its markup to the document.
This is my code where I try to achive my goal:
string contentAsRichText = @"{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard This is some {\b bold } text.\par }";
var richTextTag = new StructuredDocumentTag(documentBase, SdtType.RichText, MarkupLevel.Block);
var paragraph = new Paragraph(documentBase);
var run = new Run(documentBase)
{
Text = contentAsRichText
};
paragraph.Runs.Add(run);
richTextTag.ChildNodes.Add(paragraph);
tableCellNode.PrependChild(richTextTag);
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.