Wednesday, 1 February 2012

How to convert Rtf to HTML format for Windowsform using C#:

Hi.. here you can find how to change ".Rtf" format data to "Html" for Report viewer in RDLC file which we saved in Richtextbox field.. here its just a small it'll work only for 30000 characters that's for just you first download a
Reference file(.DLL)
and then add it to your Reference file in VS of your Project then do this Code:
In Add button :
Before saving you have to Convert the code,
SautinSoft.RtfToHtml rtfhtml = new SautinSoft.RtfToHtml();
            rtfhtml.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.HTML_32;
            rtfhtml.Encoding = SautinSoft.RtfToHtml.eEncoding.UTF_8;
            string rtfFile = rchtxtReportEntry.Rtf;
            string htmlString = null;
            htmlString = rtfhtml.ConvertString(rtfFile);
In above htmlstring you'll get your converted HTML code along with some extra text which is crested by that authorised person for full version he gives the link as "Trail version go www.abc.com" like advertisement in that for who want more than that you can also download that from that hyper text but for small Applications I'm removing that Extra code from that htmlstring make that by the following code :
int htmllength = htmlString.Length;
int cutt = htmllength - 210;
string cut = htmlString.Remove(cutt, 194);
Here 210 represents that the extra string starting INDEX, and that we have ending tags also where that 194 is for not to remove the last ENDING tags

Here it'll help you to make Remove that extra advertisement,your removing from your HTML.
Then retrieve your data when your retrieving you'll get your code how you saved...
Enjoy...........

No comments:

Post a Comment