Aspose::Words::Saving::HtmlSaveOptions Class Reference

Detailed Description

Can be used to specify additional options when saving a document into the Html, Mhtml or Epub format.

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);
static ASPOSECPP_SHARED_API EncodingPtr get_UTF8()
@ HeadingParagraph
The document is split into parts at a paragraph formatted using a heading style Heading 1,...
@ Epub
Saves the document in the IDPF EPUB format.

Shows how to specify the folder for storing linked images after saving to .html.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
String imagesDir = System::IO::Path::Combine(ArtifactsDir, u"SaveHtmlWithOptions");
{
}
// Set an option to export form fields as plain text instead of HTML input elements.
auto options = MakeObject<HtmlSaveOptions>(SaveFormat::Html);
options->set_ExportTextInputFormFieldAsText(true);
options->set_ImagesFolder(imagesDir);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.SaveHtmlWithOptions.html", options);
static ASPOSECPP_SHARED_API void Delete(const String &path, bool recursive=false)
static ASPOSECPP_SHARED_API String Combine(const ArrayPtr< String > &paths)
static ASPOSECPP_SHARED_API void CreateDirectory_(const String &path)
static ASPOSECPP_SHARED_API bool Exists(const String &path)
@ Html
Saves the document in the HTML format.

Shows how to split a document into parts and save them.

void DocumentPartsFileNames()
{
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
String outFileName = u"SavingCallback.DocumentPartsFileNames.html";
// Create an "HtmlFixedSaveOptions" object, which we can pass to the document's "Save" method
// to modify how we convert the document to HTML.
auto options = MakeObject<HtmlSaveOptions>();
// If we save the document normally, there will be one output HTML
// document with all the source document's contents.
// Set the "DocumentSplitCriteria" property to "DocumentSplitCriteria.SectionBreak" to
// save our document to multiple HTML files: one for each section.
options->set_DocumentSplitCriteria(DocumentSplitCriteria::SectionBreak);
// Assign a custom callback to the "DocumentPartSavingCallback" property to alter the document part saving logic.
options->set_DocumentPartSavingCallback(MakeObject<ExSavingCallback::SavedDocumentPartRename>(outFileName, options->get_DocumentSplitCriteria()));
// If we convert a document that contains images into html, we will end up with one html file which links to several images.
// Each image will be in the form of a file in the local file system.
// There is also a callback that can customize the name and file system location of each image.
options->set_ImageSavingCallback(MakeObject<ExSavingCallback::SavedImageRename>(outFileName));
doc->Save(ArtifactsDir + outFileName, options);
}
class SavedDocumentPartRename : public IDocumentPartSavingCallback
{
public:
SavedDocumentPartRename(String outFileName, DocumentSplitCriteria documentSplitCriteria)
: mCount(0), mDocumentSplitCriteria(((Aspose::Words::Saving::DocumentSplitCriteria)0))
{
mOutFileName = outFileName;
mDocumentSplitCriteria = documentSplitCriteria;
}
void DocumentPartSaving(SharedPtr<DocumentPartSavingArgs> args) override
{
// We can access the entire source document via the "Document" property.
ASSERT_TRUE(args->get_Document()->get_OriginalFileName().EndsWith(u"Rendering.docx"));
String partType = String::Empty;
switch (mDocumentSplitCriteria)
{
partType = u"Page";
break;
partType = u"Column";
break;
partType = u"Section";
break;
partType = u"Paragraph from heading";
break;
default:
break;
}
String partFileName = String::Format(u"{0} part {1}, of type {2}{3}", mOutFileName, ++mCount, partType,
System::IO::Path::GetExtension(args->get_DocumentPartFileName()));
// Below are two ways of specifying where Aspose.Words will save each part of the document.
// 1 - Set a filename for the output part file:
args->set_DocumentPartFileName(partFileName);
// 2 - Create a custom stream for the output part file:
args->set_DocumentPartStream(MakeObject<System::IO::FileStream>(ArtifactsDir + partFileName, System::IO::FileMode::Create));
ASSERT_TRUE(args->get_DocumentPartStream()->get_CanWrite());
ASSERT_FALSE(args->get_KeepDocumentPartStreamOpen());
}
private:
int mCount;
String mOutFileName;
DocumentSplitCriteria mDocumentSplitCriteria;
};
class SavedImageRename : public IImageSavingCallback
{
public:
SavedImageRename(String outFileName) : mCount(0)
{
mOutFileName = outFileName;
}
void ImageSaving(SharedPtr<ImageSavingArgs> args) override
{
String imageFileName = String::Format(u"{0} shape {1}, of type {2}{3}", mOutFileName, ++mCount, args->get_CurrentShape()->get_ShapeType(),
System::IO::Path::GetExtension(args->get_ImageFileName()));
// Below are two ways of specifying where Aspose.Words will save each part of the document.
// 1 - Set a filename for the output image file:
args->set_ImageFileName(imageFileName);
// 2 - Create a custom stream for the output image file:
args->set_ImageStream(MakeObject<System::IO::FileStream>(ArtifactsDir + imageFileName, System::IO::FileMode::Create));
ASSERT_TRUE(args->get_ImageStream()->get_CanWrite());
ASSERT_TRUE(args->get_IsImageAvailable());
ASSERT_FALSE(args->get_KeepImageStreamOpen());
}
private:
int mCount;
String mOutFileName;
};
static ASPOSECPP_SHARED_API String GetExtension(const String &path)
DocumentSplitCriteria
Specifies how the document is split into parts when saving to Html or Epub format.
Definition: DocumentSplitCriteria.h:59
@ PageBreak
The document is split into parts at explicit page breaks. A page break can be specified by a PageBrea...
@ ColumnBreak
The document is split into parts at column breaks. A column break can be specified by a ColumnBreak c...
@ SectionBreak
The document is split into parts at a section break of any type.
Definition: AsposeWordsLibrary.h:13

#include <Aspose.Words.Cpp/Model/Saving/HtmlSaveOptions.h>

+ Inheritance diagram for Aspose::Words::Saving::HtmlSaveOptions:

Public Member Functions

 HtmlSaveOptions ()
 Initializes a new instance of this class that can be used to save a document in the Html format. More...
 
 HtmlSaveOptions (SaveFormat saveFormat)
 Initializes a new instance of this class that can be used to save a document in the Html, Mhtml or Epub format. More...
 
bool get_AllowNegativeIndent () const
 Specifies whether negative left and right indents of paragraphs are normalized when saving to HTML, MHTML or EPUB. Default value is false. More...
 
String get_CssClassNamePrefix () const
 Specifies a prefix which is added to all CSS class names. Default value is an empty string and generated CSS class names have no common prefix. More...
 
SharedPtr< ICssSavingCallbackget_CssSavingCallback () const
 Allows to control how CSS styles are saved when a document is saved to HTML, MHTML or EPUB. More...
 
String get_CssStyleSheetFileName () const
 Specifies the path and the name of the Cascading Style Sheet (CSS) file written when a document is exported to HTML. Default is an empty string. More...
 
CssStyleSheetType get_CssStyleSheetType () const
 Specifies how CSS (Cascading Style Sheet) styles are exported to HTML, MHTML or EPUB. Default value is Inline for HTML/MHTML and External for EPUB. More...
 
SharedPtr< IDocumentPartSavingCallbackget_DocumentPartSavingCallback () const
 Allows to control how document parts are saved when a document is saved to HTML or EPUB. More...
 
DocumentSplitCriteria get_DocumentSplitCriteria () const
 Specifies how the document should be split when saving to Html or Epub format. Default is None for HTML and HeadingParagraph for EPUB. More...
 
int32_t get_DocumentSplitHeadingLevel () const
 Specifies the maximum level of headings at which to split the document. Default value is 2. More...
 
SharedPtr< Encodingget_Encoding () const
 Specifies the encoding to use when exporting to HTML, MHTML or EPUB. Default value is new UTF8Encoding(false) (UTF-8 without BOM). More...
 
int32_t get_EpubNavigationMapLevel () const
 Specifies the maximum level of headings populated to the navigation map when exporting to IDPF EPUB format. Default value is 3. More...
 
bool get_ExportCidUrlsForMhtmlResources () const
 Specifies whether to use CID (Content-ID) URLs to reference resources (images, fonts, CSS) included in MHTML documents. Default value is false. More...
 
bool get_ExportDocumentProperties () const
 Specifies whether to export built-in and custom document properties to HTML, MHTML or EPUB. Default value is false. More...
 
bool get_ExportDropDownFormFieldAsText () const
 Controls how drop-down form fields are saved to HTML or MHTML. Default value is false. More...
 
bool get_ExportFontResources () const
 Specifies whether font resources should be exported to HTML, MHTML or EPUB. Default is false. More...
 
bool get_ExportFontsAsBase64 () const
 Specifies whether fonts resources should be embedded to HTML in Base64 encoding. Default is false. More...
 
ExportHeadersFootersMode get_ExportHeadersFootersMode () const
 Specifies how headers and footers are output to HTML, MHTML or EPUB. Default value is PerSection for HTML/MHTML and None for EPUB. More...
 
bool get_ExportImagesAsBase64 ()
 Specifies whether images are saved in Base64 format to HTML, MHTML or EPUB. Default is false. More...
 
bool get_ExportLanguageInformation () const
 Specifies whether language information is exported to HTML, MHTML or EPUB. Default is false. More...
 
ExportListLabels get_ExportListLabels () const
 Controls how list labels are output to HTML, MHTML or EPUB. Default value is Auto. More...
 
bool get_ExportOriginalUrlForLinkedImages () const
 Specifies whether original URL should be used as the URL of the linked images. Default value is false. More...
 
bool get_ExportPageMargins () const
 Specifies whether page margins is exported to HTML, MHTML or EPUB. Default is false. More...
 
bool get_ExportPageSetup () const
 Specifies whether page setup is exported to HTML, MHTML or EPUB. Default is false. More...
 
bool get_ExportRelativeFontSize () const
 Specifies whether font sizes should be output in relative units when saving to HTML, MHTML or EPUB. Default is false. More...
 
bool get_ExportRoundtripInformation () const
 Specifies whether to write the roundtrip information when saving to HTML, MHTML or EPUB. Default value is true for HTML and false for MHTML and EPUB. More...
 
bool get_ExportTextBoxAsSvg ()
 Controls how textboxes represented by Shape are saved to HTML, MHTML or EPUB. Default value is false. More...
 
bool get_ExportTextInputFormFieldAsText () const
 Controls how text input form fields are saved to HTML or MHTML. Default value is false. More...
 
bool get_ExportTocPageNumbers () const
 Specifies whether to write page numbers to table of contents when saving HTML, MHTML and EPUB. Default value is false. More...
 
bool get_ExportXhtmlTransitional () const
 Specifies whether to write the DOCTYPE declaration when saving to HTML or MHTML. When true, writes a DOCTYPE declaration in the document prior to the root element. Default value is false. When saving to EPUB or HTML5 (Html5) the DOCTYPE declaration is always written. More...
 
int32_t get_FontResourcesSubsettingSizeThreshold () const
 Controls which font resources need subsetting when saving to HTML, MHTML or EPUB. Default is 0. More...
 
SharedPtr< IFontSavingCallbackget_FontSavingCallback () const
 Allows to control how fonts are saved when a document is saved to HTML, MHTML or EPUB. More...
 
String get_FontsFolder () const
 Specifies the physical folder where fonts are saved when exporting a document to HTML. Default is an empty string. More...
 
String get_FontsFolderAlias () const
 Specifies the name of the folder used to construct font URIs written into an HTML document. Default is an empty string. More...
 
HtmlVersion get_HtmlVersion () const
 Specifies version of HTML standard that should be used when saving the document to HTML or MHTML. Default value is Xhtml. More...
 
int32_t get_ImageResolution ()
 Specifies the output resolution for images when exporting to HTML, MHTML or EPUB. Default is 96 dpi. More...
 
SharedPtr< IImageSavingCallbackget_ImageSavingCallback ()
 Allows to control how images are saved when a document is saved to HTML, MHTML or EPUB. More...
 
String get_ImagesFolder () const
 Specifies the physical folder where images are saved when exporting a document to HTML format. Default is an empty string. More...
 
String get_ImagesFolderAlias () const
 Specifies the name of the folder used to construct image URIs written into an HTML document. Default is an empty string. More...
 
HtmlMetafileFormat get_MetafileFormat ()
 Specifies in what format metafiles are saved when exporting to HTML, MHTML, or EPUB. Default value is Png, meaning that metafiles are rendered to raster PNG images. More...
 
HtmlOfficeMathOutputMode get_OfficeMathOutputMode () const
 Controls how OfficeMath objects are exported to HTML, MHTML or EPUB. Default value is HtmlOfficeMathOutputMode.Image. More...
 
bool get_ResolveFontNames () const
 Specifies whether font family names used in the document are resolved and substituted according to FontSettings when being written into HTML-based formats. More...
 
String get_ResourceFolder () const
 Specifies a physical folder where all resources like images, fonts, and external CSS are saved when a document is exported to HTML. Default is an empty string. More...
 
String get_ResourceFolderAlias () const
 Specifies the name of the folder used to construct URIs of all resources written into an HTML document. Default is an empty string. More...
 
SaveFormat get_SaveFormat () override
 Specifies the format in which the document will be saved if this save options object is used. Can be Html, Mhtml or Epub. More...
 
bool get_ScaleImageToShapeSize ()
 Specifies whether images are scaled by Aspose.Words to the bounding shape size when exporting to HTML, MHTML or EPUB. Default value is true. More...
 
HtmlElementSizeOutputMode get_TableWidthOutputMode () const
 Controls how table, row and cell widths are exported to HTML, MHTML or EPUB. Default value is All. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_AllowNegativeIndent (bool value)
 Setter for get_AllowNegativeIndent. More...
 
void set_CssClassNamePrefix (String value)
 Setter for get_CssClassNamePrefix. More...
 
void set_CssSavingCallback (SharedPtr< ICssSavingCallback > value)
 Setter for get_CssSavingCallback. More...
 
void set_CssStyleSheetFileName (String value)
 Setter for get_CssStyleSheetFileName. More...
 
void set_CssStyleSheetType (CssStyleSheetType value)
 Setter for get_CssStyleSheetType. More...
 
void set_DocumentPartSavingCallback (SharedPtr< IDocumentPartSavingCallback > value)
 Setter for get_DocumentPartSavingCallback. More...
 
void set_DocumentSplitCriteria (DocumentSplitCriteria value)
 Setter for get_DocumentSplitCriteria. More...
 
void set_DocumentSplitHeadingLevel (int32_t value)
 Setter for get_DocumentSplitHeadingLevel. More...
 
void set_Encoding (SharedPtr< Encoding > value)
 Setter for get_Encoding. More...
 
void set_EpubNavigationMapLevel (int32_t value)
 Setter for get_EpubNavigationMapLevel. More...
 
void set_ExportCidUrlsForMhtmlResources (bool value)
 Setter for get_ExportCidUrlsForMhtmlResources. More...
 
void set_ExportDocumentProperties (bool value)
 Setter for get_ExportDocumentProperties. More...
 
void set_ExportDropDownFormFieldAsText (bool value)
 Setter for get_ExportDropDownFormFieldAsText. More...
 
void set_ExportFontResources (bool value)
 Setter for get_ExportFontResources. More...
 
void set_ExportFontsAsBase64 (bool value)
 Setter for get_ExportFontsAsBase64. More...
 
void set_ExportHeadersFootersMode (ExportHeadersFootersMode value)
 Setter for get_ExportHeadersFootersMode. More...
 
void set_ExportImagesAsBase64 (bool value)
 Setter for get_ExportImagesAsBase64. More...
 
void set_ExportLanguageInformation (bool value)
 Setter for get_ExportLanguageInformation. More...
 
void set_ExportListLabels (ExportListLabels value)
 Setter for get_ExportListLabels. More...
 
void set_ExportOriginalUrlForLinkedImages (bool value)
 Setter for get_ExportOriginalUrlForLinkedImages. More...
 
void set_ExportPageMargins (bool value)
 Setter for get_ExportPageMargins. More...
 
void set_ExportPageSetup (bool value)
 Setter for get_ExportPageSetup. More...
 
void set_ExportRelativeFontSize (bool value)
 Setter for get_ExportRelativeFontSize. More...
 
void set_ExportRoundtripInformation (bool value)
 Setter for get_ExportRoundtripInformation. More...
 
void set_ExportTextBoxAsSvg (bool value)
 Setter for get_ExportTextBoxAsSvg. More...
 
