Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active November 2, 2021 17:09
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/4ab4b49bfb1d048e531c1811ac307560 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/4ab4b49bfb1d048e531c1811ac307560 to your computer and use it in GitHub Desktop.
Convert Word Documents to HTML in C#
// 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);
// 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);
// 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