Aspose::Words::Saving::HtmlSaveOptions::HtmlSaveOptions constructor
Contents
[
Hide
]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 = System::MakeObject<Aspose::Words::Document>(get_MyDir() + u"Rendering.docx");
// Use a SaveOptions object to specify the encoding for a document that we will save.
auto saveOptions = System::MakeObject<Aspose::Words::Saving::HtmlSaveOptions>();
saveOptions->set_SaveFormat(Aspose::Words::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(Aspose::Words::Saving::DocumentSplitCriteria::HeadingParagraph);
// Specify that we want to export document properties.
saveOptions->set_ExportDocumentProperties(true);
doc->Save(get_ArtifactsDir() + u"HtmlSaveOptions.Doc2EpubSaveOptions.epub", saveOptions);
See Also
- Class HtmlSaveOptions
- Namespace Aspose::Words::Saving
- Library Aspose.Words for C++
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)
| Parameter | Type | Description |
|---|---|---|
| saveFormat | Aspose::Words::SaveFormat | Can be Html, Mhtml, Epub, Azw3 or Mobi. |
Examples
Shows how to save a document to a specific version of HTML.
auto doc = System::MakeObject<Aspose::Words::Document>(get_MyDir() + u"Rendering.docx");
auto options = System::MakeObject<Aspose::Words::Saving::HtmlSaveOptions>(Aspose::Words::SaveFormat::Html);
options->set_HtmlVersion(htmlVersion);
options->set_PrettyFormat(true);
doc->Save(get_ArtifactsDir() + u"HtmlSaveOptions.HtmlVersions.html", options);
// Our HTML documents will have minor differences to be compatible with different HTML versions.
System::String outDocContents = System::IO::File::ReadAllText(get_ArtifactsDir() + u"HtmlSaveOptions.HtmlVersions.html");
switch (htmlVersion)
{
case Aspose::Words::Saving::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=\"padding:0pt; -aw-border:0.5pt single #000000; -aw-border-insideh:0.5pt single #000000; -aw-border-insidev:0.5pt single #000000; border-collapse:collapse\">"));
break;
case Aspose::Words::Saving::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:0.5pt single #000000; -aw-border-insideh:0.5pt single #000000; -aw-border-insidev:0.5pt single #000000; border-collapse:collapse\""));
break;
}
See Also
- Enum SaveFormat
- Class HtmlSaveOptions
- Namespace Aspose::Words::Saving
- Library Aspose.Words for C++