70002529 Get Set RTF (Rich Text Format) contents with vdMtext object

Article 70002529
Type Wish
Product Engine
Version 1005
Date Added 5/27/2024 12:00:00 AM
Fixed 11.1.5.0 (5/27/2024 12:00:00 AM)
Submitted by Wayne Romer

Summary

Get Set RTF (Rich Text Format) contents with vdMtext object

Solution

In version 11.1.5 following new methods was added to vdMtext object
contentsRTF Returns an RTF encoded string that is a translated version of the contents.
and
setContentsRTF Sets the character content of this MText entity from the RTF-encoded text string.

Example

System.IO.TextReader reader = new System.IO.StreamReader(@"test.rtf"); ;
string str = reader.ReadToEnd();
vdMText txt = new vdMText(doc);
txt.setContentsRTF(str);
doc.Model.Entities.AddItem(txt);
//export mtext contents to a new .rtf file
System.IO.TextWriter tw = new StreamWriter(@"test-new.rtf");
tw.Write(txt.contentsRTF());
tw.Close();

Send comments on this topic.