Created
October 2, 2020 19:35
-
-
Save farhan-raza/237a7d38b3b2d61b7bf4952c33e7165b to your computer and use it in GitHub Desktop.
Convert Word DOC or DOCX to HTML, MHTML in C# VB.NET
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(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); |
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(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); |
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(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