void set_ExportTextInputFormFieldAsText (bool value)
 Setter for get_ExportTextInputFormFieldAsText. More...
 
void set_ExportTocPageNumbers (bool value)
 Setter for get_ExportTocPageNumbers. More...
 
void set_ExportXhtmlTransitional (bool value)
 Setter for get_ExportXhtmlTransitional. More...
 
void set_FontResourcesSubsettingSizeThreshold (int32_t value)
 Setter for get_FontResourcesSubsettingSizeThreshold. More...
 
void set_FontSavingCallback (SharedPtr< IFontSavingCallback > value)
 Setter for get_FontSavingCallback. More...
 
void set_FontsFolder (String value)
 Setter for get_FontsFolder. More...
 
void set_FontsFolderAlias (String value)
 Setter for get_FontsFolderAlias. More...
 
void set_HtmlVersion (HtmlVersion value)
 Setter for get_HtmlVersion. More...
 
void set_ImageResolution (int32_t value)
 Setter for get_ImageResolution. More...
 
void set_ImageSavingCallback (SharedPtr< IImageSavingCallback > value)
 Setter for get_ImageSavingCallback. More...
 
void set_ImagesFolder (String value)
 Setter for get_ImagesFolder. More...
 
void set_ImagesFolderAlias (String value)
 Setter for get_ImagesFolderAlias. More...
 
void set_MetafileFormat (HtmlMetafileFormat value)
 Setter for get_MetafileFormat. More...
 
void set_OfficeMathOutputMode (HtmlOfficeMathOutputMode value)
 Setter for get_OfficeMathOutputMode. More...
 
void set_ResolveFontNames (bool value)
 Setter for get_ResolveFontNames. More...
 
void set_ResourceFolder (String value)
 Setter for get_ResourceFolder. More...
 
void set_ResourceFolderAlias (String value)
 Setter for get_ResourceFolderAlias. More...
 
void set_SaveFormat (SaveFormat value) override
 Setter for get_SaveFormat. More...
 
void set_ScaleImageToShapeSize (bool value)
 Setter for get_ScaleImageToShapeSize. More...
 
void set_TableWidthOutputMode (HtmlElementSizeOutputMode value)
 Setter for get_TableWidthOutputMode. More...
 
- Public Member Functions inherited from SaveOptions
bool get_AllowEmbeddingPostScriptFonts () const
 Gets or sets a boolean value indicating whether to allow embedding fonts with PostScript outlines when embedding TrueType fonts in a document upon it is saved. The default value is false. More...
 
SharedPtr< TimeZoneInfoget_CustomTimeZoneInfo () const
 
String get_DefaultTemplate () const
 Gets or sets path to default template (including filename). Default value for this property is empty string (Empty). More...
 
Dml3DEffectsRenderingMode get_Dml3DEffectsRenderingMode () const
 Gets a value determining how 3D effects are rendered. More...
 
virtual DmlEffectsRenderingMode get_DmlEffectsRenderingMode ()
 Gets or sets a value determining how DrawingML effects are rendered. More...
 
DmlRenderingMode get_DmlRenderingMode () const
 Gets or sets a value determining how DrawingML shapes are rendered. More...
 
bool get_MemoryOptimization () const
 Gets or sets value determining if memory optimization should be performed before saving the document. Default value for this property is false. More...
 
bool get_PrettyFormat () const
 When true, pretty formats output where applicable. Default value is false. More...
 
String get_TempFolder () const
 Specifies the folder for temporary files used when saving to a DOC or DOCX file. By default this property is null and no temporary files are used. More...
 
bool get_UpdateCreatedTimeProperty () const
 Gets a value determining whether the CreatedTime property is updated before saving. Default value is false;. More...
 
bool get_UpdateFields () const
 Gets or sets a value determining if fields of certain types should be updated before saving the document to a fixed page format. Default value for this property is true. More...
 
bool get_UpdateLastPrintedProperty () const
 Gets or sets a value determining whether the LastPrinted property is updated before saving. More...
 
bool get_UpdateLastSavedTimeProperty () const
 Gets or sets a value determining whether the LastSavedTime property is updated before saving. More...
 
bool get_UpdateSdtContent () const
 Gets or sets value determining whether content of StructuredDocumentTag is updated before saving. More...
 
bool get_UseAntiAliasing () const
 Gets or sets a value determining whether or not to use anti-aliasing for rendering. More...
 
bool get_UseHighQualityRendering () const
 Gets or sets a value determining whether or not to use high quality (i.e. slow) rendering algorithms. More...
 
void set_AllowEmbeddingPostScriptFonts (bool value)
 Setter for get_AllowEmbeddingPostScriptFonts. More...
 
void set_CustomTimeZoneInfo (SharedPtr< TimeZoneInfo > value)
 
void set_DefaultTemplate (String value)
 Setter for get_DefaultTemplate. More...
 
void set_Dml3DEffectsRenderingMode (Dml3DEffectsRenderingMode value)
 Sets a value determining how 3D effects are rendered. More...
 
virtual void set_DmlEffectsRenderingMode (DmlEffectsRenderingMode value)
 Setter for get_DmlEffectsRenderingMode. More...
 
void set_DmlRenderingMode (DmlRenderingMode value)
 Setter for get_DmlRenderingMode. More...
 
void set_MemoryOptimization (bool value)
 Setter for get_MemoryOptimization. More...
 
void set_PrettyFormat (bool value)
 Setter for get_PrettyFormat. More...
 
void set_TempFolder (String value)
 Setter for get_TempFolder. More...
 
void set_UpdateCreatedTimeProperty (bool value)
 Sets a value determining whether the CreatedTime property is updated before saving. Default value is false;. More...
 
void set_UpdateFields (bool value)
 Setter for get_UpdateFields. More...
 
void set_UpdateLastPrintedProperty (bool value)
 Setter for get_UpdateLastPrintedProperty. More...
 
void set_UpdateLastSavedTimeProperty (bool value)
 Setter for get_UpdateLastSavedTimeProperty. More...
 
void set_UpdateSdtContent (bool value)
 Setter for get_UpdateSdtContent. More...
 
void set_UseAntiAliasing (bool value)
 Setter for get_UseAntiAliasing. More...
 
void set_UseHighQualityRendering (bool value)
 Setter for get_UseHighQualityRendering. More...
 
- Public Member Functions inherited from Object
ASPOSECPP_SHARED_API Object ()
 
ASPOSECPP_SHARED_API Object (Object const &x)
 
virtual ASPOSECPP_SHARED_API ~Object ()
 
virtual ASPOSECPP_SHARED_API bool Equals (ptr obj)
 
virtual ASPOSECPP_SHARED_API bool FastCast (const Details::FastRttiBase &helper, void **out_ptr) const
 
Detail::SmartPtrCounter * GetCounter ()
 
virtual ASPOSECPP_SHARED_API int32_t GetHashCode () const
 
ASPOSECPP_SHARED_API void Lock ()
 
virtual ASPOSECPP_SHARED_API ptr MemberwiseClone () const
 
Objectoperator= (Object const &x)
 
bool ReferenceEquals (String const &str, std::nullptr_t)
 
bool ReferenceEquals (String const &str1, String const &str2)
 
int RemovedSharedRefs (int count)
 
virtual ASPOSECPP_SHARED_API void SetTemplateWeakPtr (uint32_t argument)
 
int SharedCount () const
 
ObjectSharedRefAdded ()
 
int SharedRefRemovedSafe ()
 
virtual ASPOSECPP_SHARED_API String ToString () const
 
ASPOSECPP_SHARED_API void Unlock ()
 
Detail::SmartPtrCounter * WeakRefAdded ()
 
void WeakRefRemoved ()
 

Static Public Member Functions

static const TypeInfoType ()
 
- Static Public Member Functions inherited from SaveOptions
static SharedPtr< SaveOptionsCreateSaveOptions (SaveFormat saveFormat)
 Creates a save options object of a class suitable for the specified save format. More...
 
static SharedPtr< SaveOptionsCreateSaveOptions (String fileName)
 Creates a save options object of a class suitable for the file extension specified in the given file name. More...
 
static const TypeInfoType ()
 
- Static Public Member Functions inherited from Object
bool Equals (double const &objA, double const &objB)
 
bool Equals (float const &objA, float const &objB)
 
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 
static const TypeInfoType ()
 

Additional Inherited Members

- Public Types inherited from Object
typedef SmartPtr< Objectptr
 

Constructor & Destructor Documentation

◆ HtmlSaveOptions() [1/2]

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

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

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);

◆ HtmlSaveOptions() [2/2]

Aspose::Words::Saving::HtmlSaveOptions::HtmlSaveOptions ( Aspose::Words::SaveFormat  saveFormat)

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

Parameters
saveFormatCan be Html, Mhtml or Epub.
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)
{
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=\"border-collapse:collapse\">"));
break;
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=\"border-collapse:collapse\">"));
break;
}
static ASPOSECPP_SHARED_API String ReadAllText(const String &path, const EncodingPtr &encoding=Text::Encoding::get_UTF8())
@ Xhtml
Saves the document in compliance with the XHTML 1.0 Transitional standard.
@ Html5
Saves the document in compliance with the HTML 5 standard.

Member Function Documentation

◆ get_AllowNegativeIndent()

bool Aspose::Words::Saving::HtmlSaveOptions::get_AllowNegativeIndent ( ) const

Specifies whether negative left and right indents of paragraphs are normalized when saving to HTML, MHTML or EPUB. Default value is false.

When negative indent is not allowed, it is exported as zero margin to HTML. When negative indent is allowed, a paragraph might appear partially outside of the browser window.

Examples

Shows how to preserve negative indents in the output .html.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a table with a negative indent, which will push it to the left past the left page boundary.
SharedPtr<Table> table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Row 1, Cell 1");
builder->InsertCell();
builder->Write(u"Row 1, Cell 2");
builder->EndTable();
table->set_LeftIndent(-36);
table->set_PreferredWidth(PreferredWidth::FromPoints(144));
builder->InsertBreak(BreakType::ParagraphBreak);
// Insert a table with a positive indent, which will push the table to the right.
table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Row 1, Cell 1");
builder->InsertCell();
builder->Write(u"Row 1, Cell 2");
builder->EndTable();
table->set_LeftIndent(36);
table->set_PreferredWidth(PreferredWidth::FromPoints(144));
// When we save a document to HTML, Aspose.Words will only preserve negative indents
// such as the one we have applied to the first table if we set the "AllowNegativeIndent" flag
// in a SaveOptions object that we will pass to "true".
auto options = MakeObject<HtmlSaveOptions>(SaveFormat::Html);
options->set_AllowNegativeIndent(allowNegativeIndent);
options->set_TableWidthOutputMode(HtmlElementSizeOutputMode::RelativeOnly);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.NegativeIndent.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.NegativeIndent.html");
if (allowNegativeIndent)
{
ASSERT_TRUE(outDocContents.Contains(u"<table cellspacing=\"0\" cellpadding=\"0\" style=\"margin-left:-41.65pt; border:0.75pt solid #000000; "
u"-aw-border:0.5pt single; border-collapse:collapse\">"));
ASSERT_TRUE(outDocContents.Contains(u"<table cellspacing=\"0\" cellpadding=\"0\" style=\"margin-left:30.35pt; border:0.75pt solid #000000; "
u"-aw-border:0.5pt single; border-collapse:collapse\">"));
}
else
{
ASSERT_TRUE(outDocContents.Contains(
u"<table cellspacing=\"0\" cellpadding=\"0\" style=\"border:0.75pt solid #000000; -aw-border:0.5pt single; border-collapse:collapse\">"));
ASSERT_TRUE(outDocContents.Contains(u"<table cellspacing=\"0\" cellpadding=\"0\" style=\"margin-left:30.35pt; border:0.75pt solid #000000; "
u"-aw-border:0.5pt single; border-collapse:collapse\">"));
}
@ RelativeOnly
Element sizes are exported only if they are specified in relative units in the document....
@ ParagraphBreak
Break between paragraphs.

◆ get_CssClassNamePrefix()

System::String Aspose::Words::Saving::HtmlSaveOptions::get_CssClassNamePrefix ( ) const

Specifies a prefix which is added to all CSS class names. Default value is an empty string and generated CSS class names have no common prefix.

If this value is not empty, all CSS classes generated by Aspose.Words will start with the specified prefix. This might be useful, for example, if you add custom CSS to generated documents and want to prevent class name conflicts.

If the value is not null or empty, it must be a valid CSS identifier.

Exceptions
System::ArgumentExceptionThe value is not empty and is not a valid CSS identifier.
Examples

Shows how to save a document to HTML, and add a prefix to all of its CSS class names.

auto doc = MakeObject<Document>(MyDir + u"Paragraphs.docx");
auto saveOptions = MakeObject<HtmlSaveOptions>();
saveOptions->set_CssStyleSheetType(CssStyleSheetType::External);
saveOptions->set_CssClassNamePrefix(u"myprefix-");
doc->Save(ArtifactsDir + u"HtmlSaveOptions.CssClassNamePrefix.html", saveOptions);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.CssClassNamePrefix.html");
ASSERT_TRUE(outDocContents.Contains(u"<p class=\"myprefix-Header\">"));
ASSERT_TRUE(outDocContents.Contains(u"<p class=\"myprefix-Footer\">"));
outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.CssClassNamePrefix.css");
ASSERT_TRUE(outDocContents.Contains(String(u".myprefix-Footer { margin-bottom:0pt; line-height:normal; font-family:Arial; font-size:11pt }\r\n") +
u".myprefix-Header { margin-bottom:0pt; line-height:normal; font-family:Arial; font-size:11pt }\r\n"));
@ External
CSS styles are written separately from the content in a style sheet in an external file....

◆ get_CssSavingCallback()

System::SharedPtr<Aspose::Words::Saving::ICssSavingCallback> Aspose::Words::Saving::HtmlSaveOptions::get_CssSavingCallback ( ) const

Allows to control how CSS styles are saved when a document is saved to HTML, MHTML or EPUB.

Examples

Shows how to work with CSS stylesheets that an HTML conversion creates.

void ExternalCssFilenames()
{
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Create an "HtmlFixedSaveOptions" object, which we can pass to the document's "Save" method
// to modify how we convert the document to HTML.
auto options = MakeObject<HtmlSaveOptions>();
// Set the "CssStylesheetType" property to "CssStyleSheetType.External" to
// accompany a saved HTML document with an external CSS stylesheet file.
options->set_CssStyleSheetType(CssStyleSheetType::External);
// Below are two ways of specifying directories and filenames for output CSS stylesheets.
// 1 - Use the "CssStyleSheetFileName" property to assign a filename to our stylesheet:
options->set_CssStyleSheetFileName(ArtifactsDir + u"SavingCallback.ExternalCssFilenames.css");
// 2 - Use a custom callback to name our stylesheet:
options->set_CssSavingCallback(
MakeObject<ExSavingCallback::CustomCssSavingCallback>(ArtifactsDir + u"SavingCallback.ExternalCssFilenames.css", true, false));
doc->Save(ArtifactsDir + u"SavingCallback.ExternalCssFilenames.html", options);
}
class CustomCssSavingCallback : public ICssSavingCallback
{
public:
CustomCssSavingCallback(String cssDocFilename, bool isExportNeeded, bool keepCssStreamOpen) : mIsExportNeeded(false), mKeepCssStreamOpen(false)
{
mCssTextFileName = cssDocFilename;
mIsExportNeeded = isExportNeeded;
mKeepCssStreamOpen = keepCssStreamOpen;
}
void CssSaving(SharedPtr<CssSavingArgs> args) override
{
// We can access the entire source document via the "Document" property.
ASSERT_TRUE(args->get_Document()->get_OriginalFileName().EndsWith(u"Rendering.docx"));
args->set_CssStream(MakeObject<System::IO::FileStream>(mCssTextFileName, System::IO::FileMode::Create));
args->set_IsExportNeeded(mIsExportNeeded);
args->set_KeepCssStreamOpen(mKeepCssStreamOpen);
ASSERT_TRUE(args->get_CssStream()->get_CanWrite());
}
private:
String mCssTextFileName;
bool mIsExportNeeded;
bool mKeepCssStreamOpen;
};

◆ get_CssStyleSheetFileName()

System::String Aspose::Words::Saving::HtmlSaveOptions::get_CssStyleSheetFileName ( ) const

Specifies the path and the name of the Cascading Style Sheet (CSS) file written when a document is exported to HTML. Default is an empty string.

