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 convert a document to EPUB with save options specified.

// Open an existing document from disk
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Create a new instance of HtmlSaveOptions. This object allows us to set options that control
// how the output document is saved
auto saveOptions = MakeObject<HtmlSaveOptions>();
// Specify the desired encoding
saveOptions->set_Encoding(System::Text::Encoding::get_UTF8());
// Specify at what elements to split the internal HTML at. This creates a new HTML within the EPUB
// which allows you to limit the size of each HTML part. This is useful for readers which cannot read
// HTML files greater than a certain size e.g 300kb
// Specify that we want to export document properties
saveOptions->set_ExportDocumentProperties(true);
// Specify that we want to save in EPUB format
saveOptions->set_SaveFormat(Aspose::Words::SaveFormat::Epub);
// Export the document as an EPUB file
doc->Save(ArtifactsDir + u"Document.Doc2EpubSaveOptions.epub", saveOptions);

Shows how to set save options before saving a document to HTML.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// This is the directory we want the exported images to be saved to
String imagesDir = System::IO::Path::Combine(ArtifactsDir, u"SaveHtmlWithOptions");
// The folder specified needs to exist and should be empty
{
}
// Set an option to export form fields as plain text, not as HTML input elements
auto options = MakeObject<HtmlSaveOptions>(Aspose::Words::SaveFormat::Html);
options->set_ExportTextInputFormFieldAsText(true);
options->set_ImagesFolder(imagesDir);
doc->Save(ArtifactsDir + u"Document.SaveHtmlWithOptions.html", options);

#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)
 Allows to control how CSS styles are saved when a document is saved to HTML, MHTML or EPUB. 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)
 Allows to control how document parts are saved when a document is saved to HTML or EPUB. 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)
 Allows to control how fonts are saved when a document is saved to HTML, MHTML or EPUB. 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)
 Allows to control how images are saved when a document is saved to HTML, MHTML or EPUB. 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
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_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_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_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)
 
Detail::SmartPtrCounter * GetCounter ()
 
