Last active
February 3, 2022 00:15
-
-
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/
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
#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