Click here to Skip to main content
15,305,480 members
Articles / Programming Languages / C#
Posted 8 Aug 2005


149 bookmarked

Gios WORD .NET Library (using RTF specification)

Rate me:
Please Sign up or sign in to vote.
4.85/5 (47 votes)
8 Aug 2005LGPL31 min read
A .NET library for generating Word documents (.DOC) using the RTF (Rich Text Format) specification.

This is the output of "Example 1", included in the library.


The Gios WORD .NET is the second thing that a good C# developer needs to deploy in his business projects... The first one?!? You probably know it is the Gios PDF .NET library!

So, that's why I decided to develop this library: after the need for generating PDFs, you will need the same for WORDs!

Gios WORD .NET supports:

  • Tables with rows and columns span.
  • Images
  • Header and Footer
  • Line indent - paragraph
  • Custom Control Words (See the Rich Text Format (RTF) Specification for this implementation.)
  • Output to a generic System.IO.Stream object.


Building a library for exporting documents in the Rich Text Format is quite easier than for PDFs. In fact, the Rich Text Format (RTF) Specification, version 1.8 shows how simple it is to generate a word document with all the well known features. I used the version 1.5 (which is fully compatible with WORD 97).

Using the code

The library is very simple to be used! The first thing you need to do is instantiating a new WordDocument:

WordDocument myWordDocument=
    new WordDocument(WordDocumentFormat.Letter_8_5x11);

and with the WordDocument object you can start with the description of the document. It's like an automation. For example, if you want to set the font, you can write:

myWordDocument.SetFont(new Font("Comic Sans MS",

And now we set some alignment:


To write a text... You can imagine:

myWordDocument.Write("Hello World!");

And, in the end, you output the document!


And this is the result:

Remember, you can also output the WORD Document to a generic stream. These are the lines for a web response:


To continue with the training, please download the library and follow the examples!


  • August 8th, 2005 - First release.


This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


About the Author

Paolo Gios
Web Developer
Italy Italy
Freelance software ASPNET / C# Software Developer

I live in Torino, Italy

my homepage is:

Comments and Discussions

Newsdll with unicode support Pin
Member 1299608011-Jan-18 0:14
MemberMember 1299608011-Jan-18 0:14 
QuestionEncoding using unicode Pin
FandaCZ1-Feb-14 0:01
MemberFandaCZ1-Feb-14 0:01 
QuestionHelp Pin
Member 102652662-Dec-13 14:31
MemberMember 102652662-Dec-13 14:31 
QuestionError if more than 200 pages Pin
thomaszae14-Jun-12 1:50
Memberthomaszae14-Jun-12 1:50 
QuestionIssues on clean Windows 7 (32 bit) system? Pin
kembo25-Aug-11 14:53
Memberkembo25-Aug-11 14:53 
BugAutoFitBehavior (wdAutoFitContent) Pin
mail-2216-Aug-11 1:47
Membermail-2216-Aug-11 1:47 
how to apply to the table, click "auto-fit the width of the window?"
GeneralTurkish Encoding Problem is solved simply. Pin
emarti4-Jun-11 11:18
Memberemarti4-Jun-11 11:18 
QuestionHow do I set the First Page Header Or Footer Different with other page on word document by using this library? Pin
lin ma5923-Jul-09 6:05
Memberlin ma5923-Jul-09 6:05 
QuestionOpen an existing document? Pin
Tommy W13-May-09 0:17
MemberTommy W13-May-09 0:17 
GeneralDocument won't show correctly in WordPad (or RichtextBox) Pin
Reiner S27-Oct-08 4:54
MemberReiner S27-Oct-08 4:54 
GeneralRe: Document won't show correctly in WordPad (or RichtextBox) Pin
Never Winter5-Jan-09 17:18
MemberNever Winter5-Jan-09 17:18 
GeneralRender to image Pin
josepaulino19-Aug-08 18:36
Memberjosepaulino19-Aug-08 18:36 
GeneralChange table size and Aligment Pin
Tai Fei Pao18-Aug-08 8:12
MemberTai Fei Pao18-Aug-08 8:12 
GeneralSolution for Table of contents Pin
vavavivi3-Jul-08 4:07
Membervavavivi3-Jul-08 4:07 
GeneralRe: Solution for Table of contents Pin
thomaszae14-Jun-12 12:15
Memberthomaszae14-Jun-12 12:15 
AnswerRe: Solution for Table of contents Pin
Dannon DMello12-Oct-13 6:25
MemberDannon DMello12-Oct-13 6:25 
GeneralPage Current Number Pin
vavavivi3-Jul-08 1:56
Membervavavivi3-Jul-08 1:56 
GeneralRe: Page Current Number Pin
Paolo Gios3-Jul-08 2:01
MemberPaolo Gios3-Jul-08 2:01 
GeneralRe: Page Current Number Pin
vavavivi3-Jul-08 2:31
Membervavavivi3-Jul-08 2:31 
GeneralRe: Page Current Number Pin
Tatjana Ilchenko16-Jul-09 10:57
MemberTatjana Ilchenko16-Jul-09 10:57 
QuestionHow to add checkbox? Pin
gkee28-Apr-08 16:42
Membergkee28-Apr-08 16:42 
Generaladding landscape page and portrait page in same document. Pin
Najeed12-Dec-07 17:24
MemberNajeed12-Dec-07 17:24 
GeneralUnicode characters bugfix Pin
dejandular12-Aug-07 4:28
Memberdejandular12-Aug-07 4:28 
GeneralRe: Unicode characters bugfix Pin
Hamid Reza Mohammadi23-Sep-07 19:32
MemberHamid Reza Mohammadi23-Sep-07 19:32 
GeneralRe: Unicode characters bugfix Pin
Simon Pham1-Jan-08 17:17
MemberSimon Pham1-Jan-08 17:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.