Free Support Forum - aspose.com

Aspose.Words can convert Text to RTF String format in Asp.net Web application

Simple Text:-
syed asif

RTF String:-

{\rtf1\sste18000\ansi\deflang1033\ftnbj\uc1\deff0{\fonttbl{\f0 \froman Times New Roman;}{\f1 \fswiss \fcharset178 Arial;}{\f2 \fswiss \fcharset177 Arial;}{\f3 \fswiss \fcharset0 Arial;}{\f4 \froman \fcharset0 Times New Roman;}}{\colortbl ;\red255\green255\blue255 ;\red0\green0\blue0 ;}{\stylesheet{\f0\fs24 Normal;}{\cs1 Default Paragraph Font;}}{\*\revtbl{Unknown;}}\paperw12240\paperh15840\margl1800\margr1800\margt1440\margb1440\headery720\footery720\nogrowautofit\deftab720\formshade\fet4\aendnotes\aftnnrlc\pgbrdrhead\pgbrdrfoot\sectd\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\headery720\footery720\sbkpage\pgncont\pgndec\plain\plain\f0\fs24\pard\plain\f0\fs24 syed \hich\f4\dbch\f4\loch\f4\b\ul\i asif\plain\f0\fs24\par}



thanks in Advance:

Hi

Thanks for your request. There is no way to convert a particular node to RTF. However, you can convert a Document to RTF. So if you need to get RTF of a particular node, you should copy this node to new document and use code like the following to get RTF string:

public string ConvertDocumentToRtf(Document doc)

{

string rtf = string.Empty;

// Save docuemnt to MemoryStream in Rtf format

using (MemoryStream rtfStream = new MemoryStream())

{

doc.Save(rtfStream, SaveFormat.Rtf);

// Get Rtf string

rtf = Encoding.UTF8.GetString(rtfStream.GetBuffer(), 0, (int)rtfStream.Length);

}

return rtf;

}

Hope this helps.

Best regards,