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

C#.NET: Get Top and Bottom n Rows from DataTable using LINQ

LINQ, introduced in late 2007 is a way of querying data in arrays, lists, enumerable classes, XML, relational databases and anything built on these.This post explains how to get the top and...

Create 3D Charts and Graphs in .NET applications with MS Chart Control

Creating charts and graphs in .NET applications were no easy task before the release of Microsoft Chart Controls. It is now very simple and easy to create charts and graphs in .NET applications wit...

Set default focus and default button in ASP.NET forms

Sometimes it may require to set default focus to an element on a web page. For example if you have a registration form in your web page, with lot of text boxes to be filled in, it will be easy for ...

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
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

SUBSCRIBE


Hot in weekRecentComments

Recent

Spring Security 4 for Spring MVC using Spring Data JPA and Spring Boot

I have been writing a series of tutorials on using Spring Security 4 in Spring MVC application starting from the basic in-memory authentication. In this post, I am writing a step by ste...

Spring Security JDBC Authentication with Password Encryption

I published a basic level tutorial on how to implement JDBC Authentication and Authorization using Spring Security last week. There are few best practices to be followed while implementing secur...

Spring Security 4 - Simple JDBC Authentication and Authorization

In one of my articles, I explained with a simple example on how to secure a Spring MVC application using Spring Security and with Spring Boot for setup. I am going to extend the same example to ...

Java String Split with Pipe Character Not Working - Solution

If you are working on Java, you might have run into this issue when you try to split a string based on a pipe character ("|"). It simply won't work. Split method in Java takes regex as an argumen...

Comments

Hexa Publishers:

Hexa Publishers is a dynamic and forward-thinking publishing house dedicated to bringing compelling stories, insightful non-fiction, and innovat...

hicham :

Thank you for the post carsstories.com

We Care India:

Love how practical and well-designed everything is here. You’ve really thought this through. Keep it up, you're doing 6-2-2025

We Care India:

These features are super practical and useful. Keep up the fantastic Keyword!

Teenpatti master:

Great post – informative and concise!
Play this game for fun and earn rewards:
My Master Teenpatti Game

item