PRODUCTS   DOWNLOAD PURCHASE SUPPORT BLOG  COMPANY  
 
Key Features
Create DOCX
Create RTF
>>Convert DOCX <=> RTF
Mail Merge and Reporting
Mail Merge: Simple envelope
Download trial
Purchase
Code Samples
Documentation
What's New
Tutorials & Videos
How to generate a DOCX document within .Net and C# (Video).
How to create an RTF document in C# and .Net (Video).
How can a Word (*.docx and *.rtf) document be created in C# and .Net.
Mail Merge: generate a simple envelope using C# and Document .Net.
How programmatically convert between DOCX and RTF in C# using Document .Net library?.

"How programmatically convert between DOCX and RTF in C# using Document .Net library?"

Introduction

If you are looking for a solution to programmatically convert DOCX to RTF and vice versa in C# or VB.Net, you are in the right place!

How programmatically convert between DOCX and RTF in C# using Document .Net library?
  • Document .Net library is written in 100% managed C#
  • DOCX - Office Open XML, ECMA-376
  • RTF - Rich Text Format Specification 1.8
  • All features are supported
  • No MS Office Automation

Document .Net is 100% managed C# assembly (SautinSoft.Document.dll) which gives you API to load, parse and create DOCX and RTF documents.

The library is absolutely standalone and does not require Microsoft Office or any others.

Performance

At a machine with Intel Core i5-3337U and 4GB of RAM the Document .Net generates a simple DOCX document (one page filled by formatted text) without saving it to HDD:

  • 1000 documents by 0.45 sec.
  • 10000 documents by 3.61 sec.

Implementation and code samples

To get the full set of API to operate with DOCX or RTF, you have to only add a reference to "SautinSoft.Document.dll".

It's easy to add reference to SautinSoft.Document.dll

1. Example 1: Convert DOCX to RTF in C# application:

using System;
using System.IO;
using SautinSoft.Document;

namespace Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Step 1: Load a docx document.
            DocumentCore dc = DocumentCore.Load(@"d:\Paper.docx", LoadOptions.DocxDefault);

            // Step 2: Save the document to rtf format.
            dc.Save(@"d:\Paper.rtf", SaveOptions.RtfDefault);
        }
    }
}

2. Example 2: Convert RTF to DOCX in C# application:

using System;
using System.IO;
using SautinSoft.Document;

namespace Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Step 1: Load a rtf document.
            DocumentCore dc = DocumentCore.Load(@"d:\Paper.rtf", LoadOptions.RtfDefault);

            // Step 2: Save the document to docx format.
            dc.Save(@"d:\Paper.docx", SaveOptions.DocxDefault);
        }
    }
}

3. Example 3: Loop between DOCX and RTF in C#:

using System;
using System.IO;
using System.Collections.Generic;
using SautinSoft.Document;

namespace Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Working directory
            string startingPath = @"D:\Start.docx";

            // Set desired number of converting loops.
            int loops = 5;

            string workingDir = Path.GetDirectoryName(startingPath);
            string fileName = Path.GetFileName(startingPath);
            string name = Path.GetFileName(startingPath); ;
            string filePath = Path.Combine(workingDir, fileName);

            List<string> extns = new List<string>() { ".rtf", ".docx" };

            for (int i = 0; i < loops; i++)
            {
                DocumentCore dc = DocumentCore.Load(filePath);
                string extn = Path.GetExtension(fileName).ToLower();
                // invert extension
                int ind = extns.FindIndex((s) => (extn == s));
                extns.Reverse();
                extn = extns[ind];

                fileName = Path.GetFileNameWithoutExtension(name) + (i + 1).ToString() + extn;
                filePath = Path.Combine(workingDir, fileName);

                dc.Save(filePath);
                dc = null;
            }
        }
    }
}


Requrements and Technical Information

     Requires only .Net 4.0 or above. Our product is compatible with all .Net languages and supports all Operating Systems where .Net Framework can be used.

Note that «Document .Net» is entirely written in managed C#, which makes it absolutely standalone and an independent library. Of course, No dependency on Microsoft Word.



Reasonable prices

     The library offers for developers comprehensive API to do all what they want with DOCX, RTF, PDF and Text formats at reasonably prices. The main point of interest is that «Document .Net» is less expensive than all of its more or less popular counterparts. For example, a single license of Document .Net - DOCX Edition cost $330, Document .Net - RTF Edition also cost $330 and the Total Edition starts from $890.


Download

To see this functionality firsthand, download the freshest «Document .Net» with code examples, 12.3 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.