PRODUCTS   DOWNLOAD PURCHASE SUPPORT BLOG  COMPANY  
 
Key Features
>>HTML to RTF
HTML to Text
Merge RTF
Download trial
Purchase
Online-demo
Documentation
What's New
Tutorials & Videos
How to convert multiple HTML files to a single RTF using C# .Net platform.

"How to write a function to convert HTML to RTF in C# for 15 minutes?"

How to write a function to convert HTML to RTF in C# for 15 minutes?

Introduction

    Imagine, that in 15 minutes after reading this text you will be able to provide API for your application to convert HTML page into RTF documents, using C# or VB.Net.
            SautinSoft.HtmlToRtf h = new SautinSoft.HtmlToRtf();

            string htmlString = @"Hello World!";
            string rtfString = h.ConvertString(htmlString);
          
To get the ability of HTML conversion in you .Net application:
  • Download the latest «HTML to RTF .Net» SDK.
  • Follow to the "Solution Explorer" tab and add a reference to the "SautinSoft.HtmlToRtf.dll".
Not too shabby! Now you can operate with HtmlToRtf class which provides you by various methods and properties to convert HTML as MemoryStream, String, Files, URI and so forth:
How looks HtmlToRtf .Net class

Download HTML to RTF .Net Online Demo


Have a Question?

You have a question, need a support or a code example: ask our support team at support@sautinsoft.com. We will help you quickly and with pleasure.

At the final point of this page we've prepared five various examples to convert HTML to RTF.

Five examples to convert HTML to RTF in C# and VB.Net

1. Simple conversion of HTML file to RTF file in C#:

            SautinSoft.HtmlToRtf h = new SautinSoft.HtmlToRtf();

            string htmlFile = @"d:\Resurrection.html";
            string rtfFile = Path.ChangeExtension(htmlFile, ".rtf");

            h.ConvertFile(htmlFile, rtfFile);
2. Convert HTML to RTF in memory using C#; Set page size to Letter/Landscape, add page numbers:
            SautinSoft.HtmlToRtf h = new SautinSoft.HtmlToRtf();

            string htmlFile = @"d:\Resurrection.html";
            string htmlString = File.ReadAllText(htmlFile);

            // Let's set some page options.
            h.PageStyle.PageSize.Letter();
            h.PageStyle.PageOrientation.Landscape();

            h.PageStyle.PageNumbers.Format = "Page {page} of {numpages}";
            h.PageStyle.PageNumbers.AlignH = SautinSoft.HtmlToRtf.eAlign.Center;
            h.PageStyle.PageNumbers.AlignV = SautinSoft.HtmlToRtf.eAlign.Bottom;

            // Start the conversion.
            string rtfString = h.ConvertString(htmlString);
3. Convert HTML to RTF in memory using VB.Net; Set page size to Letter/Landscape, add page numbers:
			Dim h As New SautinSoft.HtmlToRtf()

			Dim htmlFile As String = "d:\Resurrection.html"
			Dim htmlString As String = File.ReadAllText(htmlFile)

			' Let's set some page options.
			h.PageStyle.PageSize.Letter()
			h.PageStyle.PageOrientation.Landscape()

			h.PageStyle.PageNumbers.Format = "Page {page} of {numpages}"
			h.PageStyle.PageNumbers.AlignH = SautinSoft.HtmlToRtf.eAlign.Center
			h.PageStyle.PageNumbers.AlignV = SautinSoft.HtmlToRtf.eAlign.Bottom

			' Start the conversion.
			Dim rtfString As String = h.ConvertString(htmlString)
4. Convert HTML to RTF in C#; Add a custom page header from HTML, add footer from another RTF:
            SautinSoft.HtmlToRtf h = new HtmlToRtf();
            string htmlPath = @"d:\The Living.html";
            string rtfPath = Path.ChangeExtension(htmlPath, ".rtf");

            // Add a header from HTML string.
            h.PageStyle.PageHeader.Html("This is a bold italic line.");

            // Add a footer from RTF file.
            h.PageStyle.PageFooter.FromRtfFile(@"d:\footer.rtf");

            // Make the conversion of HTML to RTF.
            h.ConvertFile(htmlPath, rtfPath);
5. Convert HTML to RTF and extract all images from HTML (local, remote, even embedded within base-64) in C#:
            SautinSoft.HtmlToRtf h = new HtmlToRtf();
            string htmlPath = @"d:\Fathers and Sons.html";
            string htmlString = File.ReadAllText(htmlPath);
            string rtfPath = Path.ChangeExtension(htmlPath, ".rtf");

            List<HtmlToRtf.SautinImage> imgList = new List<HtmlToRtf.SautinImage>();

            h.BaseURL = @"d:\";

            // Convert HTML to and place all images inside imgList.
            h.ConvertString(htmlString, imgList);

            // Save all images to HDD.
            foreach (HtmlToRtf.SautinImage img in imgList)
            {
                img.Img.Save(String.Format(@"d:\{0}.png", img.Cid));
            }

If anyone needs a code sample in C#, VB.Net, ASP.Net etc "How to convert HTML to RTF", email us at support@sautinsoft.com or ask at Online Chat (right-bottom corner of this page). We'll help you certainly!


Requrements and Technical Information

     Requires only .Net 2.0 or above. Our product is compatible with all .Net languages and supports all Operating Systems where .Net Framework can be used. Note that «HTML to RTF .Net» is entirely written in managed C#, which makes it absolutely standalone and an independent library.



Reasonable prices

     The library offers developers high quality conversion at reasonably prices. The main point of interest is that «HTML to RTF .Net» is less expensive than all of its more or less popular counterparts. For example, a single license cost $239 with no additional fees or royalties!


Download

To see this functionality firsthand, download the freshest «HTML to RTF .Net» with code examples, 4.82 Mb.

 
 
Products Downloads Support Company
Buy now
Follow us on Google Plus SautinSoft on Facebook SautinSoft on Twitter SautinSoft on Youtube Our Blog
Copyright © 2002 - 2017 SautinSoft (started from sautin.com). All rights reserved.