virtual ASPOSECPP_SHARED_API int 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 (unsigned int 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
 
typedef System::Details::SharedMembersType shared_members_type
 

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 convert a document to EPUB with save options specified.

// Open an existing document from disk
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Create a new instance of HtmlSaveOptions. This object allows us to set options that control
// how the output document is saved
auto saveOptions = MakeObject<HtmlSaveOptions>();
// Specify the desired encoding
saveOptions->set_Encoding(System::Text::Encoding::get_UTF8());
// Specify at what elements to split the internal HTML at. This creates a new HTML within the EPUB
// which allows you to limit the size of each HTML part. This is useful for readers which cannot read
// HTML files greater than a certain size e.g 300kb
// Specify that we want to export document properties
saveOptions->set_ExportDocumentProperties(true);
// Specify that we want to save in EPUB format
saveOptions->set_SaveFormat(Aspose::Words::SaveFormat::Epub);
// Export the document as an EPUB file
doc->Save(ArtifactsDir + u"Document.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 set a saved .html document to a specific version.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Save the document to a .html file of the XHTML 1.0 Transitional standard
auto options = MakeObject<HtmlSaveOptions>(Aspose::Words::SaveFormat::Html);
options->set_ExportXhtmlTransitional(true);
options->set_PrettyFormat(true);
// The DOCTYPE declaration at the top of this document will indicate the html version we chose
doc->Save(ArtifactsDir + u"HtmlSaveOptions.HtmlVersion.html", options);

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 and give it a negative value for its indent, effectively pushing it out of the left page boundary
SharedPtr<Table> table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Cell 1");
builder->InsertCell();
builder->Write(u"Cell 2");
builder->EndTable();
table->set_LeftIndent(-36);
table->set_PreferredWidth(PreferredWidth::FromPoints(144));
// When saving to .html, this indent will only be preserved if we set this flag
auto options = MakeObject<HtmlSaveOptions>(Aspose::Words::SaveFormat::Html);
options->set_AllowNegativeIndent(true);
// The first cell with "Cell 1" will not be visible in the output
doc->Save(ArtifactsDir + u"HtmlSaveOptions.NegativeIndent.html", options);

◆ 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 specifies a prefix which is added to all CSS class names.

auto doc = MakeObject<Document>(MyDir + u"Paragraphs.docx");
auto saveOptions = MakeObject<HtmlSaveOptions>();
saveOptions->set_CssStyleSheetType(Aspose::Words::Saving::CssStyleSheetType::Embedded);
saveOptions->set_CssClassNamePrefix(u"myprefix-");
// The prefix will be found before CSS element names in the embedded stylesheet
doc->Save(ArtifactsDir + u"HtmlSaveOptions.CssClassNamePrefix.html", saveOptions);

◆ 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.

◆ 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

◆ 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

◆ 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.

◆ 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 convert a document to EPUB with save options specified.

// Open an existing document from disk
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Create a new instance of HtmlSaveOptions. This object allows us to set options that control
// how the output document is saved
auto saveOptions = MakeObject<HtmlSaveOptions>();
// Specify the desired encoding
saveOptions->set_Encoding(System::Text::Encoding::get_UTF8());
// Specify at what elements to split the internal HTML at. This creates a new HTML within the EPUB
// which allows you to limit the size of each HTML part. This is useful for readers which cannot read
// HTML files greater than a certain size e.g 300kb
// Specify that we want to export document properties
saveOptions->set_ExportDocumentProperties(true);
// Specify that we want to save in EPUB format
saveOptions->set_SaveFormat(Aspose::Words::SaveFormat::Epub);
// Export the document as an EPUB file
doc->Save(ArtifactsDir + u"Document.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 a document into several html documents by heading levels.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert headings 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", meaning that the document
// will be split into parts at the beginning of every paragraph of a "Heading" style, and each part will be saved as a separate document
// Also, we will set the DocumentSplitHeadingLevel to 2, which will split the document only at headings that have levels from 1 to 2
auto options = MakeObject<HtmlSaveOptions>();
options->set_DocumentSplitHeadingLevel(2);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.HeadingLevels.html", options);

◆ 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 convert a document to EPUB with save options specified.

// Open an existing document from disk
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Create a new instance of HtmlSaveOptions. This object allows us to set options that control
// how the output document is saved
auto saveOptions = MakeObject<HtmlSaveOptions>();
// Specify the desired encoding
saveOptions->set_Encoding(System::Text::Encoding::get_UTF8());
// Specify at what elements to split the internal HTML at. This creates a new HTML within the EPUB
// which allows you to limit the size of each HTML part. This is useful for readers which cannot read
// HTML files greater than a certain size e.g 300kb
// Specify that we want to export document properties
saveOptions->set_ExportDocumentProperties(true);
// Specify that we want to save in EPUB format
saveOptions->set_SaveFormat(Aspose::Words::SaveFormat::Epub);
// Export the document as an EPUB file
doc->Save(ArtifactsDir + u"Document.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 the relationship between heading levels and the Epub navigation panel.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert headings 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 normally treat paragraphs with "Heading" styles as anchors for a table of contents-style navigation pane
// We set a maximum heading level above which headings won't be registered by the reader as navigation points with
// a HtmlSaveOptions object and its EpubNavigationLevel attribute
// Our document has headings of levels 1 to 3,
// but our output epub will only place level 1 and 2 headings in the table of contents
auto options = MakeObject<HtmlSaveOptions>(Aspose::Words::SaveFormat::Epub);
options->set_EpubNavigationMapLevel(2);
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
// The file names that were next to each "Content-Location" tag are re-purposed as content IDs
auto options = MakeObject<HtmlSaveOptions>(Aspose::Words::SaveFormat::Mhtml);
options->set_ExportCidUrlsForMhtmlResources(true);
options->set_ExportFontResources(true);
options->set_PrettyFormat(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ContentIdUrls.mht", options);

◆ 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 convert a document to EPUB with save options specified.

// Open an existing document from disk
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Create a new instance of HtmlSaveOptions. This object allows us to set options that control
// how the output document is saved
auto saveOptions = MakeObject<HtmlSaveOptions>();
// Specify the desired encoding
saveOptions->set_Encoding(System::Text::Encoding::get_UTF8());
// Specify at what elements to split the internal HTML at. This creates a new HTML within the EPUB
// which allows you to limit the size of each HTML part. This is useful for readers which cannot read
// HTML files greater than a certain size e.g 300kb
// Specify that we want to export document properties
saveOptions->set_ExportDocumentProperties(true);
// Specify that we want to save in EPUB format
saveOptions->set_SaveFormat(Aspose::Words::SaveFormat::Epub);
// Export the document as an EPUB file
doc->Save(ArtifactsDir + u"Document.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);
// When converting to .html, drop down combo boxes will be converted to select/option tags to preserve their functionality
// If we want to freeze a combo box at its current selected value and convert it into plain text, we can do so with this flag
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportDropDownFormFieldAsText(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.DropDownFormField.html", options);

◆ 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

◆ 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 resources embedded inside it.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// By default, when converting a document with images to .html, resources such as images will be linked to in external files
// We can set these flags to embed resources inside the output .html instead, cutting down on the amount of files created during the conversion
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportFontsAsBase64(true);
options->set_ExportImagesAsBase64(true);
options->set_PrettyFormat(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportBase64.html", options);

◆ 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

Demonstrates how to disable the export of headers and footers when saving to HTML based formats.

auto doc = MakeObject<Document>(MyDir + u"Header and footer types.docx");
// This document contains headers and footers, whose text contents can be looked up like this
ASSERT_EQ(u"First header", doc->get_FirstSection()->get_HeadersFooters()->idx_get(Aspose::Words::HeaderFooterType::HeaderFirst)->GetText().Trim());
// Formats such as html do not have a pre-defined equivalent for Microsoft Word headers/footers
// If we convert a document with headers and/or footers to html, they will be assimilated into body text
// We can use a SaveOptions object to omit headers/footers while converting to html
auto saveOptions = MakeObject<HtmlSaveOptions>(Aspose::Words::SaveFormat::Html);
saveOptions->set_ExportHeadersFootersMode(Aspose::Words::Saving::ExportHeadersFootersMode::None);
doc->Save(ArtifactsDir + u"HeaderFooter.DisableHeadersFooters.html", saveOptions);
// Open our saved document and verify that it does not contain the header's text
doc = MakeObject<Document>(ArtifactsDir + u"HeaderFooter.DisableHeadersFooters.html");
ASSERT_FALSE(doc->get_Range()->get_Text().Contains(u"First header"));

◆ 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 resources embedded inside it.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// By default, when converting a document with images to .html, resources such as images will be linked to in external files
// We can set these flags to embed resources inside the output .html instead, cutting down on the amount of files created during the conversion
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportFontsAsBase64(true);
options->set_ExportImagesAsBase64(true);
options->set_PrettyFormat(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportBase64.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 in more than one language
builder->get_Font()->set_LocaleId(2057);
// en-GB
builder->Writeln(u"Hello world!");
builder->get_Font()->set_LocaleId(1049);
// ru-RU
builder->Write(u"Привет, мир!");
// Normally, when saving a document with more than one proofing language to .html,
// only the text content is preserved with no traces of any other languages
// Saving with a HtmlSaveOptions object with this flag set will add "lang" attributes to spans
// in places where other proofing languages were used
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportLanguageInformation(true);
options->set_PrettyFormat(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportLanguageInformation.html", options);

◆ 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 export an indented list to .html as plain text.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Use the builder to insert a list
SharedPtr<Aspose::Words::Lists::List> list = doc->get_Lists()->Add(Aspose::Words::Lists::ListTemplate::NumberDefault);
builder->get_ListFormat()->set_List(list);
builder->Writeln(u"List item 1.");
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"List item 2.");
builder->get_ListFormat()->ListIndent();
builder->Write(u"List item 3.");
// When we save this to .html, normally our list will be represented by <li> tags
// We can set this flag to have lists as plain text instead
auto options = MakeObject<HtmlSaveOptions>();
options->set_PrettyFormat(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.List.html", options);

◆ 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 when saving to html.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
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(Aspose::Words::Drawing::ShapeType::Cube, 200, 200);
shape->set_RelativeHorizontalPosition(Aspose::Words::Drawing::RelativeHorizontalPosition::Page);
shape->set_RelativeVerticalPosition(Aspose::Words::Drawing::RelativeVerticalPosition::Page);
// Negative values for shape position may cause the shape to go out of page bounds
// If we export this to .html, the shape will be truncated
shape->set_Left(-150);
// We can avoid that and have the entire shape be visible by setting this flag
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportPageMargins(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportPageMargins2.html", options);

◆ 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 to preserve section structure/page setup information when saving to html.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Use a DocumentBuilder to insert two sections with text
builder->Writeln(u"Section 1");
builder->Writeln(u"Section 2");
// Change dimensions and paper size of first section
SharedPtr<PageSetup> pageSetup = doc->get_Sections()->idx_get(0)->get_PageSetup();
pageSetup->set_TopMargin(36.0);
pageSetup->set_BottomMargin(36.0);
pageSetup->set_PaperSize(Aspose::Words::PaperSize::A5);
// Section structure and pagination are normally lost when when converting to .html
// We can create an HtmlSaveOptions object with the ExportPageSetup flag set to true
// to preserve the section structure in <div> tags and page dimensions in the output document's CSS
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportPageSetup(true);
options->set_PrettyFormat(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportPageSetup.html", options);

◆ 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);
// Use a builder to write some text in various sizes
builder->Writeln(u"Default font size, ");
builder->get_Font()->set_Size(24.0);
builder->Writeln(u"2x default font size,");
builder->get_Font()->set_Size(96);
builder->Write(u"8x default font size");
// We can save font sizes as ratios of the default size, which will be 12 in this case
// If we use an input .html, this size can be set with the AbsSize {font-size:12pt} tag
// The ExportRelativeFontSize will enable this feature
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportRelativeFontSize(true);
options->set_PrettyFormat(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.RelativeFontSize.html", options);

◆ 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
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportRoundtripInformation(true);
options->set_PrettyFormat(true);
// These elements will have tags that will start with "-aw", such as "-aw-import" or "-aw-left-pos"
doc->Save(ArtifactsDir + u"HtmlSaveOptions.RoundTripInformation.html", options);

◆ 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);
// Use a DocumentBuilder to insert a text box and give it some text content
SharedPtr<Shape> textBox = builder->InsertShape(Aspose::Words::Drawing::ShapeType::TextBox, 100.0, 60.0);
builder->MoveTo(textBox->get_FirstParagraph());
builder->Write(u"My text box");
// Normally, all shapes such as the text box we placed are exported to .html as external images linked by the .html document
// We can save with an HtmlSaveOptions object with the ExportTextBoxAsSvg set to true to save text boxes as <svg> tags,
// which will cause no linked images to be saved and will make the inner text selectable
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportTextBoxAsSvg(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportTextBox.html", options);

◆ 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 set save options before saving a document to HTML.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// This is the directory we want the exported images to be saved to
String imagesDir = System::IO::Path::Combine(ArtifactsDir, u"SaveHtmlWithOptions");
// The folder specified needs to exist and should be empty
{
}
// Set an option to export form fields as plain text, not as HTML input elements
auto options = MakeObject<HtmlSaveOptions>(Aspose::Words::SaveFormat::Html);
options->set_ExportTextInputFormFieldAsText(true);
options->set_ImagesFolder(imagesDir);
doc->Save(ArtifactsDir + u"Document.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
auto fieldToc = System::DynamicCast<Aspose::Words::Fields::FieldToc>(builder->InsertField(Aspose::Words::Fields::FieldType::FieldTOC, true));
// Populate the document with paragraphs of a "Heading" style that the table of contents will pick up
builder->get_ParagraphFormat()->set_Style(builder->get_Document()->get_Styles()->idx_get(u"Heading 1"));
builder->Writeln(u"Entry 1");
builder->Writeln(u"Entry 2");
builder->Writeln(u"Entry 3");
builder->Writeln(u"Entry 4");
// Our headings span several pages, and those page numbers will be displayed by the TOC at the top of the document
fieldToc->UpdatePageNumbers();
doc->UpdateFields();
// These page numbers are normally omitted since .html has no pagination, but we can still have them displayed
// if we save with a HtmlSaveOptions object with the ExportTocPageNumbers set to true
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportTocPageNumbers(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportTocPageNumbers.html", options);

◆ 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 set a saved .html document to a specific version.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Save the document to a .html file of the XHTML 1.0 Transitional standard
auto options = MakeObject<HtmlSaveOptions>(Aspose::Words::SaveFormat::Html);
options->set_ExportXhtmlTransitional(true);
options->set_PrettyFormat(true);
// The DOCTYPE declaration at the top of this document will indicate the html version we chose
doc->Save(ArtifactsDir + u"HtmlSaveOptions.HtmlVersion.html", options);

◆ 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);
// Use a DocumentBuilder to insert text with several fonts
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 saving to .html, font subsetting fully applies by default, meaning that when we export fonts with our file,
// the symbols not used by our document are not represented by the exported fonts, which cuts down file size dramatically
// Font files of a file size larger than FontResourcesSubsettingSizeThreshold get subsetted, so a value of 0 will apply default full subsetting
// Setting the value to something large will fully suppress subsetting, saving some very large font files that cover every glyph
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportFontResources(true);
options->set_FontResourcesSubsettingSizeThreshold(std::numeric_limits<int>::max());
doc->Save(ArtifactsDir + u"HtmlSaveOptions.FontSubsetting.html", options);

◆ 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.

◆ 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 when saving to html.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
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 when saving to html.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
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 set a saved .html document to a specific version.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Save the document to a .html file of the XHTML 1.0 Transitional standard
auto options = MakeObject<HtmlSaveOptions>(Aspose::Words::SaveFormat::Html);
options->set_ExportXhtmlTransitional(true);
options->set_PrettyFormat(true);
// The DOCTYPE declaration at the top of this document will indicate the html version we chose
doc->Save(ArtifactsDir + u"HtmlSaveOptions.HtmlVersion.html", options);

◆ 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 when saving to html.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
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.

◆ 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 set save options before saving a document to HTML.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// This is the directory we want the exported images to be saved to
String imagesDir = System::IO::Path::Combine(ArtifactsDir, u"SaveHtmlWithOptions");
// The folder specified needs to exist and should be empty
{
}
// Set an option to export form fields as plain text, not as HTML input elements
auto options = MakeObject<HtmlSaveOptions>(Aspose::Words::SaveFormat::Html);
options->set_ExportTextInputFormFieldAsText(true);
options->set_ImagesFolder(imagesDir);
doc->Save(ArtifactsDir + u"Document.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 when saving to html.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
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 set a meta file in a different format.

// Create a document from an html string
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 <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,
// which by default will be saved as a linked external .png when we save the document as html
// We can save with a HtmlSaveOptions object with this flag set to preserve the <svg> tag
auto options = MakeObject<HtmlSaveOptions>();
doc->Save(ArtifactsDir + u"HtmlSaveOptions.MetafileFormat.html", options);

◆ 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 control the way how OfficeMath objects are exported to .html.

// Open a document that contains OfficeMath objects
auto doc = MakeObject<Document>(MyDir + u"Office math.docx");
// Create a HtmlSaveOptions object and configure it to export OfficeMath objects as images
auto options = MakeObject<HtmlSaveOptions>();
options->set_OfficeMathOutputMode(Aspose::Words::Saving::HtmlOfficeMathOutputMode::Image);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.OfficeMathOutputMode.html", options);

◆ 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 when saving to html.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
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 when saving to html.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>();
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 convert a document to EPUB with save options specified.

// Open an existing document from disk
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Create a new instance of HtmlSaveOptions. This object allows us to set options that control
// how the output document is saved
auto saveOptions = MakeObject<HtmlSaveOptions>();
// Specify the desired encoding
saveOptions->set_Encoding(System::Text::Encoding::get_UTF8());
// Specify at what elements to split the internal HTML at. This creates a new HTML within the EPUB
// which allows you to limit the size of each HTML part. This is useful for readers which cannot read
// HTML files greater than a certain size e.g 300kb
// Specify that we want to export document properties
saveOptions->set_ExportDocumentProperties(true);
// Specify that we want to save in EPUB format
saveOptions->set_SaveFormat(Aspose::Words::SaveFormat::Epub);
// Export the document as an EPUB file
doc->Save(ArtifactsDir + u"Document.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.

// Open a document which contains shapes with images
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// By default, images inside shapes get scaled to the size of their shapes while the document gets
// converted to .html, reducing image file size
// We can save the document with a HtmlSaveOptions with ScaleImageToShapeSize set to false to prevent the scaling
// and preserve the full quality and file size of the linked images
auto options = MakeObject<HtmlSaveOptions>();
options->set_ScaleImageToShapeSize(false);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ScaleImageToShapeSize.html", options);

◆ 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 and give it a negative value for its indent, effectively pushing it out of the left page boundary
SharedPtr<Table> table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Cell 1");
builder->InsertCell();
builder->Write(u"Cell 2");
builder->EndTable();
table->set_LeftIndent(-36);
table->set_PreferredWidth(PreferredWidth::FromPoints(144));
// When saving to .html, this indent will only be preserved if we set this flag
auto options = MakeObject<HtmlSaveOptions>(Aspose::Words::SaveFormat::Html);
options->set_AllowNegativeIndent(true);
// The first cell with "Cell 1" will not be visible in the output
doc->Save(ArtifactsDir + u"HtmlSaveOptions.NegativeIndent.html", options);

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

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

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

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

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

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

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

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

◆ 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
@ FieldTOC
Specifies the TOC field.
static ASPOSECPP_SHARED_API void CreateDirectory_(const String &path)
String
static ASPOSECPP_SHARED_API String Combine(const ArrayPtr< String > &paths)
@ PageBreak
Explicit page break.
@ Cube
@ A5
148 x 210 mm.
@ Epub
Saves the document in the IDPF EPUB format.
@ RelativeOnly
Element sizes are exported only if they are specified in relative units in the document....
@ Page
The object is positioned relative to the top edge of the page.
static ASPOSECPP_SHARED_API bool Exists(const String &path)
@ NumberDefault
Default numbered list with 9 levels. Arabic numbering (1., 2., 3., ...) for the first level,...
static ASPOSECPP_SHARED_API void Delete(const String &path, bool recursive=false)
@ None
No text wrapping around the shape. The shape is placed behind or in front of text.
@ Embedded
CSS styles are written separately from the content in a style sheet embedded in the HTML file.
@ HeaderFirst
Header for the first page of the section.
static ASPOSECPP_SHARED_API EncodingPtr get_UTF8()
@ Page
The object is positioned relative to the left edge of the page.
@ TextBox
The shape is a textbox. Note that shapes of many other types can also have text inside them too....
@ External
CSS styles are written separately from the content in a style sheet in an external file....
@ Xhtml
Saves the document in compliance with the XHTML 1.0 Transitional standard.
@ Html
Saves the document in the HTML format.
@ Svg
Metafiles are converted to vector SVG images.
@ Mhtml
Saves the document in the MHTML (Web archive) format.
@ HeadingParagraph
The document is split into parts at a paragraph formatted using a heading style Heading 1,...
@ Image
OfficeMath is converted to HTML as image specified by <img> tag.
@ SectionBreakNewPage
Specifies start of new section on a new page.
@ None
Headers and footers are not exported.
@ AsInlineText
Outputs all list labels as inline text.