Aspose::Words::Saving::HtmlSaveOptions::HtmlSaveOptions constructor

HtmlSaveOptions::HtmlSaveOptions() constructor

Initializes a new instance of this class that can be used to save a document in the Html format.

Aspose::Words::Saving::HtmlSaveOptions::HtmlSaveOptions()

Examples

Shows how to use a specific encoding when saving a document to .epub.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");

// Use a SaveOptions object to specify the encoding for a document that we will save.
auto saveOptions = MakeObject<HtmlSaveOptions>();
saveOptions->set_SaveFormat(SaveFormat::Epub);
saveOptions->set_Encoding(System::Text::Encoding::get_UTF8());

// By default, an output .epub document will have all its contents in one HTML part.
// A split criterion allows us to segment the document into several HTML parts.
// We will set the criteria to split the document into heading paragraphs.
// This is useful for readers who cannot read HTML files more significant than a specific size.
saveOptions->set_DocumentSplitCriteria(DocumentSplitCriteria::HeadingParagraph);

// Specify that we want to export document properties.
saveOptions->set_ExportDocumentProperties(true);

doc->Save(ArtifactsDir + u"HtmlSaveOptions.Doc2EpubSaveOptions.epub", saveOptions);

See Also

HtmlSaveOptions::HtmlSaveOptions(Aspose::Words::SaveFormat) constructor

Initializes a new instance of this class that can be used to save a document in the Html, Mhtml, Epub, Azw3 or Mobi format.

Aspose::Words::Saving::HtmlSaveOptions::HtmlSaveOptions(Aspose::Words::SaveFormat saveFormat)
ParameterTypeDescription
saveFormatAspose::Words::SaveFormatCan be Html, Mhtml, Epub, Azw3 or Mobi.

Examples

Shows how to save a document to a specific version of HTML.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");

auto options = MakeObject<HtmlSaveOptions>(SaveFormat::Html);
options->set_HtmlVersion(htmlVersion);
options->set_PrettyFormat(true);

doc->Save(ArtifactsDir + u"HtmlSaveOptions.HtmlVersions.html", options);

// Our HTML documents will have minor differences to be compatible with different HTML versions.
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.HtmlVersions.html");

switch (htmlVersion)
{
case HtmlVersion::Html5:
    ASSERT_TRUE(outDocContents.Contains(u"<a id=\"_Toc76372689\"></a>"));
    ASSERT_TRUE(outDocContents.Contains(u"<a id=\"_Toc76372689\"></a>"));
    ASSERT_TRUE(outDocContents.Contains(
        u"<table style=\"-aw-border-insideh:0.5pt single #000000; -aw-border-insidev:0.5pt single #000000; border-collapse:collapse\">"));
    break;

case HtmlVersion::Xhtml:
    ASSERT_TRUE(outDocContents.Contains(u"<a name=\"_Toc76372689\"></a>"));
    ASSERT_TRUE(outDocContents.Contains(u"<ul type=\"disc\" style=\"margin:0pt; padding-left:0pt\">"));
    ASSERT_TRUE(outDocContents.Contains(u"<table cellspacing=\"0\" cellpadding=\"0\" style=\"-aw-border-insideh:0.5pt single #000000; "
                                        u"-aw-border-insidev:0.5pt single #000000; border-collapse:collapse\""));
    break;
}

See Also