This property has effect only when saving a document to HTML format and external CSS style sheet is requested using CssStyleSheetType.

If this property is empty, the CSS file will be saved into the same folder and with the same name as the HTML document but with the ".css" extension.

If only path but no file name is specified in this property, the CSS file will be saved into the specified folder and will have the same name as the HTML document but with the ".css" extension.

If the folder specified by this property doesn't exist, it will be created automatically before the CSS file is saved.

Another way to specify a folder where external CSS file is saved is to use ResourceFolder.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_ResourceFolder
Aspose::Words::Saving::HtmlSaveOptions::get_ResourceFolderAlias
Aspose::Words::Saving::HtmlSaveOptions::get_CssStyleSheetType
Examples

Shows how to work with CSS stylesheets that an HTML conversion creates.

void ExternalCssFilenames()
{
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Create an "HtmlFixedSaveOptions" object, which we can pass to the document's "Save" method
// to modify how we convert the document to HTML.
auto options = MakeObject<HtmlSaveOptions>();
// Set the "CssStylesheetType" property to "CssStyleSheetType.External" to
// accompany a saved HTML document with an external CSS stylesheet file.
options->set_CssStyleSheetType(CssStyleSheetType::External);
// Below are two ways of specifying directories and filenames for output CSS stylesheets.
// 1 - Use the "CssStyleSheetFileName" property to assign a filename to our stylesheet:
options->set_CssStyleSheetFileName(ArtifactsDir + u"SavingCallback.ExternalCssFilenames.css");
// 2 - Use a custom callback to name our stylesheet:
options->set_CssSavingCallback(
MakeObject<ExSavingCallback::CustomCssSavingCallback>(ArtifactsDir + u"SavingCallback.ExternalCssFilenames.css", true, false));
doc->Save(ArtifactsDir + u"SavingCallback.ExternalCssFilenames.html", options);
}
class CustomCssSavingCallback : public ICssSavingCallback
{
public:
CustomCssSavingCallback(String cssDocFilename, bool isExportNeeded, bool keepCssStreamOpen) : mIsExportNeeded(false), mKeepCssStreamOpen(false)
{
mCssTextFileName = cssDocFilename;
mIsExportNeeded = isExportNeeded;
mKeepCssStreamOpen = keepCssStreamOpen;
}
void CssSaving(SharedPtr<CssSavingArgs> args) override
{
// We can access the entire source document via the "Document" property.
ASSERT_TRUE(args->get_Document()->get_OriginalFileName().EndsWith(u"Rendering.docx"));
args->set_CssStream(MakeObject<System::IO::FileStream>(mCssTextFileName, System::IO::FileMode::Create));
args->set_IsExportNeeded(mIsExportNeeded);
args->set_KeepCssStreamOpen(mKeepCssStreamOpen);
ASSERT_TRUE(args->get_CssStream()->get_CanWrite());
}
private:
String mCssTextFileName;
bool mIsExportNeeded;
bool mKeepCssStreamOpen;
};

◆ get_CssStyleSheetType()

Aspose::Words::Saving::CssStyleSheetType Aspose::Words::Saving::HtmlSaveOptions::get_CssStyleSheetType ( ) const

Specifies how CSS (Cascading Style Sheet) styles are exported to HTML, MHTML or EPUB. Default value is Inline for HTML/MHTML and External for EPUB.

Saving CSS style sheet into an external file is only supported when saving to HTML. When you are exporting to one of the container formats (EPUB or MHTML) and specifying External, CSS file will be encapsulated into the output package.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_CssStyleSheetFileName
Examples

Shows how to work with CSS stylesheets that an HTML conversion creates.

void ExternalCssFilenames()
{
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Create an "HtmlFixedSaveOptions" object, which we can pass to the document's "Save" method
// to modify how we convert the document to HTML.
auto options = MakeObject<HtmlSaveOptions>();
// Set the "CssStylesheetType" property to "CssStyleSheetType.External" to
// accompany a saved HTML document with an external CSS stylesheet file.
options->set_CssStyleSheetType(CssStyleSheetType::External);
// Below are two ways of specifying directories and filenames for output CSS stylesheets.
// 1 - Use the "CssStyleSheetFileName" property to assign a filename to our stylesheet:
options->set_CssStyleSheetFileName(ArtifactsDir + u"SavingCallback.ExternalCssFilenames.css");
// 2 - Use a custom callback to name our stylesheet:
options->set_CssSavingCallback(
MakeObject<ExSavingCallback::CustomCssSavingCallback>(ArtifactsDir + u"SavingCallback.ExternalCssFilenames.css", true, false));
doc->Save(ArtifactsDir + u"SavingCallback.ExternalCssFilenames.html", options);
}
class CustomCssSavingCallback : public ICssSavingCallback
{
public:
CustomCssSavingCallback(String cssDocFilename, bool isExportNeeded, bool keepCssStreamOpen) : mIsExportNeeded(false), mKeepCssStreamOpen(false)
{
mCssTextFileName = cssDocFilename;
mIsExportNeeded = isExportNeeded;
mKeepCssStreamOpen = keepCssStreamOpen;
}
void CssSaving(SharedPtr<CssSavingArgs> args) override
{
// We can access the entire source document via the "Document" property.
ASSERT_TRUE(args->get_Document()->get_OriginalFileName().EndsWith(u"Rendering.docx"));
args->set_CssStream(MakeObject<System::IO::FileStream>(mCssTextFileName, System::IO::FileMode::Create));
args->set_IsExportNeeded(mIsExportNeeded);
args->set_KeepCssStreamOpen(mKeepCssStreamOpen);
ASSERT_TRUE(args->get_CssStream()->get_CanWrite());
}
private:
String mCssTextFileName;
bool mIsExportNeeded;
bool mKeepCssStreamOpen;
};

◆ get_DocumentPartSavingCallback()

System::SharedPtr<Aspose::Words::Saving::IDocumentPartSavingCallback> Aspose::Words::Saving::HtmlSaveOptions::get_DocumentPartSavingCallback ( ) const

Allows to control how document parts are saved when a document is saved to HTML or EPUB.

Examples

Shows how to split a document into parts and save them.

void DocumentPartsFileNames()
{
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
String outFileName = u"SavingCallback.DocumentPartsFileNames.html";
// Create an "HtmlFixedSaveOptions" object, which we can pass to the document's "Save" method
// to modify how we convert the document to HTML.
auto options = MakeObject<HtmlSaveOptions>();
// If we save the document normally, there will be one output HTML
// document with all the source document's contents.
// Set the "DocumentSplitCriteria" property to "DocumentSplitCriteria.SectionBreak" to
// save our document to multiple HTML files: one for each section.
options->set_DocumentSplitCriteria(DocumentSplitCriteria::SectionBreak);
// Assign a custom callback to the "DocumentPartSavingCallback" property to alter the document part saving logic.
options->set_DocumentPartSavingCallback(MakeObject<ExSavingCallback::SavedDocumentPartRename>(outFileName, options->get_DocumentSplitCriteria()));
// If we convert a document that contains images into html, we will end up with one html file which links to several images.
// Each image will be in the form of a file in the local file system.
// There is also a callback that can customize the name and file system location of each image.
options->set_ImageSavingCallback(MakeObject<ExSavingCallback::SavedImageRename>(outFileName));
doc->Save(ArtifactsDir + outFileName, options);
}
class SavedDocumentPartRename : public IDocumentPartSavingCallback
{
public:
SavedDocumentPartRename(String outFileName, DocumentSplitCriteria documentSplitCriteria)
: mCount(0), mDocumentSplitCriteria(((Aspose::Words::Saving::DocumentSplitCriteria)0))
{
mOutFileName = outFileName;
mDocumentSplitCriteria = documentSplitCriteria;
}
void DocumentPartSaving(SharedPtr<DocumentPartSavingArgs> args) override
{
// We can access the entire source document via the "Document" property.
ASSERT_TRUE(args->get_Document()->get_OriginalFileName().EndsWith(u"Rendering.docx"));
String partType = String::Empty;
switch (mDocumentSplitCriteria)
{
partType = u"Page";
break;
partType = u"Column";
break;
partType = u"Section";
break;
partType = u"Paragraph from heading";
break;
default:
break;
}
String partFileName = String::Format(u"{0} part {1}, of type {2}{3}", mOutFileName, ++mCount, partType,
System::IO::Path::GetExtension(args->get_DocumentPartFileName()));
// Below are two ways of specifying where Aspose.Words will save each part of the document.
// 1 - Set a filename for the output part file:
args->set_DocumentPartFileName(partFileName);
// 2 - Create a custom stream for the output part file:
args->set_DocumentPartStream(MakeObject<System::IO::FileStream>(ArtifactsDir + partFileName, System::IO::FileMode::Create));
ASSERT_TRUE(args->get_DocumentPartStream()->get_CanWrite());
ASSERT_FALSE(args->get_KeepDocumentPartStreamOpen());
}
private:
int mCount;
String mOutFileName;
DocumentSplitCriteria mDocumentSplitCriteria;
};
class SavedImageRename : public IImageSavingCallback
{
public:
SavedImageRename(String outFileName) : mCount(0)
{
mOutFileName = outFileName;
}
void ImageSaving(SharedPtr<ImageSavingArgs> args) override
{
String imageFileName = String::Format(u"{0} shape {1}, of type {2}{3}", mOutFileName, ++mCount, args->get_CurrentShape()->get_ShapeType(),
System::IO::Path::GetExtension(args->get_ImageFileName()));
// Below are two ways of specifying where Aspose.Words will save each part of the document.
// 1 - Set a filename for the output image file:
args->set_ImageFileName(imageFileName);
// 2 - Create a custom stream for the output image file:
args->set_ImageStream(MakeObject<System::IO::FileStream>(ArtifactsDir + imageFileName, System::IO::FileMode::Create));
ASSERT_TRUE(args->get_ImageStream()->get_CanWrite());
ASSERT_TRUE(args->get_IsImageAvailable());
ASSERT_FALSE(args->get_KeepImageStreamOpen());
}
private:
int mCount;
String mOutFileName;
};

◆ get_DocumentSplitCriteria()

Aspose::Words::Saving::DocumentSplitCriteria Aspose::Words::Saving::HtmlSaveOptions::get_DocumentSplitCriteria ( ) const

Specifies how the document should be split when saving to Html or Epub format. Default is None for HTML and HeadingParagraph for EPUB.

Normally you would want a document saved to HTML as a single file. But in some cases it is preferable to split the output into several smaller HTML pages. When saving to HTML format these pages will be output to individual files or streams. When saving to EPUB format they will be incorporated into corresponding packages.

A document cannot be split when saving in the MHTML format.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_DocumentSplitHeadingLevel
Aspose::Words::Saving::HtmlSaveOptions::get_DocumentPartSavingCallback
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);

◆ get_DocumentSplitHeadingLevel()

int32_t Aspose::Words::Saving::HtmlSaveOptions::get_DocumentSplitHeadingLevel ( ) const

Specifies the maximum level of headings at which to split the document. Default value is 2.

When DocumentSplitCriteria includes HeadingParagraph and this property is set to a value from 1 to 9, the document will be split at paragraphs formatted using Heading 1, Heading 2 , Heading 3 etc. styles up to the specified heading level.

By default, only Heading 1 and Heading 2 paragraphs cause the document to be split. Setting this property to zero will cause the document not to be split at heading paragraphs at all.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_DocumentSplitCriteria
Aspose::Words::Saving::HtmlSaveOptions::get_DocumentPartSavingCallback
Examples

Shows how to split an output HTML document by headings into several parts.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Every paragraph that we format using a "Heading" style can serve as a heading.
// Each heading may also have a heading level, determined by the number of its heading style.
// The headings below are of levels 1-3.
builder->get_ParagraphFormat()->set_Style(builder->get_Document()->get_Styles()->idx_get(u"Heading 1"));
builder->Writeln(u"Heading #1");
builder->get_ParagraphFormat()->set_Style(builder->get_Document()->get_Styles()->idx_get(u"Heading 2"));
builder->Writeln(u"Heading #2");
builder->get_ParagraphFormat()->set_Style(builder->get_Document()->get_Styles()->idx_get(u"Heading 3"));
builder->Writeln(u"Heading #3");
builder->get_ParagraphFormat()->set_Style(builder->get_Document()->get_Styles()->idx_get(u"Heading 1"));
builder->Writeln(u"Heading #4");
builder->get_ParagraphFormat()->set_Style(builder->get_Document()->get_Styles()->idx_get(u"Heading 2"));
builder->Writeln(u"Heading #5");
builder->get_ParagraphFormat()->set_Style(builder->get_Document()->get_Styles()->idx_get(u"Heading 3"));
builder->Writeln(u"Heading #6");
// Create a HtmlSaveOptions object and set the split criteria to "HeadingParagraph".
// These criteria will split the document at paragraphs with "Heading" styles into several smaller documents,
// and save each document in a separate HTML file in the local file system.
// We will also set the maximum heading level, which splits the document to 2.
// Saving the document will split it at headings of levels 1 and 2, but not at 3 to 9.
auto options = MakeObject<HtmlSaveOptions>();
options->set_DocumentSplitCriteria(DocumentSplitCriteria::HeadingParagraph);
options->set_DocumentSplitHeadingLevel(2);
// Our document has four headings of levels 1 - 2. One of those headings will not be
// a split point since it is at the beginning of the document.
// The saving operation will split our document at three places, into four smaller documents.
doc->Save(ArtifactsDir + u"HtmlSaveOptions.HeadingLevels.html", options);
doc = MakeObject<Document>(ArtifactsDir + u"HtmlSaveOptions.HeadingLevels.html");
ASSERT_EQ(u"Heading #1", doc->GetText().Trim());
doc = MakeObject<Document>(ArtifactsDir + u"HtmlSaveOptions.HeadingLevels-01.html");
ASSERT_EQ(String(u"Heading #2\r") + u"Heading #3", doc->GetText().Trim());
doc = MakeObject<Document>(ArtifactsDir + u"HtmlSaveOptions.HeadingLevels-02.html");
ASSERT_EQ(u"Heading #4", doc->GetText().Trim());
doc = MakeObject<Document>(ArtifactsDir + u"HtmlSaveOptions.HeadingLevels-03.html");
ASSERT_EQ(String(u"Heading #5\r") + u"Heading #6", doc->GetText().Trim());

◆ get_Encoding()

System::SharedPtr<System::Text::Encoding> Aspose::Words::Saving::HtmlSaveOptions::get_Encoding ( ) const

Specifies the encoding to use when exporting to HTML, MHTML or EPUB. Default value is new UTF8Encoding(false) (UTF-8 without BOM).

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);

◆ get_EpubNavigationMapLevel()

int32_t Aspose::Words::Saving::HtmlSaveOptions::get_EpubNavigationMapLevel ( ) const

Specifies the maximum level of headings populated to the navigation map when exporting to IDPF EPUB format. Default value is 3.

Navigation map in IDPF EPUB format allows user agents to provide easy way of navigation through the document structure. Usually navigation points correspond to headings in the document. To populate headings up to level N assign this value to EpubNavigationMapLevel.

By default, three levels of headings are populated: paragraphs of styles Heading 1, Heading 2 and Heading 3. You can set this property to a value from 1 to 9 to request corresponding maximum level. Setting it to zero will reduce navigation map to only document root or roots of document parts.

Examples

Shows how to filter headings that appear in the navigation panel of a saved Epub document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Every paragraph that we format using a "Heading" style can serve as a heading.
// Each heading may also have a heading level, determined by the number of its heading style.
// The headings below are of levels 1-3.
builder->get_ParagraphFormat()->set_Style(builder->get_Document()->get_Styles()->idx_get(u"Heading 1"));
builder->Writeln(u"Heading #1");
builder->get_ParagraphFormat()->set_Style(builder->get_Document()->get_Styles()->idx_get(u"Heading 2"));
builder->Writeln(u"Heading #2");
builder->get_ParagraphFormat()->set_Style(builder->get_Document()->get_Styles()->idx_get(u"Heading 3"));
builder->Writeln(u"Heading #3");
builder->get_ParagraphFormat()->set_Style(builder->get_Document()->get_Styles()->idx_get(u"Heading 1"));
builder->Writeln(u"Heading #4");
builder->get_ParagraphFormat()->set_Style(builder->get_Document()->get_Styles()->idx_get(u"Heading 2"));
builder->Writeln(u"Heading #5");
builder->get_ParagraphFormat()->set_Style(builder->get_Document()->get_Styles()->idx_get(u"Heading 3"));
builder->Writeln(u"Heading #6");
// Epub readers typically create a table of contents for their documents.
// Each paragraph with a "Heading" style in the document will create an entry in this table of contents.
// We can use the "EpubNavigationMapLevel" property to set a maximum heading level.
// The Epub reader will not add headings with a level above the one we specify to the contents table.
auto options = MakeObject<HtmlSaveOptions>(SaveFormat::Epub);
options->set_EpubNavigationMapLevel(2);
// Our document has six headings, two of which are above level 2.
// The table of contents for this document will have four entries.
doc->Save(ArtifactsDir + u"HtmlSaveOptions.EpubHeadings.epub", options);

◆ get_ExportCidUrlsForMhtmlResources()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ExportCidUrlsForMhtmlResources ( ) const

Specifies whether to use CID (Content-ID) URLs to reference resources (images, fonts, CSS) included in MHTML documents. Default value is false.

This option affects only documents being saved to MHTML.

By default, resources in MHTML documents are referenced by file name (for example, "image.png"), which are matched against "Content-Location" headers of MIME parts.

This option enables an alternative method, where references to resource files are written as CID (Content-ID) URLs (for example, "cid:image.png") and are matched against "Content-ID" headers.

In theory, there should be no difference between the two referencing methods and either of them should work fine in any browser or mail agent. In practice, however, some agents fail to fetch resources by file name. If your browser or mail agent refuses to load resources included in an MTHML document (doesn't show images or doesn't load CSS styles), try exporting the document with CID URLs.

Examples

Shows how to enable content IDs for output MHTML documents.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Setting this flag will replace "Content-Location" tags
// with "Content-ID" tags for each resource from the input document.
auto options = MakeObject<HtmlSaveOptions>(SaveFormat::Mhtml);
options->set_ExportCidUrlsForMhtmlResources(exportCidUrlsForMhtmlResources);
options->set_CssStyleSheetType(CssStyleSheetType::External);
options->set_ExportFontResources(true);
options->set_PrettyFormat(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ContentIdUrls.mht", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.ContentIdUrls.mht");
if (exportCidUrlsForMhtmlResources)
{
ASSERT_TRUE(outDocContents.Contains(u"Content-ID: <document.html>"));
ASSERT_TRUE(outDocContents.Contains(u"<link href=3D\"cid:styles.css\" type=3D\"text/css\" rel=3D\"stylesheet\" />"));
ASSERT_TRUE(outDocContents.Contains(u"@font-face { font-family:'Arial Black'; src:url('cid:ariblk.ttf') }"));
ASSERT_TRUE(outDocContents.Contains(u"<img src=3D\"cid:image.003.jpeg\" width=3D\"351\" height=3D\"180\" alt=3D\"\" />"));
}
else
{
ASSERT_TRUE(outDocContents.Contains(u"Content-Location: document.html"));
ASSERT_TRUE(outDocContents.Contains(u"<link href=3D\"styles.css\" type=3D\"text/css\" rel=3D\"stylesheet\" />"));
ASSERT_TRUE(outDocContents.Contains(u"@font-face { font-family:'Arial Black'; src:url('ariblk.ttf') }"));
ASSERT_TRUE(outDocContents.Contains(u"<img src=3D\"image.003.jpeg\" width=3D\"351\" height=3D\"180\" alt=3D\"\" />"));
}
@ Mhtml
Saves the document in the MHTML (Web archive) format.

◆ get_ExportDocumentProperties()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ExportDocumentProperties ( ) const

Specifies whether to export built-in and custom document properties to HTML, MHTML or EPUB. Default value is false.

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);

◆ get_ExportDropDownFormFieldAsText()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ExportDropDownFormFieldAsText ( ) const

Controls how drop-down form fields are saved to HTML or MHTML. Default value is false.

When set to true, exports drop-down form fields as normal text. When false, exports drop-down form fields as SELECT element in HTML.

When exporting to EPUB, text drop-down form fields are always saved as text due to requirements of this format.

Examples

Shows how to get drop-down combo box form fields to blend in with paragraph text when saving to html.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Use a document builder to insert a combo box with the value "Two" selected.
builder->InsertComboBox(u"MyComboBox", MakeArray<String>({u"One", u"Two", u"Three"}), 1);
// The "ExportDropDownFormFieldAsText" flag of this SaveOptions object allows us to
// control how saving the document to HTML treats drop-down combo boxes.
// Setting it to "true" will convert each combo box into simple text
// that displays the combo box's currently selected value, effectively freezing it.
// Setting it to "false" will preserve the functionality of the combo box using <select> and <option> tags.
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportDropDownFormFieldAsText(exportDropDownFormFieldAsText);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.DropDownFormField.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.DropDownFormField.html");
if (exportDropDownFormFieldAsText)
{
ASSERT_TRUE(outDocContents.Contains(u"<span>Two</span>"));
}
else
{
ASSERT_TRUE(outDocContents.Contains(String(u"<select name=\"MyComboBox\">") + u"<option>One</option>" +
u"<option selected=\"selected\">Two</option>" + u"<option>Three</option>" + u"</select>"));
}

◆ get_ExportFontResources()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ExportFontResources ( ) const

Specifies whether font resources should be exported to HTML, MHTML or EPUB. Default is false.

Exporting font resources allows for consistent document rendering independent of the fonts available in a given user's environment.

If ExportFontResources is set to true, main HTML document will refer to every font via the CSS 3 @font-face at-rule and fonts will be output as separate files. When exporting to IDPF EPUB or MHTML formats, fonts will be embedded into the corresponding package along with other subsidiary files.

If ExportFontsAsBase64 is set to true, fonts will not be saved to separate files. Instead, they will be embedded into @font-face at-rules in Base64 encoding.

Important! When exporting font resources, font licensing issues should be considered. Authors who want to use specific fonts via a downloadable font mechanism must always carefully verify that their intended use is within the scope of the font license. Many commercial fonts presently do not allow web downloading of their fonts in any form. License agreements that cover some fonts specifically note that usage via @font-face rules in CSS style sheets is not allowed. Font subsetting can also violate license terms.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_FontResourcesSubsettingSizeThreshold
Examples

Shows how to define custom logic for exporting fonts when saving to HTML.

void SaveExportedFonts()
{
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Configure a SaveOptions object to export fonts to separate files.
// Set a callback that will handle font saving in a custom manner.
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportFontResources(true);
options->set_FontSavingCallback(MakeObject<ExHtmlSaveOptions::HandleFontSaving>());
// The callback will export .ttf files and save them alongside the output document.
doc->Save(ArtifactsDir + u"HtmlSaveOptions.SaveExportedFonts.html", options);
std::function<bool(String s)> endsWithTtf = [](String s)
{
return s.EndsWith(u".ttf");
};
for (String fontFilename : System::Array<String>::FindAll(System::IO::Directory::GetFiles(ArtifactsDir), endsWithTtf))
{
std::cout << fontFilename << std::endl;
}
}
class HandleFontSaving : public IFontSavingCallback
{
public:
void FontSaving(SharedPtr<FontSavingArgs> args) override
{
std::cout << "Font:\t" << args->get_FontFamilyName();
if (args->get_Bold())
{
std::cout << ", bold";
}
if (args->get_Italic())
{
std::cout << ", italic";
}
std::cout << "\nSource:\t" << args->get_OriginalFileName() << ", " << args->get_OriginalFileSize() << " bytes\n" << std::endl;
// We can also access the source document from here.
ASSERT_TRUE(args->get_Document()->get_OriginalFileName().EndsWith(u"Rendering.docx"));
ASSERT_TRUE(args->get_IsExportNeeded());
ASSERT_TRUE(args->get_IsSubsettingNeeded());
// There are two ways of saving an exported font.
// 1 - Save it to a local file system location:
args->set_FontFileName(args->get_OriginalFileName().Split(MakeArray<char16_t>({System::IO::Path::DirectorySeparatorChar}))->LINQ_Last());
// 2 - Save it to a stream:
args->set_FontStream(MakeObject<System::IO::FileStream>(
ArtifactsDir + args->get_OriginalFileName().Split(MakeArray<char16_t>({System::IO::Path::DirectorySeparatorChar}))->LINQ_Last(),
ASSERT_FALSE(args->get_KeepFontStreamOpen());
}
};
static ASPOSECPP_SHARED_API ArrayPtr< String > GetFiles(const String &path, const String &searchPattern=u"*", SearchOption searchOption=SearchOption::TopDirectoryOnly)

◆ get_ExportFontsAsBase64()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ExportFontsAsBase64 ( ) const

Specifies whether fonts resources should be embedded to HTML in Base64 encoding. Default is false.

By default, fonts are written to separate files. If this option is set to true, fonts will be embedded into the document's CSS in Base64 encoding.

Examples

Shows how to save a .html document with images embedded inside it.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportImagesAsBase64(exportItemsAsBase64);
options->set_PrettyFormat(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportImagesAsBase64.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.ExportImagesAsBase64.html");
ASSERT_TRUE(exportItemsAsBase64 ? outDocContents.Contains(u"<img src=\"data:image/png;base64")
: outDocContents.Contains(u"<img src=\"HtmlSaveOptions.ExportImagesAsBase64.001.png\""));

Shows how to embed fonts inside a saved HTML document.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportFontsAsBase64(true);
options->set_CssStyleSheetType(CssStyleSheetType::Embedded);
options->set_PrettyFormat(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportFontsAsBase64.html", options);
@ Embedded
CSS styles are written separately from the content in a style sheet embedded in the HTML file.

◆ get_ExportHeadersFootersMode()

Aspose::Words::Saving::ExportHeadersFootersMode Aspose::Words::Saving::HtmlSaveOptions::get_ExportHeadersFootersMode ( ) const

Specifies how headers and footers are output to HTML, MHTML or EPUB. Default value is PerSection for HTML/MHTML and None for EPUB.

It is hard to meaningfully output headers and footers to HTML because HTML is not paginated.

When this property is PerSection, Aspose.Words exports only primary headers and footers at the beginning and the end of each section.

When it is FirstSectionHeaderLastSectionFooter only first primary header and the last primary footer (including linked to previous) are exported.

You can disable export of headers and footers altogether by setting this property to None.

Examples

Shows how to omit headers/footers when saving a document to HTML.

auto doc = MakeObject<Document>(MyDir + u"Header and footer types.docx");
// This document contains headers and footers. We can access them via the "HeadersFooters" collection.
ASSERT_EQ(u"First header", doc->get_FirstSection()->get_HeadersFooters()->idx_get(HeaderFooterType::HeaderFirst)->GetText().Trim());
// Formats such as .html do not split the document into pages, so headers/footers will not function the same way
// they would when we open the document as a .docx using Microsoft Word.
// If we convert a document with headers/footers to html, the conversion will assimilate the headers/footers into body text.
// We can use a SaveOptions object to omit headers/footers while converting to html.
auto saveOptions = MakeObject<HtmlSaveOptions>(SaveFormat::Html);
saveOptions->set_ExportHeadersFootersMode(ExportHeadersFootersMode::None);
doc->Save(ArtifactsDir + u"HeaderFooter.ExportMode.html", saveOptions);
// Open our saved document and verify that it does not contain the header's text
doc = MakeObject<Document>(ArtifactsDir + u"HeaderFooter.ExportMode.html");
ASSERT_FALSE(doc->get_Range()->get_Text().Contains(u"First header"));
@ None
Headers and footers are not exported.
@ HeaderFirst
Header for the first page of the section.

◆ get_ExportImagesAsBase64()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ExportImagesAsBase64 ( )

Specifies whether images are saved in Base64 format to HTML, MHTML or EPUB. Default is false.

When this property is set to true image data is exported directly on the img elements and separate files are not created.

Examples

Shows how to save a .html document with images embedded inside it.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportImagesAsBase64(exportItemsAsBase64);
options->set_PrettyFormat(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportImagesAsBase64.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.ExportImagesAsBase64.html");
ASSERT_TRUE(exportItemsAsBase64 ? outDocContents.Contains(u"<img src=\"data:image/png;base64")
: outDocContents.Contains(u"<img src=\"HtmlSaveOptions.ExportImagesAsBase64.001.png\""));

Shows how to embed fonts inside a saved HTML document.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportFontsAsBase64(true);
options->set_CssStyleSheetType(CssStyleSheetType::Embedded);
options->set_PrettyFormat(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportFontsAsBase64.html", options);

◆ get_ExportLanguageInformation()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ExportLanguageInformation ( ) const

Specifies whether language information is exported to HTML, MHTML or EPUB. Default is false.

When this property is set to true Aspose.Words outputs lang HTML attribute on the document elements that specify language. This can be needed to preserve language related semantics.

Examples

Shows how to preserve language information when saving to .html.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Use the builder to write text while formatting it in different locales.
builder->get_Font()->set_LocaleId(MakeObject<System::Globalization::CultureInfo>(u"en-US")->get_LCID());
builder->Writeln(u"Hello world!");
builder->get_Font()->set_LocaleId(MakeObject<System::Globalization::CultureInfo>(u"en-GB")->get_LCID());
builder->Writeln(u"Hello again!");
builder->get_Font()->set_LocaleId(MakeObject<System::Globalization::CultureInfo>(u"ru-RU")->get_LCID());
builder->Write(u"Привет, мир!");
// When saving the document to HTML, we can pass a SaveOptions object
// to either preserve or discard each formatted text's locale.
// If we set the "ExportLanguageInformation" flag to "true",
// the output HTML document will contain the locales in "lang" attributes of <span> tags.
// If we set the "ExportLanguageInformation" flag to "false',
// the text in the output HTML document will not contain any locale information.
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportLanguageInformation(exportLanguageInformation);
options->set_PrettyFormat(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportLanguageInformation.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.ExportLanguageInformation.html");
if (exportLanguageInformation)
{
ASSERT_TRUE(outDocContents.Contains(u"<span>Hello world!</span>"));
ASSERT_TRUE(outDocContents.Contains(u"<span lang=\"en-GB\">Hello again!</span>"));
ASSERT_TRUE(outDocContents.Contains(u"<span lang=\"ru-RU\">Привет, мир!</span>"));
}
else
{
ASSERT_TRUE(outDocContents.Contains(u"<span>Hello world!</span>"));
ASSERT_TRUE(outDocContents.Contains(u"<span>Hello again!</span>"));
ASSERT_TRUE(outDocContents.Contains(u"<span>Привет, мир!</span>"));
}

◆ get_ExportListLabels()

Aspose::Words::Saving::ExportListLabels Aspose::Words::Saving::HtmlSaveOptions::get_ExportListLabels ( ) const

Controls how list labels are output to HTML, MHTML or EPUB. Default value is Auto.

Examples

Shows how to configure list exporting to HTML.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Aspose::Words::Lists::List> list = doc->get_Lists()->Add(ListTemplate::NumberDefault);
builder->get_ListFormat()->set_List(list);
builder->Writeln(u"Default numbered list item 1.");
builder->Writeln(u"Default numbered list item 2.");
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"Default numbered list item 3.");
builder->get_ListFormat()->RemoveNumbers();
list = doc->get_Lists()->Add(ListTemplate::OutlineHeadingsLegal);
builder->get_ListFormat()->set_List(list);
builder->Writeln(u"Outline legal heading list item 1.");
builder->Writeln(u"Outline legal heading list item 2.");
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"Outline legal heading list item 3.");
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"Outline legal heading list item 4.");
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"Outline legal heading list item 5.");
builder->get_ListFormat()->RemoveNumbers();
// When saving the document to HTML, we can pass a SaveOptions object
// to decide which HTML elements the document will use to represent lists.
// Setting the "ExportListLabels" property to "ExportListLabels.AsInlineText"
// will create lists by formatting spans.
// Setting the "ExportListLabels" property to "ExportListLabels.Auto" will use the <p> tag
// to build lists in cases when using the <ol> and <li> tags may cause loss of formatting.
// Setting the "ExportListLabels" property to "ExportListLabels.ByHtmlTags"
// will use <ol> and <li> tags to build all lists.
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportListLabels(exportListLabels);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.List.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.List.html");
switch (exportListLabels)
{
ASSERT_TRUE(outDocContents.Contains(
String(u"<p style=\"margin-top:0pt; margin-left:72pt; margin-bottom:0pt; text-indent:-18pt; -aw-import:list-item; -aw-list-level-number:1; "
u"-aw-list-number-format:'%1.'; -aw-list-number-styles:'lowerLetter'; -aw-list-number-values:'1'; -aw-list-padding-sml:9.67pt\">") +
u"<span style=\"-aw-import:ignore\">" + u"<span>a.</span>" +
u"<span style=\"width:9.67pt; font:7pt 'Times New Roman'; display:inline-block; -aw-import:spaces\">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; "
u"</span>" +
u"</span>" + u"<span>Default numbered list item 3.</span>" + u"</p>"));
ASSERT_TRUE(
outDocContents.Contains(String(u"<p style=\"margin-top:0pt; margin-left:43.2pt; margin-bottom:0pt; text-indent:-43.2pt; -aw-import:list-item; "
u"-aw-list-level-number:3; -aw-list-number-format:'%0.%1.%2.%3'; -aw-list-number-styles:'decimal decimal "
u"decimal decimal'; -aw-list-number-values:'2 1 1 1'; -aw-list-padding-sml:10.2pt\">") +
u"<span style=\"-aw-import:ignore\">" + u"<span>2.1.1.1</span>" +
u"<span style=\"width:10.2pt; font:7pt 'Times New Roman'; display:inline-block; "
u"-aw-import:spaces\">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span>" +
u"</span>" + u"<span>Outline legal heading list item 5.</span>" + u"</p>"));
break;
ASSERT_TRUE(outDocContents.Contains(String(u"<ol type=\"a\" style=\"margin-right:0pt; margin-left:0pt; padding-left:0pt\">") +
u"<li style=\"margin-left:31.33pt; padding-left:4.67pt\">" + u"<span>Default numbered list item 3.</span>" +
u"</li>" + u"</ol>"));
ASSERT_TRUE(outDocContents.Contains(
u"<p style=\"margin-top:0pt; margin-left:43.2pt; margin-bottom:0pt; text-indent:-43.2pt; -aw-import:list-item; -aw-list-level-number:3; ") +
u"-aw-list-number-format:'%0.%1.%2.%3'; -aw-list-number-styles:'decimal decimal decimal decimal'; " +
u"-aw-list-number-values:'2 1 1 1'; -aw-list-padding-sml:10.2pt\">" + u"<span style=\"-aw-import:ignore\">" + u"<span>2.1.1.1</span>" +
u"<span style=\"width:10.2pt; font:7pt 'Times New Roman'; display:inline-block; -aw-import:spaces\">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; "
u"</span>" +
u"</span>" + u"<span>Outline legal heading list item 5.</span>" + u"</p>"));
break;
ASSERT_TRUE(outDocContents.Contains(String(u"<ol type=\"a\" style=\"margin-right:0pt; margin-left:0pt; padding-left:0pt\">") +
u"<li style=\"margin-left:31.33pt; padding-left:4.67pt\">" + u"<span>Default numbered list item 3.</span>" +
u"</li>" + u"</ol>"));
ASSERT_TRUE(outDocContents.Contains(String(u"<ol type=\"1\" class=\"awlist3\" style=\"margin-right:0pt; margin-left:0pt; padding-left:0pt\">") +
u"<li style=\"margin-left:7.2pt; text-indent:-43.2pt; -aw-list-padding-sml:10.2pt\">" +
u"<span style=\"width:10.2pt; font:7pt 'Times New Roman'; display:inline-block; "
u"-aw-import:ignore\">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span>" +
u"<span>Outline legal heading list item 5.</span>" + u"</li>" + u"</ol>"));
break;
}
@ Auto
Outputs list labels in auto mode. Uses HTML native elements when possible.
@ ByHtmlTags
Outputs all list labels as HTML native elements.
@ AsInlineText
Outputs all list labels as inline text.

◆ get_ExportOriginalUrlForLinkedImages()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ExportOriginalUrlForLinkedImages ( ) const

Specifies whether original URL should be used as the URL of the linked images. Default value is false.

If value is set to trueSourceFullName value is used as the URL of linked images and linked images are not loaded into document's folder or ImagesFolder.

If value is set to false linked images are loaded into document's folder or ImagesFolder and URL of each linked image is constructed depending on document's folder, ImagesFolder and ImagesFolderAlias properties.

Examples

Shows how to set folders and folder aliases for externally saved resources that Aspose.Words will create when saving a document to HTML.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
options->set_CssStyleSheetType(CssStyleSheetType::External);
options->set_ExportFontResources(true);
options->set_ImageResolution(72);
options->set_FontResourcesSubsettingSizeThreshold(0);
options->set_FontsFolder(ArtifactsDir + u"Fonts");
options->set_ImagesFolder(ArtifactsDir + u"Images");
options->set_ResourceFolder(ArtifactsDir + u"Resources");
options->set_FontsFolderAlias(u"http://example.com/fonts");
options->set_ImagesFolderAlias(u"http://example.com/images");
options->set_ResourceFolderAlias(u"http://example.com/resources");
options->set_ExportOriginalUrlForLinkedImages(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.FolderAlias.html", options);

◆ get_ExportPageMargins()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ExportPageMargins ( ) const

Specifies whether page margins is exported to HTML, MHTML or EPUB. Default is false.

Examples

Shows how to show out-of-bounds objects in output HTML documents.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Use a builder to insert a shape with no wrapping.
SharedPtr<Shape> shape = builder->InsertShape(ShapeType::Cube, 200, 200);
shape->set_RelativeHorizontalPosition(RelativeHorizontalPosition::Page);
shape->set_RelativeVerticalPosition(RelativeVerticalPosition::Page);
shape->set_WrapType(WrapType::None);
// Negative shape position values may place the shape outside of page boundaries.
// If we export this to HTML, the shape will appear truncated.
shape->set_Left(-150);
// When saving the document to HTML, we can pass a SaveOptions object
// to decide whether to adjust the page to display out-of-bounds objects fully.
// If we set the "ExportPageMargins" flag to "true", the shape will be fully visible in the output HTML.
// If we set the "ExportPageMargins" flag to "false",
// our document will display the shape truncated as we would see it in Microsoft Word.
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportPageMargins(exportPageMargins);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportPageMargins.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.ExportPageMargins.html");
if (exportPageMargins)
{
ASSERT_TRUE(outDocContents.Contains(u"<style type=\"text/css\">div.Section1 { margin:70.85pt }</style>"));
ASSERT_TRUE(outDocContents.Contains(u"<div class=\"Section1\"><p style=\"margin-top:0pt; margin-left:151pt; margin-bottom:0pt\">"));
}
else
{
ASSERT_FALSE(outDocContents.Contains(u"style type=\"text/css\">"));
ASSERT_TRUE(outDocContents.Contains(u"<div><p style=\"margin-top:0pt; margin-left:221.85pt; margin-bottom:0pt\">"));
}

◆ get_ExportPageSetup()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ExportPageSetup ( ) const

Specifies whether page setup is exported to HTML, MHTML or EPUB. Default is false.

Each Section in Aspose.Words document model provides page setup information via PageSetup class. When you export a document to HTML format you might need to keep this information for further usage. In particular, page setup might be important for rendering to paged media (printing) or subsequent conversion to the native Microsoft Word file formats (DOCX, DOC, RTF, WML).

In most cases HTML is intended for viewing in browsers where pagination is not performed. So this feature is inactive by default.

Examples

Shows how decide whether to preserve section structure/page setup information when saving to HTML.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Write(u"Section 1");
builder->InsertBreak(BreakType::SectionBreakNewPage);
builder->Write(u"Section 2");
SharedPtr<PageSetup> pageSetup = doc->get_Sections()->idx_get(0)->get_PageSetup();
pageSetup->set_TopMargin(36.0);
pageSetup->set_BottomMargin(36.0);
pageSetup->set_PaperSize(PaperSize::A5);
// When saving the document to HTML, we can pass a SaveOptions object
// to decide whether to preserve or discard page setup settings.
// If we set the "ExportPageSetup" flag to "true", the output HTML document will contain our page setup configuration.
// If we set the "ExportPageSetup" flag to "false", the save operation will discard our page setup settings
// for the first section, and both sections will look identical.
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportPageSetup(exportPageSetup);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportPageSetup.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.ExportPageSetup.html");
if (exportPageSetup)
{
ASSERT_TRUE(outDocContents.Contains(String(u"<style type=\"text/css\">") + u"@page Section1 { size:419.55pt 595.3pt; margin:36pt 70.85pt }" +
u"@page Section2 { size:612pt 792pt; margin:70.85pt }" +
u"div.Section1 { page:Section1 }div.Section2 { page:Section2 }" + u"</style>"));
ASSERT_TRUE(outDocContents.Contains(String(u"<div class=\"Section1\">") + u"<p style=\"margin-top:0pt; margin-bottom:0pt\">" +
u"<span>Section 1</span>" + u"</p>" + u"</div>"));
}
else
{
ASSERT_FALSE(outDocContents.Contains(u"style type=\"text/css\">"));
ASSERT_TRUE(outDocContents.Contains(String(u"<div>") + u"<p style=\"margin-top:0pt; margin-bottom:0pt\">" + u"<span>Section 1</span>" + u"</p>" +
u"</div>"));
}
@ SectionBreakNewPage
Specifies start of new section on a new page.

◆ get_ExportRelativeFontSize()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ExportRelativeFontSize ( ) const

Specifies whether font sizes should be output in relative units when saving to HTML, MHTML or EPUB. Default is false.

In many existing documents (HTML, IDPF EPUB) font sizes are specified in relative units. This allows applications to adjust text size when viewing/processing documents. For instance, Microsoft Internet Explorer has "View->Text Size" submenu, Adobe Digital Editions has two buttons: Increase/Decrease Text Size. If you expect this functionality to work then set ExportRelativeFontSize property to true.

Aspose Words document model contains and operates only with absolute font size units. Relative units need additional logic to be recalculated from some initial (standard) size. Font size of Normal document style is taken as standard. For instance, if Normal has 12pt font and some text is 18pt then it will be output as 1.5em. to the HTML.

When this option is enabled, document elements other than text will still have absolute sizes. Also some text-related attributes might be expressed absolutely. In particular, line spacing specified with "exactly" rule might produce unwanted results when scaling text. So the source documents should be properly designed and tested when exporting with ExportRelativeFontSize set to true.

Examples

Shows how to use relative font sizes when saving to .html.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Default font size, ");
builder->get_Font()->set_Size(24);
builder->Writeln(u"2x default font size,");
builder->get_Font()->set_Size(96);
builder->Write(u"8x default font size");
// When we save the document to HTML, we can pass a SaveOptions object
// to determine whether to use relative or absolute font sizes.
// Set the "ExportRelativeFontSize" flag to "true" to declare font sizes
// using the "em" measurement unit, which is a factor that multiplies the current font size.
// Set the "ExportRelativeFontSize" flag to "false" to declare font sizes
// using the "pt" measurement unit, which is the font's absolute size in points.
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportRelativeFontSize(exportRelativeFontSize);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.RelativeFontSize.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.RelativeFontSize.html");
if (exportRelativeFontSize)
{
ASSERT_TRUE(outDocContents.Contains(String(u"<body style=\"font-family:'Times New Roman'\">") + u"<div>" +
u"<p style=\"margin-top:0pt; margin-bottom:0pt\">" + u"<span>Default font size, </span>" + u"</p>" +
u"<p style=\"margin-top:0pt; margin-bottom:0pt; font-size:2em\">" + u"<span>2x default font size,</span>" +
u"</p>" + u"<p style=\"margin-top:0pt; margin-bottom:0pt; font-size:8em\">" +
u"<span>8x default font size</span>" + u"</p>" + u"</div>" + u"</body>"));
}
else
{
ASSERT_TRUE(outDocContents.Contains(String(u"<body style=\"font-family:'Times New Roman'; font-size:12pt\">") + u"<div>" +
u"<p style=\"margin-top:0pt; margin-bottom:0pt\">" + u"<span>Default font size, </span>" + u"</p>" +
u"<p style=\"margin-top:0pt; margin-bottom:0pt; font-size:24pt\">" + u"<span>2x default font size,</span>" +
u"</p>" + u"<p style=\"margin-top:0pt; margin-bottom:0pt; font-size:96pt\">" +
u"<span>8x default font size</span>" + u"</p>" + u"</div>" + u"</body>"));
}

◆ get_ExportRoundtripInformation()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ExportRoundtripInformation ( ) const

Specifies whether to write the roundtrip information when saving to HTML, MHTML or EPUB. Default value is true for HTML and false for MHTML and EPUB.

Saving of the roundtrip information allows to restore document properties such as tab stops, comments, headers and footers during the HTML documents loading back into a Document object.

When true, the roundtrip information is exported as -aw-* CSS properties of the corresponding HTML elements.

When false, causes no roundtrip information to be output into produced files.

Examples

Shows how to preserve hidden elements when converting to .html.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// When converting a document to .html, some elements such as hidden bookmarks, original shape positions,
// or footnotes will be either removed or converted to plain text and effectively be lost.
// Saving with a HtmlSaveOptions object with ExportRoundtripInformation set to true will preserve these elements.
// When we save the document to HTML, we can pass a SaveOptions object to determine
// how the saving operation will export document elements that HTML does not support or use,
// such as hidden bookmarks and original shape positions.
// If we set the "ExportRoundtripInformation" flag to "true", the save operation will preserve these elements.
// If we set the "ExportRoundTripInformation" flag to "false", the save operation will discard these elements.
// We will want to preserve such elements if we intend to load the saved HTML using Aspose.Words,
// as they could be of use once again.
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportRoundtripInformation(exportRoundtripInformation);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.RoundTripInformation.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.RoundTripInformation.html");
doc = MakeObject<Document>(ArtifactsDir + u"HtmlSaveOptions.RoundTripInformation.html");
if (exportRoundtripInformation)
{
ASSERT_TRUE(outDocContents.Contains(u"<div style=\"-aw-headerfooter-type:header-primary; clear:both\">"));
ASSERT_TRUE(outDocContents.Contains(u"<span style=\"-aw-import:ignore\">&#xa0;</span>"));
ASSERT_TRUE(outDocContents.Contains(String(u"td colspan=\"2\" style=\"width:210.6pt; border-style:solid; border-width:0.75pt 6pt 0.75pt 0.75pt; ") +
u"padding-right:2.4pt; padding-left:5.03pt; vertical-align:top; " +
u"-aw-border-bottom:0.5pt single; -aw-border-left:0.5pt single; -aw-border-top:0.5pt single\">"));
ASSERT_TRUE(outDocContents.Contains(
u"<li style=\"margin-left:30.2pt; padding-left:5.8pt; -aw-font-family:'Courier New'; -aw-font-weight:normal; -aw-number-format:'o'\">"));
ASSERT_TRUE(
outDocContents.Contains(String(u"<img src=\"HtmlSaveOptions.RoundTripInformation.003.jpeg\" width=\"351\" height=\"180\" alt=\"\" ") +
u"style=\"-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline\" />"));
ASSERT_TRUE(outDocContents.Contains(String(u"<span>Page number </span>") + u"<span style=\"-aw-field-start:true\"></span>" +
u"<span style=\"-aw-field-code:' PAGE \\\\* MERGEFORMAT '\"></span>" +
u"<span style=\"-aw-field-separator:true\"></span>" + u"<span>1</span>" +
u"<span style=\"-aw-field-end:true\"></span>"));
ASSERT_EQ(1, doc->get_Range()->get_Fields()->LINQ_Count([](SharedPtr<Field> f) { return f->get_Type() == FieldType::FieldPage; }));
}
else
{
ASSERT_TRUE(outDocContents.Contains(u"<div style=\"clear:both\">"));
ASSERT_TRUE(outDocContents.Contains(u"<span>&#xa0;</span>"));
ASSERT_TRUE(
outDocContents.Contains(String(u"<td colspan=\"2\" style=\"width:210.6pt; border-style:solid; border-width:0.75pt 6pt 0.75pt 0.75pt; ") +
u"padding-right:2.4pt; padding-left:5.03pt; vertical-align:top\">"));
ASSERT_TRUE(outDocContents.Contains(u"<li style=\"margin-left:30.2pt; padding-left:5.8pt\">"));
ASSERT_TRUE(outDocContents.Contains(u"<img src=\"HtmlSaveOptions.RoundTripInformation.003.jpeg\" width=\"351\" height=\"180\" alt=\"\" />"));
ASSERT_TRUE(outDocContents.Contains(u"<span>Page number 1</span>"));
ASSERT_EQ(0, doc->get_Range()->get_Fields()->LINQ_Count([](SharedPtr<Field> f) { return f->get_Type() == FieldType::FieldPage; }));
}

◆ get_ExportTextBoxAsSvg()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ExportTextBoxAsSvg ( )

Controls how textboxes represented by Shape are saved to HTML, MHTML or EPUB. Default value is false.

When set to true, exports textboxes as inline <svg> elements. When false, exports as <img> elements.

Examples

Shows how to export text boxes as scalable vector graphics.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Shape> textBox = builder->InsertShape(ShapeType::TextBox, 100.0, 60.0);
builder->MoveTo(textBox->get_FirstParagraph());
builder->Write(u"My text box");
// When we save the document to HTML, we can pass a SaveOptions object
// to determine how the saving operation will export text box shapes.
// If we set the "ExportTextBoxAsSvg" flag to "true",
// the save operation will convert shapes with text into SVG objects.
// If we set the "ExportTextBoxAsSvg" flag to "false",
// the save operation will convert shapes with text into images.
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportTextBoxAsSvg(exportTextBoxAsSvg);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportTextBox.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.ExportTextBox.html");
if (exportTextBoxAsSvg)
{
ASSERT_TRUE(outDocContents.Contains(
String(u"<span style=\"-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline\">") +
u"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" width=\"133\" height=\"80\">"));
}
else
{
ASSERT_TRUE(outDocContents.Contains(
String(u"<p style=\"margin-top:0pt; margin-bottom:0pt\">") +
u"<img src=\"HtmlSaveOptions.ExportTextBox.001.png\" width=\"136\" height=\"83\" alt=\"\" " +
u"style=\"-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline\" />" + u"</p>"));
}

◆ get_ExportTextInputFormFieldAsText()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ExportTextInputFormFieldAsText ( ) const

Controls how text input form fields are saved to HTML or MHTML. Default value is false.

When set to true, exports text input form fields as normal text. When false, exports Word text input form fields as INPUT elements in HTML.

When exporting to EPUB, text input form fields are always saved as text due to requirements of this format.

Examples

Shows how to specify the folder for storing linked images after saving to .html.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
String imagesDir = System::IO::Path::Combine(ArtifactsDir, u"SaveHtmlWithOptions");
{
}
// Set an option to export form fields as plain text instead of HTML input elements.
auto options = MakeObject<HtmlSaveOptions>(SaveFormat::Html);
options->set_ExportTextInputFormFieldAsText(true);
options->set_ImagesFolder(imagesDir);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.SaveHtmlWithOptions.html", options);

◆ get_ExportTocPageNumbers()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ExportTocPageNumbers ( ) const

Specifies whether to write page numbers to table of contents when saving HTML, MHTML and EPUB. Default value is false.

Examples

Shows how to display page numbers when saving a document with a table of contents to .html.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a table of contents, and then populate the document with paragraphs formatted using a "Heading"
// style that the table of contents will pick up as entries. Each entry will display the heading paragraph on the left,
// and the page number that contains the heading on the right.
auto fieldToc = System::DynamicCast<FieldToc>(builder->InsertField(FieldType::FieldTOC, true));
builder->get_ParagraphFormat()->set_Style(builder->get_Document()->get_Styles()->idx_get(u"Heading 1"));
builder->InsertBreak(BreakType::PageBreak);
builder->Writeln(u"Entry 1");
builder->Writeln(u"Entry 2");
builder->InsertBreak(BreakType::PageBreak);
builder->Writeln(u"Entry 3");
builder->InsertBreak(BreakType::PageBreak);
builder->Writeln(u"Entry 4");
fieldToc->UpdatePageNumbers();
doc->UpdateFields();
// HTML documents do not have pages. If we save this document to HTML,
// the page numbers that our TOC displays will have no meaning.
// When we save the document to HTML, we can pass a SaveOptions object to omit these page numbers from the TOC.
// If we set the "ExportTocPageNumbers" flag to "true",
// each TOC entry will display the heading, separator, and page number, preserving its appearance in Microsoft Word.
// If we set the "ExportTocPageNumbers" flag to "false",
// the save operation will omit both the separator and page number and leave the heading for each entry intact.
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportTocPageNumbers(exportTocPageNumbers);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportTocPageNumbers.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.ExportTocPageNumbers.html");
if (exportTocPageNumbers)
{
ASSERT_TRUE(outDocContents.Contains(
String(u"<p style=\"margin-top:0pt; margin-bottom:0pt\">") + u"<span>Entry 1</span>" +
u"<span style=\"width:428.14pt; font-family:'Lucida Console'; font-size:10pt; display:inline-block; -aw-font-family:'Times New Roman'; " +
u"-aw-tabstop-align:right; -aw-tabstop-leader:dots; "
u"-aw-tabstop-pos:469.8pt\">.......................................................................</span>" +
u"<span>2</span>" + u"</p>"));
}
else
{
ASSERT_TRUE(outDocContents.Contains(String(u"<p style=\"margin-top:0pt; margin-bottom:0pt\">") + u"<span>Entry 1</span>" + u"</p>"));
}
@ PageBreak
Explicit page break.

◆ get_ExportXhtmlTransitional()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ExportXhtmlTransitional ( ) const

Specifies whether to write the DOCTYPE declaration when saving to HTML or MHTML. When true, writes a DOCTYPE declaration in the document prior to the root element. Default value is false. When saving to EPUB or HTML5 (Html5) the DOCTYPE declaration is always written.

Aspose.Words always writes well formed HTML regardless of this setting.

When true, the beginning of the HTML output document will look like this:

<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

Aspose.Words aims to output XHTML according to the XHTML 1.0 Transitional specification, but the output will not always validate against the DTD. Some structures inside a Microsoft Word document are hard or impossible to map to a document that will validate against the XHTML schema. For example, XHTML does not allow nested lists (UL cannot be nested inside another UL element), but in Microsoft Word document multilevel lists occur quite often.

Examples

Shows how to display a DOCTYPE heading when converting documents to the Xhtml 1.0 transitional standard.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
auto options = MakeObject<HtmlSaveOptions>(SaveFormat::Html);
options->set_HtmlVersion(HtmlVersion::Xhtml);
options->set_ExportXhtmlTransitional(showDoctypeDeclaration);
options->set_PrettyFormat(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportXhtmlTransitional.html", options);
// Our document will only contain a DOCTYPE declaration heading if we have set the "ExportXhtmlTransitional" flag to "true".
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.ExportXhtmlTransitional.html");
if (showDoctypeDeclaration)
{
ASSERT_TRUE(outDocContents.Contains(String(u"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n") +
u"<!DOCTYPE html\r\nPUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\r\n "
u"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n" +
u"<html xmlns=\"http://www.w3.org/1999/xhtml\">"));
}
else
{
ASSERT_TRUE(outDocContents.Contains(u"<html>"));
}

◆ get_FontResourcesSubsettingSizeThreshold()

int32_t Aspose::Words::Saving::HtmlSaveOptions::get_FontResourcesSubsettingSizeThreshold ( ) const

Controls which font resources need subsetting when saving to HTML, MHTML or EPUB. Default is 0.

ExportFontResources allows exporting fonts as subsidiary files or as parts of the output package. If the document uses many fonts, especially with large number of glyphs, then output size can grow significantly. Font subsetting reduces the size of the exported font resource by filtering out glyphs that are not used by the current document.

Font subsetting works as follows:

Important! When exporting font resources, font licensing issues should be considered. Authors who want to use specific fonts via a downloadable font mechanism must always carefully verify that their intended use is within the scope of the font license. Many commercial fonts presently do not allow web downloading of their fonts in any form. License agreements that cover some fonts specifically note that usage via @font-face rules in CSS style sheets is not allowed. Font subsetting can also violate license terms.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_ExportFontResources
Examples

Shows how to work with font subsetting.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_Font()->set_Name(u"Arial");
builder->Writeln(u"Hello world!");
builder->get_Font()->set_Name(u"Times New Roman");
builder->Writeln(u"Hello world!");
builder->get_Font()->set_Name(u"Courier New");
builder->Writeln(u"Hello world!");
// When we save the document to HTML, we can pass a SaveOptions object configure font subsetting.
// Suppose we set the "ExportFontResources" flag to "true" and also name a folder in the "FontsFolder" property.
// In that case, the saving operation will create that folder and place a .ttf file inside
// that folder for each font that our document uses.
// Each .ttf file will contain that font's entire glyph set,
// which may potentially result in a very large file that accompanies the document.
// When we apply subsetting to a font, its exported raw data will only contain the glyphs that the document is
// using instead of the entire glyph set. If the text in our document only uses a small fraction of a font's
// glyph set, then subsetting will significantly reduce our output documents' size.
// We can use the "FontResourcesSubsettingSizeThreshold" property to define a .ttf file size, in bytes.
// If an exported font creates a size bigger file than that, then the save operation will apply subsetting to that font.
// Setting a threshold of 0 applies subsetting to all fonts,
// and setting it to "int.MaxValue" effectively disables subsetting.
String fontsFolder = ArtifactsDir + u"HtmlSaveOptions.FontSubsetting.Fonts";
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportFontResources(true);
options->set_FontsFolder(fontsFolder);
options->set_FontResourcesSubsettingSizeThreshold(fontResourcesSubsettingSizeThreshold);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.FontSubsetting.html", options);
ArrayPtr<String> fontFileNames = System::IO::Directory::GetFiles(fontsFolder)->LINQ_Where([](String s) { return s.EndsWith(u".ttf"); })->LINQ_ToArray();
ASSERT_EQ(3, fontFileNames->get_Length());
for (String filename : fontFileNames)
{
// By default, the .ttf files for each of our three fonts will be over 700MB.
// Subsetting will reduce them all to under 30MB.
auto fontFileInfo = MakeObject<System::IO::FileInfo>(filename);
ASSERT_TRUE(fontFileInfo->get_Length() > 700000 || fontFileInfo->get_Length() < 30000);
ASSERT_TRUE(System::Math::Max(fontResourcesSubsettingSizeThreshold, 30000) > MakeObject<System::IO::FileInfo>(filename)->get_Length());
}
static auto Max(T0 val1, T1 val2) -> decltype(val1+val2)

◆ get_FontSavingCallback()

System::SharedPtr<Aspose::Words::Saving::IFontSavingCallback> Aspose::Words::Saving::HtmlSaveOptions::get_FontSavingCallback ( ) const

Allows to control how fonts are saved when a document is saved to HTML, MHTML or EPUB.

Examples

Shows how to define custom logic for exporting fonts when saving to HTML.

void SaveExportedFonts()
{
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Configure a SaveOptions object to export fonts to separate files.
// Set a callback that will handle font saving in a custom manner.
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportFontResources(true);
options->set_FontSavingCallback(MakeObject<ExHtmlSaveOptions::HandleFontSaving>());
// The callback will export .ttf files and save them alongside the output document.
doc->Save(ArtifactsDir + u"HtmlSaveOptions.SaveExportedFonts.html", options);
std::function<bool(String s)> endsWithTtf = [](String s)
{
return s.EndsWith(u".ttf");
};
for (String fontFilename : System::Array<String>::FindAll(System::IO::Directory::GetFiles(ArtifactsDir), endsWithTtf))
{
std::cout << fontFilename << std::endl;
}
}
class HandleFontSaving : public IFontSavingCallback
{
public:
void FontSaving(SharedPtr<FontSavingArgs> args) override
{
std::cout << "Font:\t" << args->get_FontFamilyName();
if (args->get_Bold())
{
std::cout << ", bold";
}
if (args->get_Italic())
{
std::cout << ", italic";
}
std::cout << "\nSource:\t" << args->get_OriginalFileName() << ", " << args->get_OriginalFileSize() << " bytes\n" << std::endl;
// We can also access the source document from here.
ASSERT_TRUE(args->get_Document()->get_OriginalFileName().EndsWith(u"Rendering.docx"));
ASSERT_TRUE(args->get_IsExportNeeded());
ASSERT_TRUE(args->get_IsSubsettingNeeded());
// There are two ways of saving an exported font.
// 1 - Save it to a local file system location:
args->set_FontFileName(args->get_OriginalFileName().Split(MakeArray<char16_t>({System::IO::Path::DirectorySeparatorChar}))->LINQ_Last());
// 2 - Save it to a stream:
args->set_FontStream(MakeObject<System::IO::FileStream>(
ArtifactsDir + args->get_OriginalFileName().Split(MakeArray<char16_t>({System::IO::Path::DirectorySeparatorChar}))->LINQ_Last(),
ASSERT_FALSE(args->get_KeepFontStreamOpen());
}
};

◆ get_FontsFolder()

System::String Aspose::Words::Saving::HtmlSaveOptions::get_FontsFolder ( ) const

Specifies the physical folder where fonts are saved when exporting a document to HTML. Default is an empty string.

When you save a Document in HTML format and ExportFontResources is set to true, Aspose.Words needs to save fonts used in the document as standalone files. FontsFolder allows you to specify where the fonts will be saved and FontsFolderAlias allows to specify how the font URIs will be constructed.

If you save a document into a file and provide a file name, Aspose.Words, by default, saves the fonts in the same folder where the document file is saved. Use FontsFolder to override this behavior.

If you save a document into a stream, Aspose.Words does not have a folder where to save the fonts, but still needs to save the fonts somewhere. In this case, you need to specify an accessible folder in the FontsFolder property or provide custom streams via the FontSavingCallback event handler.

If the folder specified by FontsFolder doesn't exist, it will be created automatically.

ResourceFolder is another way to specify a folder where fonts should be saved.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_ResourceFolder
Aspose::Words::Saving::HtmlSaveOptions::get_ExportFontResources
Aspose::Words::Saving::HtmlSaveOptions::get_FontsFolderAlias
Aspose::Words::Saving::HtmlSaveOptions::get_FontSavingCallback
Examples

Shows how to set folders and folder aliases for externally saved resources that Aspose.Words will create when saving a document to HTML.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
options->set_CssStyleSheetType(CssStyleSheetType::External);
options->set_ExportFontResources(true);
options->set_ImageResolution(72);
options->set_FontResourcesSubsettingSizeThreshold(0);
options->set_FontsFolder(ArtifactsDir + u"Fonts");
options->set_ImagesFolder(ArtifactsDir + u"Images");
options->set_ResourceFolder(ArtifactsDir + u"Resources");
options->set_FontsFolderAlias(u"http://example.com/fonts");
options->set_ImagesFolderAlias(u"http://example.com/images");
options->set_ResourceFolderAlias(u"http://example.com/resources");
options->set_ExportOriginalUrlForLinkedImages(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.FolderAlias.html", options);

◆ get_FontsFolderAlias()

System::String Aspose::Words::Saving::HtmlSaveOptions::get_FontsFolderAlias ( ) const

Specifies the name of the folder used to construct font URIs written into an HTML document. Default is an empty string.

When you save a Document in HTML format and ExportFontResources is set to true, Aspose.Words needs to save fonts used in the document as standalone files. FontsFolder allows you to specify where the fonts will be saved and FontsFolderAlias allows to specify how the font URIs will be constructed.

If FontsFolderAlias is not an empty string, then the font URI written to HTML will be FontsFolderAlias + <font file name>.

If FontsFolderAlias is an empty string, then the font URI written to HTML will be FontsFolder + <font file name>.

If FontsFolderAlias is set to '.' (dot), then the font file name will be written to HTML without path regardless of other options.

Alternative way to specify the name of the folder to construct font URIs is to use ResourceFolderAlias.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_ResourceFolderAlias
Aspose::Words::Saving::HtmlSaveOptions::get_ExportFontResources
Aspose::Words::Saving::HtmlSaveOptions::get_FontsFolder
Aspose::Words::Saving::HtmlSaveOptions::get_FontSavingCallback
Examples

Shows how to set folders and folder aliases for externally saved resources that Aspose.Words will create when saving a document to HTML.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
options->set_CssStyleSheetType(CssStyleSheetType::External);
options->set_ExportFontResources(true);
options->set_ImageResolution(72);
options->set_FontResourcesSubsettingSizeThreshold(0);
options->set_FontsFolder(ArtifactsDir + u"Fonts");
options->set_ImagesFolder(ArtifactsDir + u"Images");
options->set_ResourceFolder(ArtifactsDir + u"Resources");
options->set_FontsFolderAlias(u"http://example.com/fonts");
options->set_ImagesFolderAlias(u"http://example.com/images");
options->set_ResourceFolderAlias(u"http://example.com/resources");
options->set_ExportOriginalUrlForLinkedImages(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.FolderAlias.html", options);

◆ get_HtmlVersion()

Aspose::Words::Saving::HtmlVersion Aspose::Words::Saving::HtmlSaveOptions::get_HtmlVersion ( ) const

Specifies version of HTML standard that should be used when saving the document to HTML or MHTML. Default value is Xhtml.

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)
{
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=\"border-collapse:collapse\">"));
break;
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=\"border-collapse:collapse\">"));
break;
}

Shows how to display a DOCTYPE heading when converting documents to the Xhtml 1.0 transitional standard.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
auto options = MakeObject<HtmlSaveOptions>(SaveFormat::Html);
options->set_HtmlVersion(HtmlVersion::Xhtml);
options->set_ExportXhtmlTransitional(showDoctypeDeclaration);
options->set_PrettyFormat(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportXhtmlTransitional.html", options);
// Our document will only contain a DOCTYPE declaration heading if we have set the "ExportXhtmlTransitional" flag to "true".
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.ExportXhtmlTransitional.html");
if (showDoctypeDeclaration)
{
ASSERT_TRUE(outDocContents.Contains(String(u"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n") +
u"<!DOCTYPE html\r\nPUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\r\n "
u"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n" +
u"<html xmlns=\"http://www.w3.org/1999/xhtml\">"));
}
else
{
ASSERT_TRUE(outDocContents.Contains(u"<html>"));
}

◆ get_ImageResolution()

int32_t Aspose::Words::Saving::HtmlSaveOptions::get_ImageResolution ( )

Specifies the output resolution for images when exporting to HTML, MHTML or EPUB. Default is 96 dpi.

This property effects raster images when ScaleImageToShapeSize is true and effects metafiles exported as raster images. Some image properties such as cropping or rotation require saving transformed images and in this case transformed images are created in the given resolution.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_ScaleImageToShapeSize
Examples

Shows how to set folders and folder aliases for externally saved resources that Aspose.Words will create when saving a document to HTML.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
options->set_CssStyleSheetType(CssStyleSheetType::External);
options->set_ExportFontResources(true);
options->set_ImageResolution(72);
options->set_FontResourcesSubsettingSizeThreshold(0);
options->set_FontsFolder(ArtifactsDir + u"Fonts");
options->set_ImagesFolder(ArtifactsDir + u"Images");
options->set_ResourceFolder(ArtifactsDir + u"Resources");
options->set_FontsFolderAlias(u"http://example.com/fonts");
options->set_ImagesFolderAlias(u"http://example.com/images");
options->set_ResourceFolderAlias(u"http://example.com/resources");
options->set_ExportOriginalUrlForLinkedImages(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.FolderAlias.html", options);

◆ get_ImageSavingCallback()

System::SharedPtr<Aspose::Words::Saving::IImageSavingCallback> Aspose::Words::Saving::HtmlSaveOptions::get_ImageSavingCallback ( )

Allows to control how images are saved when a document is saved to HTML, MHTML or EPUB.

Examples

Shows how to split a document into parts and save them.

void DocumentPartsFileNames()
{
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
String outFileName = u"SavingCallback.DocumentPartsFileNames.html";
// Create an "HtmlFixedSaveOptions" object, which we can pass to the document's "Save" method
// to modify how we convert the document to HTML.
auto options = MakeObject<HtmlSaveOptions>();
// If we save the document normally, there will be one output HTML
// document with all the source document's contents.
// Set the "DocumentSplitCriteria" property to "DocumentSplitCriteria.SectionBreak" to
// save our document to multiple HTML files: one for each section.
options->set_DocumentSplitCriteria(DocumentSplitCriteria::SectionBreak);
// Assign a custom callback to the "DocumentPartSavingCallback" property to alter the document part saving logic.
options->set_DocumentPartSavingCallback(MakeObject<ExSavingCallback::SavedDocumentPartRename>(outFileName, options->get_DocumentSplitCriteria()));
// If we convert a document that contains images into html, we will end up with one html file which links to several images.
// Each image will be in the form of a file in the local file system.
// There is also a callback that can customize the name and file system location of each image.
options->set_ImageSavingCallback(MakeObject<ExSavingCallback::SavedImageRename>(outFileName));
doc->Save(ArtifactsDir + outFileName, options);
}
class SavedDocumentPartRename : public IDocumentPartSavingCallback
{
public:
SavedDocumentPartRename(String outFileName, DocumentSplitCriteria documentSplitCriteria)
: mCount(0), mDocumentSplitCriteria(((Aspose::Words::Saving::DocumentSplitCriteria)0))
{
mOutFileName = outFileName;
mDocumentSplitCriteria = documentSplitCriteria;
}
void DocumentPartSaving(SharedPtr<DocumentPartSavingArgs> args) override
{
// We can access the entire source document via the "Document" property.
ASSERT_TRUE(args->get_Document()->get_OriginalFileName().EndsWith(u"Rendering.docx"));
String partType = String::Empty;
switch (mDocumentSplitCriteria)
{
partType = u"Page";
break;
partType = u"Column";
break;
partType = u"Section";
break;
partType = u"Paragraph from heading";
break;
default:
break;
}
String partFileName = String::Format(u"{0} part {1}, of type {2}{3}", mOutFileName, ++mCount, partType,
System::IO::Path::GetExtension(args->get_DocumentPartFileName()));
// Below are two ways of specifying where Aspose.Words will save each part of the document.
// 1 - Set a filename for the output part file:
args->set_DocumentPartFileName(partFileName);
// 2 - Create a custom stream for the output part file:
args->set_DocumentPartStream(MakeObject<System::IO::FileStream>(ArtifactsDir + partFileName, System::IO::FileMode::Create));
ASSERT_TRUE(args->get_DocumentPartStream()->get_CanWrite());
ASSERT_FALSE(args->get_KeepDocumentPartStreamOpen());
}
private:
int mCount;
String mOutFileName;
DocumentSplitCriteria mDocumentSplitCriteria;
};
class SavedImageRename : public IImageSavingCallback
{
public:
SavedImageRename(String outFileName) : mCount(0)
{
mOutFileName = outFileName;
}
void ImageSaving(SharedPtr<ImageSavingArgs> args) override
{
String imageFileName = String::Format(u"{0} shape {1}, of type {2}{3}", mOutFileName, ++mCount, args->get_CurrentShape()->get_ShapeType(),
System::IO::Path::GetExtension(args->get_ImageFileName()));
// Below are two ways of specifying where Aspose.Words will save each part of the document.
// 1 - Set a filename for the output image file:
args->set_ImageFileName(imageFileName);
// 2 - Create a custom stream for the output image file:
args->set_ImageStream(MakeObject<System::IO::FileStream>(ArtifactsDir + imageFileName, System::IO::FileMode::Create));
ASSERT_TRUE(args->get_ImageStream()->get_CanWrite());
ASSERT_TRUE(args->get_IsImageAvailable());
ASSERT_FALSE(args->get_KeepImageStreamOpen());
}
private:
int mCount;
String mOutFileName;
};

◆ get_ImagesFolder()

System::String Aspose::Words::Saving::HtmlSaveOptions::get_ImagesFolder ( ) const

Specifies the physical folder where images are saved when exporting a document to HTML format. Default is an empty string.

When you save a Document in HTML format, Aspose.Words needs to save all images embedded in the document as standalone files. ImagesFolder allows you to specify where the images will be saved and ImagesFolderAlias allows to specify how the image URIs will be constructed.

If you save a document into a file and provide a file name, Aspose.Words, by default, saves the images in the same folder where the document file is saved. Use ImagesFolder to override this behavior.

If you save a document into a stream, Aspose.Words does not have a folder where to save the images, but still needs to save the images somewhere. In this case, you need to specify an accessible folder in the ImagesFolder property or provide custom streams via the ImageSavingCallback event handler.

If the folder specified by ImagesFolder doesn't exist, it will be created automatically.

ResourceFolder is another way to specify a folder where images should be saved.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_ResourceFolder
Aspose::Words::Saving::HtmlSaveOptions::get_ImagesFolderAlias
Aspose::Words::Saving::HtmlSaveOptions::get_ImageSavingCallback
Examples

Shows how to specify the folder for storing linked images after saving to .html.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
String imagesDir = System::IO::Path::Combine(ArtifactsDir, u"SaveHtmlWithOptions");
{
}
// Set an option to export form fields as plain text instead of HTML input elements.
auto options = MakeObject<HtmlSaveOptions>(SaveFormat::Html);
options->set_ExportTextInputFormFieldAsText(true);
options->set_ImagesFolder(imagesDir);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.SaveHtmlWithOptions.html", options);

◆ get_ImagesFolderAlias()

System::String Aspose::Words::Saving::HtmlSaveOptions::get_ImagesFolderAlias ( ) const

Specifies the name of the folder used to construct image URIs written into an HTML document. Default is an empty string.

When you save a Document in HTML format, Aspose.Words needs to save all images embedded in the document as standalone files. ImagesFolder allows you to specify where the images will be saved and ImagesFolderAlias allows to specify how the image URIs will be constructed.

If ImagesFolderAlias is not an empty string, then the image URI written to HTML will be ImagesFolderAlias + <image file name>.

If ImagesFolderAlias is an empty string, then the image URI written to HTML will be ImagesFolder + <image file name>.

If ImagesFolderAlias is set to '.' (dot), then the image file name will be written to HTML without path regardless of other options.

Alternative way to specify the name of the folder to construct image URIs is to use ResourceFolderAlias.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_ResourceFolderAlias
Aspose::Words::Saving::HtmlSaveOptions::get_ImagesFolder
Aspose::Words::Saving::HtmlSaveOptions::get_ImageSavingCallback
Examples

Shows how to set folders and folder aliases for externally saved resources that Aspose.Words will create when saving a document to HTML.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
options->set_CssStyleSheetType(CssStyleSheetType::External);
options->set_ExportFontResources(true);
options->set_ImageResolution(72);
options->set_FontResourcesSubsettingSizeThreshold(0);
options->set_FontsFolder(ArtifactsDir + u"Fonts");
options->set_ImagesFolder(ArtifactsDir + u"Images");
options->set_ResourceFolder(ArtifactsDir + u"Resources");
options->set_FontsFolderAlias(u"http://example.com/fonts");
options->set_ImagesFolderAlias(u"http://example.com/images");
options->set_ResourceFolderAlias(u"http://example.com/resources");
options->set_ExportOriginalUrlForLinkedImages(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.FolderAlias.html", options);

◆ get_MetafileFormat()

Aspose::Words::Saving::HtmlMetafileFormat Aspose::Words::Saving::HtmlSaveOptions::get_MetafileFormat ( )

Specifies in what format metafiles are saved when exporting to HTML, MHTML, or EPUB. Default value is Png, meaning that metafiles are rendered to raster PNG images.

Metafiles are not natively displayed by HTML browsers. By default, Aspose.Words converts WMF and EMF images into PNG files when exporting to HTML. Other options are to convert metafiles to SVG images or to export them as is without conversion.

Some image transforms, in particular image cropping, will not be applied to metafile images if they are exported to HTML without conversion.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_ImageResolution
Aspose::Words::Saving::HtmlSaveOptions::get_ScaleImageToShapeSize
Examples

Shows how to convert SVG objects to a different format when saving HTML documents.

String html =
u"<html>\r\n <svg xmlns='http://www.w3.org/2000/svg' width='500' height='40' viewBox='0 0 500 40'>\r\n "
u"<text x='0' y='35' font-family='Verdana' font-size='35'>Hello world!</text>\r\n </svg>\r\n </html>";
auto doc = MakeObject<Document>(MakeObject<System::IO::MemoryStream>(System::Text::Encoding::get_UTF8()->GetBytes(html)));
// This document contains a <svg> element in the form of text.
// When we save the document to HTML, we can pass a SaveOptions object
// to determine how the saving operation handles this object.
// Setting the "MetafileFormat" property to "HtmlMetafileFormat.Png" to convert it to a PNG image.
// Setting the "MetafileFormat" property to "HtmlMetafileFormat.Svg" preserve it as a SVG object.
// Setting the "MetafileFormat" property to "HtmlMetafileFormat.EmfOrWmf" to convert it to a metafile.
auto options = MakeObject<HtmlSaveOptions>();
options->set_MetafileFormat(htmlMetafileFormat);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.MetafileFormat.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.MetafileFormat.html");
switch (htmlMetafileFormat)
{
ASSERT_TRUE(outDocContents.Contains(
String(u"<p style=\"margin-top:0pt; margin-bottom:0pt\">") +
u"<img src=\"HtmlSaveOptions.MetafileFormat.001.png\" width=\"500\" height=\"40\" alt=\"\" " +
u"style=\"-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline\" />" + u"</p>"));
break;
ASSERT_TRUE(outDocContents.Contains(
String(u"<span style=\"-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline\">") +
u"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" width=\"499\" height=\"40\">"));
break;
ASSERT_TRUE(outDocContents.Contains(
String(u"<p style=\"margin-top:0pt; margin-bottom:0pt\">") +
u"<img src=\"HtmlSaveOptions.MetafileFormat.001.emf\" width=\"500\" height=\"40\" alt=\"\" " +
u"style=\"-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline\" />" + u"</p>"));
break;
}
@ Svg
Metafiles are converted to vector SVG images.
@ EmfOrWmf
Metafiles are saved as is, without conversion.
@ Png
Metafiles are rendered to raster PNG images.

◆ get_OfficeMathOutputMode()

Aspose::Words::Saving::HtmlOfficeMathOutputMode Aspose::Words::Saving::HtmlSaveOptions::get_OfficeMathOutputMode ( ) const

Controls how OfficeMath objects are exported to HTML, MHTML or EPUB. Default value is HtmlOfficeMathOutputMode.Image.

Examples

Shows how to specify how to export Microsoft OfficeMath objects to HTML.

auto doc = MakeObject<Document>(MyDir + u"Office math.docx");
// When we save the document to HTML, we can pass a SaveOptions object
// to determine how the saving operation handles OfficeMath objects.
// Setting the "OfficeMathOutputMode" property to "HtmlOfficeMathOutputMode.Image"
// will render each OfficeMath object into an image.
// Setting the "OfficeMathOutputMode" property to "HtmlOfficeMathOutputMode.MathML"
// will convert each OfficeMath object into MathML.
// Setting the "OfficeMathOutputMode" property to "HtmlOfficeMathOutputMode.Text"
// will represent each OfficeMath formula using plain HTML text.
auto options = MakeObject<HtmlSaveOptions>();
options->set_OfficeMathOutputMode(htmlOfficeMathOutputMode);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.OfficeMathOutputMode.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.OfficeMathOutputMode.html");
switch (htmlOfficeMathOutputMode)
{
ASSERT_TRUE(
outDocContents,
String(u"<p style=\"margin-top:0pt; margin-bottom:10pt\">") +
u"<img src=\"HtmlSaveOptions.OfficeMathOutputMode.001.png\" width=\"159\" height=\"19\" alt=\"\" style=\"vertical-align:middle; " +
u"-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline\" />" + u"</p>")
->get_Success());
break;
ASSERT_TRUE(System::Text::RegularExpressions::Regex::Match(outDocContents, String(u"<p style=\"margin-top:0pt; margin-bottom:10pt\">") +
u"<math xmlns=\"http://www.w3.org/1998/Math/MathML\">" +
u"<mi>i</mi>" + u"<mo>[+]</mo>" + u"<mi>b</mi>" + u"<mo>-</mo>" +
u"<mi>c</mi>" + u"<mo>≥</mo>" + u".*" + u"</math>" + u"</p>")
->get_Success());
break;
outDocContents, String(u"<p style=\\\"margin-top:0pt; margin-bottom:10pt\\\">") +
u"<span style=\\\"font-family:'Cambria Math'\\\">i[+]b-c≥iM[+]bM-cM </span>" + u"</p>")
->get_Success());
break;
}
@ MathML
OfficeMath is converted to HTML using MathML.
@ Text
OfficeMath is converted to HTML as sequence of runs specified by <span> tags.
@ Image
OfficeMath is converted to HTML as image specified by <img> tag.

◆ get_ResolveFontNames()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ResolveFontNames ( ) const

Specifies whether font family names used in the document are resolved and substituted according to FontSettings when being written into HTML-based formats.

By default, this option is set to false and font family names are written to HTML as specified in source documents. That is, FontSettings are ignored and no resolution or substitution of font family names is performed.

If this option is set to true, Aspose.Words uses FontSettings to resolve each font family name specified in a source document into the name of an available font family, performing font subsitution as required.

◆ get_ResourceFolder()

System::String Aspose::Words::Saving::HtmlSaveOptions::get_ResourceFolder ( ) const

Specifies a physical folder where all resources like images, fonts, and external CSS are saved when a document is exported to HTML. Default is an empty string.

ResourceFolder is the simplest way to specify a folder where all resources should be written. Another way is to use individual properties FontsFolder, ImagesFolder, and CssStyleSheetFileName.

ResourceFolder has a lower priority than folders specified via FontsFolder, ImagesFolder, and CssStyleSheetFileName. For example, if both ResourceFolder and FontsFolder are specified, fonts will be saved to FontsFolder, while images and CSS will be saved to ResourceFolder.

If the folder specified by ResourceFolder doesn't exist, it will be created automatically.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_FontsFolder
Aspose::Words::Saving::HtmlSaveOptions::get_ImagesFolder
Aspose::Words::Saving::HtmlSaveOptions::get_CssStyleSheetFileName
Examples

Shows how to set folders and folder aliases for externally saved resources that Aspose.Words will create when saving a document to HTML.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
options->set_CssStyleSheetType(CssStyleSheetType::External);
options->set_ExportFontResources(true);
options->set_ImageResolution(72);
options->set_FontResourcesSubsettingSizeThreshold(0);
options->set_FontsFolder(ArtifactsDir + u"Fonts");
options->set_ImagesFolder(ArtifactsDir + u"Images");
options->set_ResourceFolder(ArtifactsDir + u"Resources");
options->set_FontsFolderAlias(u"http://example.com/fonts");
options->set_ImagesFolderAlias(u"http://example.com/images");
options->set_ResourceFolderAlias(u"http://example.com/resources");
options->set_ExportOriginalUrlForLinkedImages(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.FolderAlias.html", options);

◆ get_ResourceFolderAlias()

System::String Aspose::Words::Saving::HtmlSaveOptions::get_ResourceFolderAlias ( ) const

Specifies the name of the folder used to construct URIs of all resources written into an HTML document. Default is an empty string.

ResourceFolderAlias is the simplest way to specify how URIs for all resource files should be constructed. Same information can be specified for images and fonts separately via ImagesFolderAlias and FontsFolderAlias properties, respectively. However, there is no individual property for CSS.

ResourceFolderAlias has lower priority than FontsFolderAlias and ImagesFolderAlias. For example, if both ResourceFolderAlias and FontsFolderAlias are specified, fonts' URIs will be constructed using FontsFolderAlias, while URIs of images and CSS will be constructed using ResourceFolderAlias.

If ResourceFolderAlias is empty, the ResourceFolder property value will be used to construct resource URIs.

If ResourceFolderAlias is set to '.' (dot), resource URIs will contain file names only, without any path.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_ResourceFolder
Aspose::Words::Saving::HtmlSaveOptions::get_FontsFolderAlias
Aspose::Words::Saving::HtmlSaveOptions::get_ImagesFolderAlias
Examples

Shows how to set folders and folder aliases for externally saved resources that Aspose.Words will create when saving a document to HTML.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
options->set_CssStyleSheetType(CssStyleSheetType::External);
options->set_ExportFontResources(true);
options->set_ImageResolution(72);
options->set_FontResourcesSubsettingSizeThreshold(0);
options->set_FontsFolder(ArtifactsDir + u"Fonts");
options->set_ImagesFolder(ArtifactsDir + u"Images");
options->set_ResourceFolder(ArtifactsDir + u"Resources");
options->set_FontsFolderAlias(u"http://example.com/fonts");
options->set_ImagesFolderAlias(u"http://example.com/images");
options->set_ResourceFolderAlias(u"http://example.com/resources");
options->set_ExportOriginalUrlForLinkedImages(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.FolderAlias.html", options);

◆ get_SaveFormat()

Aspose::Words::SaveFormat Aspose::Words::Saving::HtmlSaveOptions::get_SaveFormat ( )
overridevirtual

Specifies the format in which the document will be saved if this save options object is used. Can be Html, Mhtml or Epub.

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);

Implements Aspose::Words::Saving::SaveOptions.

◆ get_ScaleImageToShapeSize()

bool Aspose::Words::Saving::HtmlSaveOptions::get_ScaleImageToShapeSize ( )

Specifies whether images are scaled by Aspose.Words to the bounding shape size when exporting to HTML, MHTML or EPUB. Default value is true.

An image in a Microsoft Word document is a shape. The shape has a size and the image has its own size. The sizes are not directly linked. For example, the image can be 1024x786 pixels, but shape that displays this image can be 400x300 points.

In order to display an image in the browser, it must be scaled to the shape size. The ScaleImageToShapeSize property controls where the scaling of the image takes place: in Aspose.Words during export to HTML or in the browser when displaying the document.

When ScaleImageToShapeSize is true, the image is scaled by Aspose.Words using high quality scaling during export to HTML. When ScaleImageToShapeSize is false, the image is output with its original size and the browser has to scale it.

In general, browsers do quick and poor quality scaling. As a result, you will normally get better display quality in the browser and smaller file size when ScaleImageToShapeSize is true, but better printing quality and faster conversion when ScaleImageToShapeSize is false.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_ImageResolution
Examples

Shows how to disable the scaling of images to their parent shape dimensions when saving to .html.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a shape which contains an image, and then make that shape considerably smaller than the image.
SharedPtr<System::Drawing::Image> image = System::Drawing::Image::FromFile(ImageDir + u"Transparent background logo.png");
ASSERT_EQ(400, image->get_Size().get_Width());
ASSERT_EQ(400, image->get_Size().get_Height());
SharedPtr<Shape> imageShape = builder->InsertImage(image);
imageShape->set_Width(50);
imageShape->set_Height(50);
// Saving a document that contains shapes with images to HTML will create an image file in the local file system
// for each such shape. The output HTML document will use <image> tags to link to and display these images.
// When we save the document to HTML, we can pass a SaveOptions object to determine
// whether to scale all images that are inside shapes to the sizes of their shapes.
// Setting the "ScaleImageToShapeSize" flag to "true" will shrink every image
// to the size of the shape that contains it, so that no saved images will be larger than the document requires them to be.
// Setting the "ScaleImageToShapeSize" flag to "false" will preserve these images' original sizes,
// which will take up more space in exchange for preserving image quality.
auto options = MakeObject<HtmlSaveOptions>();
options->set_ScaleImageToShapeSize(scaleImageToShapeSize);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ScaleImageToShapeSize.html", options);
auto fileInfo = MakeObject<System::IO::FileInfo>(ArtifactsDir + u"HtmlSaveOptions.ScaleImageToShapeSize.001.png");
static ASPOSECPP_SHARED_API SharedPtr< Image > FromFile(const String &filename, bool use_embedded_color_management=false)

◆ get_TableWidthOutputMode()

Aspose::Words::Saving::HtmlElementSizeOutputMode Aspose::Words::Saving::HtmlSaveOptions::get_TableWidthOutputMode ( ) const

Controls how table, row and cell widths are exported to HTML, MHTML or EPUB. Default value is All.

In the HTML format, table, row and cell elements (<table>, <tr>, <th>, <td>) can have their widths specified either in relative (percentage) or in absolute units. In a document in Aspose.Words, tables, rows and cells can have their widths specified using either relative or absolute units too.

When you convert a document to HTML using Aspose.Words, you might want to control how table, row and cell widths are exported to affect how the resulting document is displayed in the visual agent (e.g. a browser or viewer).

Use this property as a filter to specify what table widths values are exported into the destination document. For example, if you are converting a document to EPUB and intend to view the document on a mobile reading device, then you probably want to avoid exporting absolute width values. To do this you need to specify the output mode RelativeOnly or None so the viewer on the mobile device can layout the table to fit the width of the screen as best as it can.

Examples

Shows how to preserve negative indents in the output .html.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a table with a negative indent, which will push it to the left past the left page boundary.
SharedPtr<Table> table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Row 1, Cell 1");
builder->InsertCell();
builder->Write(u"Row 1, Cell 2");
builder->EndTable();
table->set_LeftIndent(-36);
table->set_PreferredWidth(PreferredWidth::FromPoints(144));
builder->InsertBreak(BreakType::ParagraphBreak);
// Insert a table with a positive indent, which will push the table to the right.
table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Row 1, Cell 1");
builder->InsertCell();
builder->Write(u"Row 1, Cell 2");
builder->EndTable();
table->set_LeftIndent(36);
table->set_PreferredWidth(PreferredWidth::FromPoints(144));
// When we save a document to HTML, Aspose.Words will only preserve negative indents
// such as the one we have applied to the first table if we set the "AllowNegativeIndent" flag
// in a SaveOptions object that we will pass to "true".
auto options = MakeObject<HtmlSaveOptions>(SaveFormat::Html);
options->set_AllowNegativeIndent(allowNegativeIndent);
options->set_TableWidthOutputMode(HtmlElementSizeOutputMode::RelativeOnly);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.NegativeIndent.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.NegativeIndent.html");
if (allowNegativeIndent)
{
ASSERT_TRUE(outDocContents.Contains(u"<table cellspacing=\"0\" cellpadding=\"0\" style=\"margin-left:-41.65pt; border:0.75pt solid #000000; "
u"-aw-border:0.5pt single; border-collapse:collapse\">"));
ASSERT_TRUE(outDocContents.Contains(u"<table cellspacing=\"0\" cellpadding=\"0\" style=\"margin-left:30.35pt; border:0.75pt solid #000000; "
u"-aw-border:0.5pt single; border-collapse:collapse\">"));
}
else
{
ASSERT_TRUE(outDocContents.Contains(
u"<table cellspacing=\"0\" cellpadding=\"0\" style=\"border:0.75pt solid #000000; -aw-border:0.5pt single; border-collapse:collapse\">"));
ASSERT_TRUE(outDocContents.Contains(u"<table cellspacing=\"0\" cellpadding=\"0\" style=\"margin-left:30.35pt; border:0.75pt solid #000000; "
u"-aw-border:0.5pt single; border-collapse:collapse\">"));
}

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Saving::HtmlSaveOptions::GetType ( ) const
overridevirtual

◆ Is()

virtual bool Aspose::Words::Saving::HtmlSaveOptions::Is ( const System::TypeInfo target) const
overridevirtual

◆ set_AllowNegativeIndent()

void Aspose::Words::Saving::HtmlSaveOptions::set_AllowNegativeIndent ( bool  value)

◆ set_CssClassNamePrefix()

void Aspose::Words::Saving::HtmlSaveOptions::set_CssClassNamePrefix ( System::String  value)

◆ set_CssSavingCallback()

void Aspose::Words::Saving::HtmlSaveOptions::set_CssSavingCallback ( System::SharedPtr< Aspose::Words::Saving::ICssSavingCallback value)

◆ set_CssStyleSheetFileName()

void Aspose::Words::Saving::HtmlSaveOptions::set_CssStyleSheetFileName ( System::String  value)

◆ set_CssStyleSheetType()

void Aspose::Words::Saving::HtmlSaveOptions::set_CssStyleSheetType ( Aspose::Words::Saving::CssStyleSheetType  value)

◆ set_DocumentPartSavingCallback()

void Aspose::Words::Saving::HtmlSaveOptions::set_DocumentPartSavingCallback ( System::SharedPtr< Aspose::Words::Saving::IDocumentPartSavingCallback value)

◆ set_DocumentSplitCriteria()

void Aspose::Words::Saving::HtmlSaveOptions::set_DocumentSplitCriteria ( Aspose::Words::Saving::DocumentSplitCriteria  value)

◆ set_DocumentSplitHeadingLevel()

void Aspose::Words::Saving::HtmlSaveOptions::set_DocumentSplitHeadingLevel ( int32_t  value)

◆ set_Encoding()

void Aspose::Words::Saving::HtmlSaveOptions::set_Encoding ( System::SharedPtr< System::Text::Encoding value)

◆ set_EpubNavigationMapLevel()

void Aspose::Words::Saving::HtmlSaveOptions::set_EpubNavigationMapLevel ( int32_t  value)

◆ set_ExportCidUrlsForMhtmlResources()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportCidUrlsForMhtmlResources ( bool  value)

◆ set_ExportDocumentProperties()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportDocumentProperties ( bool  value)

◆ set_ExportDropDownFormFieldAsText()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportDropDownFormFieldAsText ( bool  value)

◆ set_ExportFontResources()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportFontResources ( bool  value)

◆ set_ExportFontsAsBase64()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportFontsAsBase64 ( bool  value)

◆ set_ExportHeadersFootersMode()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportHeadersFootersMode ( Aspose::Words::Saving::ExportHeadersFootersMode  value)

◆ set_ExportImagesAsBase64()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportImagesAsBase64 ( bool  value)

◆ set_ExportLanguageInformation()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportLanguageInformation ( bool  value)

◆ set_ExportListLabels()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportListLabels ( Aspose::Words::Saving::ExportListLabels  value)

◆ set_ExportOriginalUrlForLinkedImages()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportOriginalUrlForLinkedImages ( bool  value)

◆ set_ExportPageMargins()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportPageMargins ( bool  value)

◆ set_ExportPageSetup()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportPageSetup ( bool  value)

◆ set_ExportRelativeFontSize()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportRelativeFontSize ( bool  value)

◆ set_ExportRoundtripInformation()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportRoundtripInformation ( bool  value)

◆ set_ExportTextBoxAsSvg()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportTextBoxAsSvg ( bool  value)

◆ set_ExportTextInputFormFieldAsText()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportTextInputFormFieldAsText ( bool  value)

◆ set_ExportTocPageNumbers()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportTocPageNumbers ( bool  value)

◆ set_ExportXhtmlTransitional()

void Aspose::Words::Saving::HtmlSaveOptions::set_ExportXhtmlTransitional ( bool  value)

◆ set_FontResourcesSubsettingSizeThreshold()

void Aspose::Words::Saving::HtmlSaveOptions::set_FontResourcesSubsettingSizeThreshold ( int32_t  value)

◆ set_FontSavingCallback()

void Aspose::Words::Saving::HtmlSaveOptions::set_FontSavingCallback ( System::SharedPtr< Aspose::Words::Saving::IFontSavingCallback value)

◆ set_FontsFolder()

void Aspose::Words::Saving::HtmlSaveOptions::set_FontsFolder ( System::String  value)

◆ set_FontsFolderAlias()

void Aspose::Words::Saving::HtmlSaveOptions::set_FontsFolderAlias ( System::String  value)

◆ set_HtmlVersion()

void Aspose::Words::Saving::HtmlSaveOptions::set_HtmlVersion ( Aspose::Words::Saving::HtmlVersion  value)

◆ set_ImageResolution()

void Aspose::Words::Saving::HtmlSaveOptions::set_ImageResolution ( int32_t  value)

◆ set_ImageSavingCallback()

void Aspose::Words::Saving::HtmlSaveOptions::set_ImageSavingCallback ( System::SharedPtr< Aspose::Words::Saving::IImageSavingCallback value)

◆ set_ImagesFolder()

void Aspose::Words::Saving::HtmlSaveOptions::set_ImagesFolder ( System::String  value)

◆ set_ImagesFolderAlias()

void Aspose::Words::Saving::HtmlSaveOptions::set_ImagesFolderAlias ( System::String  value)

◆ set_MetafileFormat()

void Aspose::Words::Saving::HtmlSaveOptions::set_MetafileFormat ( Aspose::Words::Saving::HtmlMetafileFormat  value)

◆ set_OfficeMathOutputMode()

void Aspose::Words::Saving::HtmlSaveOptions::set_OfficeMathOutputMode ( Aspose::Words::Saving::HtmlOfficeMathOutputMode  value)

◆ set_ResolveFontNames()

void Aspose::Words::Saving::HtmlSaveOptions::set_ResolveFontNames ( bool  value)

◆ set_ResourceFolder()

void Aspose::Words::Saving::HtmlSaveOptions::set_ResourceFolder ( System::String  value)

◆ set_ResourceFolderAlias()

void Aspose::Words::Saving::HtmlSaveOptions::set_ResourceFolderAlias ( System::String  value)

◆ set_SaveFormat()

void Aspose::Words::Saving::HtmlSaveOptions::set_SaveFormat ( Aspose::Words::SaveFormat  value)
overridevirtual

◆ set_ScaleImageToShapeSize()

void Aspose::Words::Saving::HtmlSaveOptions::set_ScaleImageToShapeSize ( bool  value)

◆ set_TableWidthOutputMode()

void Aspose::Words::Saving::HtmlSaveOptions::set_TableWidthOutputMode ( Aspose::Words::Saving::HtmlElementSizeOutputMode  value)

◆ Type()

static const System::TypeInfo& Aspose::Words::Saving::HtmlSaveOptions::Type ( )
static