How to Convert Word to EPub with C#/VB.NET

What is EPub

EPub is one kind of Open eBook standard, which can display contents according to features of readers to suit for reading. It used XHTML or DTBook to present text and packs contents with zip format. So, actually, EPub is simple ZIP format file but with extension .epub.

How to view an EPub file? There are several kinds of EPub readers. One of the most frequently used is Adobe Digital Editions because it can read and manage EPub files easily.

How to create an EPub file? Because nearly all the contents in EPub is xml, so users can create XML tool to create EPub files instead of using professional software. The other method to get EPub file is to convert from other format files, for example, Word to EPub.

How to Convert Word to EPub

In this post, I want to introduce a method about how to convert Word document to EPub with C#/VB.NET.

I use a component, Spire.Doc to realize this conversion in my example. Before coding, I have added its dll file as reference in my project.

Detailed Steps Shown as Following:           

I. Load file which I want to convert to EPub from computer by using document.LoadFromFile() method.

C#

            Document document = new Document();

            document.LoadFromFile(@”E:\work\documents\message.docx”);

VB.NET

            Dim document As New Document()

            document.LoadFromFile(“E:\work\documents\message.docx”)

II. Use document.SaveToFile() method to save Word document as EPub. There are two parameters sent to this method, string file name and file format.

C#

            document.SaveToFile(“ToEpub.epub”, FileFormat.EPub);

VB.NET

            document.SaveToFile(“ToEpub.epub”, FileFormat.EPub)

III. Launch for getting this converted EPub file.

C#

            System.Diagnostics.Process.Start(“ToEpub.epub”);

VB.NET

            System.Diagnostics.Process.Start(“ToEpub.epub”)

Note: Although Word document I convert to EPub is .DOCX, this method can be used to convert .DOC document to EPub as well.

Result Shown as Following:

______________________________________________________________________________________________

Click Here to LEARN MORE about Spire.Doc

Click Here to DOWNLOAD Spire.Doc

Spire.Office also can be used to realize this function.

Related Posts:

Convert Word to HTML

Convert Word to XML

Convert Word to Image

Convert Word to PDF

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s