Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created January 19, 2021 20: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/55fefeb42d0a2829672e78eaed4c7b38 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/55fefeb42d0a2829672e78eaed4c7b38 to your computer and use it in GitHub Desktop.
Convert Word DOC or DOCX to HTML, MHTML in C# VB.NET
// Load the document from disk.
Document doc = new Document(dataDir + "Test File.docx");
// Set HtmlSaveOptions
HtmlSaveOptions options = new HtmlSaveOptions();
options.SaveFormat = SaveFormat.Html;
// Save the document into HTML
doc.Save(dataDir + "Document.html", options);
// Load the document from disk.
Document doc = new Document(dataDir + "Test File (doc).docx");
HtmlSaveOptions options = new HtmlSaveOptions();
// HtmlSaveOptions.ExportRoundtripInformation property specifies
// Whether to write the roundtrip information when saving to HTML, MHTML or EPUB.
// Default value is true for HTML and false for MHTML and EPUB.
options.ExportRoundtripInformation = true;
doc.Save(dataDir + "ExportRoundtripInformation_out.html", options);
// Load the document from disk.
Document doc = new Document(dataDir + "Test File.docx");
// Set HtmlSaveOptions
HtmlSaveOptions options = new HtmlSaveOptions();
options.SaveFormat = SaveFormat.Mhtml;
// Save the document into MHTML
doc.Save(dataDir + "Document.mhtml", options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment