Learn how to convert Word documents to HTML in C#: https://blog.aspose.com/2021/10/02/convert-word-to-html-using-csharp/
Last active
November 2, 2021 17:09
-
-
Save aspose-com-gists/4ab4b49bfb1d048e531c1811ac307560 to your computer and use it in GitHub Desktop.
Convert Word Documents to HTML in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load document | |
Document doc = new Document("document.docx"); | |
// Set folder for resources | |
HtmlSaveOptions saveOptions = new HtmlSaveOptions(); | |
saveOptions.CssStyleSheetType = CssStyleSheetType.External; | |
saveOptions.ExportFontResources = true; | |
saveOptions.ResourceFolder = dataDir + @"\Resources"; | |
saveOptions.ResourceFolderAlias = "http://example.com/resources"; | |
// Convert document to HTML | |
doc.Save("ExportResourcesUsingHtmlSaveOptions.html", saveOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load the document from disk | |
Document doc = new Document("Document.docx"); | |
// Enable roundtrip information | |
HtmlSaveOptions options = new HtmlSaveOptions(); | |
options.ExportRoundtripInformation = true; | |
// Save as HTML | |
doc.Save("ExportRoundtripInformation_out.html", options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load the document from disk | |
Document doc = new Document("Document.docx"); | |
// Save the document as HTML | |
doc.Save("Document.html", SaveFormat.Html); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment