Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created August 19, 2020 21:30
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/2b38adfb2d3ff27c0c6ef3ee36062ce3 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/2b38adfb2d3ff27c0c6ef3ee36062ce3 to your computer and use it in GitHub Desktop.
Convert Word DOCX/DOC to HTML/MHTML in C++
// Load the document from
System::SharedPtr<Document> doc = System::MakeObject<Document>(u"Test File.docx");
// Save the word document in HTML format
doc->Save(u"Document_out.html", SaveFormat::Html);
// Load the document into Aspose.Words.
System::SharedPtr<Document> doc = System::MakeObject<Document>(u"Test File.docx");
// Save output in MHTML format.
doc->Save(u"Document_out.mhtml", SaveFormat::Mhtml);
// Load source DOCX file
System::SharedPtr<Document> doc = System::MakeObject<Document>(u"Document.docx");
// Initialize HtmlSaveOptions object
System::SharedPtr<HtmlSaveOptions> saveOptions = System::MakeObject<HtmlSaveOptions>();
saveOptions->set_ExportFontResources(true);
saveOptions->set_ExportFontsAsBase64(true);
// Save output HTML
System::String outputPath = u"ExportFontsAsBase64.html";
doc->Save(outputPath, saveOptions);
// Load input DOCX file
System::SharedPtr<Document> doc = System::MakeObject<Document>(u"Document.doc");
// Set HtmlSaveOptions
System::SharedPtr<HtmlSaveOptions> saveOptions = System::MakeObject<HtmlSaveOptions>();
saveOptions->set_ExportFontResources(true);
saveOptions->set_ExportFontsAsBase64(true);
// Save output HTML file
System::String outputPath = u"ExportFontsAsBase64.html";
doc->Save(outputPath, saveOptions);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment