Skip to main content

How to: Insert RTF text to a document

Use the RichEditCommands.insertRtf command to add formatted RTF content at the specified position.

var RTFstring = '{\\rtf1\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\pard This is some { \\b bold } text.\\par}';  
var insertPosition = 2;
var subDocumentId = richEdit.document.mainSubDocument.id;
var callbackFunc = function (interval, isRtfValid) {}
richEdit.commands.insertRtf.execute(RTFstring, insertPosition);
richEdit.commands.insertRtf.execute(RTFstring, insertPosition, subDocumentId);
richEdit.commands.insertRtf.execute(RTFstring, insertPosition, subDocumentId, callbackFunc);