1. Introduction
  2. Library installation and Reference
  3. Document to PDF conversion
  4. Document to XPS conversion
  5. Summary


In this article, I will explain about certain third- party libraries, which helps to create, convert and manipulate word and excel files. All we need to do is get the library reference from NuGet Packet Manager and make use of it. You can also install it from NuGet package Console if you are interested. Once you add the reference into your project, it is just a matter of few method calls to the library to get the features like converting the document to PDF or converting the document into Image format. Let us discuss this in detail

Library installation and Reference

Spire.Doc is the library designed for programmers to manipulate word processing tasks.  With this Library one can easily convert,create,read and  write word document file. As a first step, I request you to Open the Visual studio and Click File->New->Project->Windows Application


After that open, the Tools->Library Package Manager Console->NuGet Package Manager Console and provide the following command

Install-Package Spire.Doc


Another way you can also download the same from websites. Once you successfully downloaded the package you can check the reference in the project. You need to  manually add the reference in case you download the library from the website.


Document to PDF conversion

Here, am going to explain to you how you can convert your word document into a PDF document by consuming the library. As a first step, just use the library reference into your windows application.


After that, you just need to create the XML document object and load the word document which you want to convert into a PDF document. Then you have to choose the Method SaveToFile method in the XML document, this will automatically convert the word document into PDF document. Following is the snapshot, which details the conversion.


In the snapshot above, you can find that XmlDocument object named doc has been created, After that I have loaded Caramel_Chocolate.docx document into the doc XmlDocument. After that select SaveToFile method in the XmlDocument and provide the FileFormat you want to convert and name of the file once it get converted., in our case I have selected as FileFormat.PDF and Caramel_Chocolate_PdfVersion.PDF.

This will convert the word document into a PDF document.

Document to Txt conversion

Here, you can see the steps to convert the word document into a text document.

All the steps remain the same, as we did for Word to PDF conversion except the FileFormat value need to be changed into FileFormat.Txt. Please look at the below snapshot to get the complete details of conversion


In the snapshot above, you can find that Caramel_Chocolate.docx a word document file will be converted into Caramel_Chocolate_TxtVersion a Text document

Document to XPS conversion

There are situations you need to convert the word document into an XPS Image file , and the main Advantage of having, as an XPS file is one cannot able to edit the content.

The below snapshot will explain you the steps we need to consider for converting word document into a XPS image file.


In the snapshot above, you can find that word document will be loaded into an XML document and then We need to choose the file format version into XPS. With that, one can easily convert the word  Document into XPS image.



Spire.Doc is a .Net Library designed to convert, create, read and write word document file. With that Developers can easily convert the word document into PDF,XPS,Txt format.