Working with Word Documents (Create,Extract,Modify,etc.) without MS Office Installed

There are many libraries available in Java, dot net and other languages for creating and manipulating word documents. I recently came ac...


There are many libraries available in Java, dot net and other languages for creating and manipulating word documents. I recently came across one such dotnet library called "Bytescout document SDK" which I found to be highly useful, flawless and very simple too. It is freely available, also it does not require Microsoft Office to be installed on your machine. So let me quickly explain on how to use this SDK with a simple example. Though it is well documented I hope this explanation would help you to get started instantly once you download this SDK.

Bytescout Document SDK

Bytescout Document SDK is 100% managed .NET (1.10, 2.00 and higher) library for document (DOC, DOCX) writing, reading and modification.

Steps to follow,

1. Download Bytescout Document SDK here.
2. Install the Bytescout Document SDK exe file using the application wizard.
3. Go to /installationpath/Redistributable/ folder where you will find "Bytescout.Document.dll".(Example: C:\ProgramFiles\Redistributable\net2.00\Bytescout.Document.dll)
4. Add the above dll as a reference to your dot net application.
5. Start writing programs to create and manipulate word documents instantly.

A simple example for creating a sample word document, in your project's debug folder,

Visual C#

using Bytescout.Document;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            using (Document doc = new Document(DocumentFormat.OpenXml))
            {
                Paragraph p = doc.AddParagraph();
                p.Text = "Hello, world!";

                p = doc.AddParagraph();
                p.Text = "Please evaluate Bytescout Document SDK.";
                p.Text += " It may save you some time and effort when creating documents.";
                doc.Save("output.docx");
                System.Diagnostics.Process.Start("output.docx");
            }
        }
    }
}

Visual Basic .Net

Imports Bytescout.Document

Module Module1

    Sub Main()
        Using doc As New Document(DocumentFormat.OpenXml)
            Dim p As Paragraph = doc.AddParagraph()
            p.Text = "Hello, world!"

            p = doc.AddParagraph()
            p.Text = "Please evaluate Bytescout Document SDK."
            p.Text += " It may save you some time and effort when creating documents."

            doc.Save("output.docx")
            System.Diagnostics.Process.Start("output.docx")
        End Using

    End Sub

End Module

Benefits

  1. Microsoft Word (or Microsoft Office) is not required;
  2. Made with 100% managed code for .NET. Both .NET 1.10 (Visual Studio 2003) and 2.00 (Visual Studio 2005,2008 or higher) frameworks are supported;
  3. Operations with documents, paragraphs and text runs are supported;
  4. Unicode text support;
  5. Paragraph and text run formating (font, color, highlighting, alignment and other parameters) is supported;
  6. Text extraction is supported;
  7. You can search for text in documents using built-in search functionality;
  8. You can replace text in documents using built-in search and replace functionality;
  9. Reading of document is supported: you can open existing DOC or DOCX file and extract text from it. You can also open DOCX file and modify text or formatting (change text, add or remove paragraphs etc.) then save document as new DOCX file;
  10. And much more!

Please leave your comments and queries about this post in the comment sections in order for me to improve my writing skills and to showcase more useful posts. 

Subscribe to GET LATEST ARTICLES!


Related

Dot Net 3355711077473448193

Post a Comment

  1. I use Aspose.Words for .NET Library for managing my word files and i have used many of their sample codes in my Api and so far i am very much satisfied with its working. You should try this library also.

    ReplyDelete
    Replies
    1. Yes. But it is not opensource and we need to pay to get licensed version of it. Otherwise, Aspose is really good according to what I hear from many.

      Delete
  2. Hey! Use our past tense of proofread tool. Our assistant was created to check and correct errors in your text related to the use of the verb tense. You no longer need to waste your time on this. Our assistant is absolutely free and works very quickly. Just try it!

    ReplyDelete

emo-but-icon

SUBSCRIBE


item