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 DOCX in C# using Document .Net library?"

Introduction

If you are looking for a solution to programmatically create DOCX in C# or VB.Net, you are in the right place!

How programmatically create DOCX in C# using Document .Net library?

Document .Net is 100% managed C# assembly (SautinSoft.Document.dll) which gives you API to generate Office Open XML (DOCX) documents.

Your .Net app will be able to create DOCX documents with any desired formatting, such as:

  • Insert formatted text, paragraphs, images, plain and nested tables.
  • Set page size and orientation (height, width, margin vals).
  • Set 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 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, you have to only add a reference to "SautinSoft.Document.dll".

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

1. Let's see how easy to create DOCX document in C# application:

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

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

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

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


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

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

                    // 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 DOCX in your .Net app:

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

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

            // Add the image as a shape with coordinates.
            Picture pict1 = new Picture(docx, "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(docx, 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.