Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 1, 2021 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/195c44f2a6821422b11f5fa3211977c5 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/195c44f2a6821422b11f5fa3211977c5 to your computer and use it in GitHub Desktop.
Convert Word Documents to EPUB in C#
// Load the Word document
Document doc = new Document("document.docx");
// Create an object for save options
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
// Set the desired encoding
saveOptions.Encoding = Encoding.UTF8;
// Specify at what elements to split the internal HTML at. This creates a new HTML within the EPUB
// which allows you to limit the size of each HTML part. This is useful for readers which cannot read
// HTML files greater than a certain size e.g 300kb.
saveOptions.DocumentSplitCriteria = DocumentSplitCriteria.HeadingParagraph;
// Enable export of document properties
saveOptions.ExportDocumentProperties = true;
// Specify save format
saveOptions.SaveFormat = SaveFormat.Epub;
// Convert Word document to EPUB
doc.Save("word-to-epub.epub", saveOptions);
// Load the Word document
Document doc = new Document("document.docx");
// Convert Word document to EPUB
doc.Save("word-to-epub.epub");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment