The EPUB format is used for electronic publications, which are commonly known as ebooks. The EPUB files are supported by a range of smart devices such as smartphones, tablets, laptops, etc. In various cases, the documents are created in MS Word formats that do not often have built-in support on smart devices. Therefore, Word files are converted to EPUB format. In this article, you will learn how to convert Word (DOCX, DOC, etc.) files to EPUB programmatically using C#.
- .NET API for Word to EPUB Conversion
- Convert a Word Document to EPUB
- Customize Word to EPUB Conversion
Tip: If you ever need to get a Word document from a PowerPoint presentation, you can use Aspose Presentation to Word Document converter.
C# API for Word to EPUB Conversion
In order to convert MS Word files to EPUB format, we will use Aspose.Words for .NET. The API is designed to work with MS Word documents from within the .NET applications. It lets you create, manipulate and convert Word documents with high fidelity. You can download the API’s DLL or install it directly from NuGet using the package manager console.
PM> Install-Package Aspose.Words
Convert a Word Document to EPUB in C#
The following are the steps to convert a Word DOCX file to EPUB in C#.
- Load the Word DOCX/DOC file using Document class.
- Save document as EPUB using Document.Save(string) method.
The following code sample shows how to convert a DOCX file to EPUB in C#.
Customize Word to EPUB Conversion in C#
You can also customize Word to EPUB conversion using different options provided by Aspose.Words for .NET. For example, you can specify the encoding scheme, enable or disable exporting document information, and so on. The following are the steps to customize Word to EPUB conversion.
- Load the Word DOCX/DOC file using Document class.
- Create an object of HtmlSaveOptions class and set desired options.
- Save document as EPUB using Document.Save(string, HtmlSaveOptions) method.
The following code sample shows how to specify additional options in Word to EPUB conversion.
Get a Free License
Get a temporary license to use Aspose.Words for .NET without any evaluation limitations.
Conclusion
In this article, you have learned how to convert Word documents to EPUB format in C#. Furthermore, you have seen how to customize Word to EPUB conversion dynamically using different options. Apart from that, you can visit the documentation to explore more about Aspose.Words for .NET. In case of any queries, you can let us know via our forum.