Skip to content

Instantly share code, notes, and snippets.

@aspose-com-kb
Last active February 3, 2022 00:15
Show Gist options
  • Save aspose-com-kb/0436365369615e884be4a012b5de4225 to your computer and use it in GitHub Desktop.
Save aspose-com-kb/0436365369615e884be4a012b5de4225 to your computer and use it in GitHub Desktop.
How to Convert Word to HTML using C++. For more information, please visit the link: https://kb.aspose.com/words/cpp/how-to-convert-word-to-html-using-cpp/
#pragma once
#include <cstdint>
#include <iostream>
#include <Aspose.Words.Cpp/Document.h>
#include <Aspose.Words.Cpp/License.h>
#include <Aspose.Words.Cpp/Saving/HtmlSaveOptions.h>
#include <system/exceptions.h>
using System::MakeObject;
using System::SharedPtr;
using System::String;
using namespace Aspose::Words;
using namespace Aspose::Words::Saving;
void DOCXtoHTML()
{
// Set license
System::String LicFilePath = u"Aspose.Total.CPP.lic";
SharedPtr<License> WordsCPPLicenseForDOCXtoHTML = System::MakeObject<License>();
WordsCPPLicenseForDOCXtoHTML->SetLicense(LicFilePath);
// Instantiate Document class for loading input document for converting to HTML
SharedPtr <Document> doc = MakeObject<Document>(u"Test.docx");
// Initilaize HtmlSaveOptions to convert DOCX to HTML file
SharedPtr <HtmlSaveOptions> saveOptions = MakeObject<HtmlSaveOptions>();
saveOptions->set_CssStyleSheetType(CssStyleSheetType::External);
saveOptions->set_ExportFontResources(true);
saveOptions->set_PrettyFormat(true);
saveOptions->set_ResolveFontNames(true);
// Save output HTML file
doc->Save(u"Output.html", saveOptions);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment