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 create RTF document in C# and .Net for 10 minutes?"

Introduction

Imagine, that in 10 minutes after reading this text you will be able to provide API for your application to create a custom RTF document, using C# or VB.Net.

How programmatically create RTF document in C# and .Net for 10 minutes?

Document .Net is 100% managed C# assembly (SautinSoft.Document.dll) which gives you API to generate documents in RTF format.

The control is designated for manipulation with existing and creation of new documents in Rich Text Format:

  • Insert formatted text, paragraphs, images, plain and nested tables.
  • Specify page size and orientation (height, width, margin vals).
  • Specify font type/name, style, and size.
  • Add page numbering and page breaks, headers and footers.
  • Add sections and pages, bookmarks, Table of contents.
  • Full Unicode support.

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 RTF 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 ability to create RTF documents in your application, you have to only add a reference to "SautinSoft.Document.dll".

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

1. Let's create a simple RTF document with a single line in C#:

Hello My Friend.docx
            // Let's create a simple RTF document.
            DocumentCore rtf = new DocumentCore();
            
            rtf.Content.End.Insert("Hello my Friend!", new CharacterFormat() { Size = 14, FontName = "Arial"});

2. Let's add a table (2x3) in RTF using for-loop:

create-table.docx
            // Let's create a simple RTF document.
            DocumentCore rtf = new DocumentCore();

            // Add a new section
            Section s = new Section(rtf);
            rtf.Sections.Add(s);


            // Let's create a plain table: 2x3.
            Table t = new Table(rtf);            

            // Add 2 rows.
            for (int r = 0; r < 2; r++)
            {
                TableRow row = new TableRow(rtf);
                
                // Add 3 columns.
                for (int c = 0; c < 3; c++)
                {
                    TableCell cell = new TableCell(rtf);

                    // Set some cell formatting
                    cell.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, BorderStyle.Single, Color.Blue, 1.0);
                    cell.CellFormat.PreferredWidth = new TableWidth(60, TableWidthUnit.Point);


                    row.Cells.Add(cell);

                    cell.Content.Start.Insert(String.Format("[{0}, {1}]", r, c));
                }
                t.Rows.Add(row);
            }
            // Add this table to the current section.
            s.Blocks.Add(t);

3. If you want to add an image in RTF in your .Net app:

add-image.docx
            // Let's create a simple RTF document.
            DocumentCore rtf = new DocumentCore();

            // Add a new section
            Section s = new Section(rtf);
            rtf.Sections.Add(s);

            // Add the image as a shape with coordinates.
            Picture pict1 = new Picture(rtf, "image1.jpg");

            FloatingLayout fl = new FloatingLayout(
                new HorizontalPosition(10, LengthUnit.Millimeter, HorizontalPositionAnchor.Page),
                new VerticalPosition(10, LengthUnit.Millimeter, VerticalPositionAnchor.TopMargin),
                new Size(70, 70));
            DrawingElement drawingElement = new DrawingElement(rtf, fl, pict1);
            s.Content.End.Insert(drawingElement.Content);


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.