HtmlSaveOptions class

HtmlSaveOptions class

Can be used to specify additional options when saving a document into the SaveFormat.Html, SaveFormat.Mhtml, SaveFormat.Epub, SaveFormat.Azw3 or SaveFormat.Mobi format. To learn more, visit the Specify Save Options documentation article.

Inheritance: HtmlSaveOptionsSaveOptions

Constructors

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

Properties

NameDescription
allowEmbeddingPostScriptFontsGets or sets a boolean value indicating whether to allow embedding fonts with PostScript outlines when embedding TrueType fonts in a document upon it is saved. The default value is false.
(Inherited from SaveOptions)
allowNegativeIndentSpecifies whether negative left and right indents of paragraphs are normalized when saving to HTML, MHTML or EPUB. Default value is false.
cssClassNamePrefixSpecifies 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.
cssSavingCallbackAllows to control how CSS styles are saved when a document is saved to HTML, MHTML or EPUB.
cssStyleSheetFileNameSpecifies 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.
cssStyleSheetTypeSpecifies how CSS (Cascading Style Sheet) styles are exported to HTML, MHTML or EPUB. Default value is CssStyleSheetType.Inline for HTML/MHTML and CssStyleSheetType.External for EPUB.
defaultTemplateGets or sets path to default template (including filename). Default value for this property is empty string .
(Inherited from SaveOptions)
dml3DEffectsRenderingModeGets or sets a value determining how 3D effects are rendered.
(Inherited from SaveOptions)
dmlEffectsRenderingModeGets or sets a value determining how DrawingML effects are rendered.
(Inherited from SaveOptions)
dmlRenderingModeGets or sets a value determining how DrawingML shapes are rendered.
(Inherited from SaveOptions)
documentPartSavingCallbackAllows to control how document parts are saved when a document is saved to HTML or EPUB.
documentSplitCriteriaSpecifies how the document should be split when saving to SaveFormat.Html, SaveFormat.Epub or SaveFormat.Azw3 format. Default is DocumentSplitCriteria.None for HTML and DocumentSplitCriteria.HeadingParagraph for EPUB and AZW3.
documentSplitHeadingLevelSpecifies the maximum level of headings at which to split the document. Default value is 2.
encodingSpecifies the encoding to use when exporting to HTML, MHTML or EPUB. Default value is .
exportCidUrlsForMhtmlResourcesSpecifies whether to use CID (Content-ID) URLs to reference resources (images, fonts, CSS) included in MHTML documents. Default value is false.
exportDocumentPropertiesSpecifies whether to export built-in and custom document properties to HTML, MHTML or EPUB. Default value is false.
exportDropDownFormFieldAsTextControls how drop-down form fields are saved to HTML or MHTML. Default value is false.
exportFontResourcesSpecifies whether font resources should be exported to HTML, MHTML or EPUB. Default is false.
exportFontsAsBase64Specifies whether fonts resources should be embedded to HTML in Base64 encoding. Default is false.
exportGeneratorNameWhen true, causes the name and version of Aspose.Words to be embedded into produced files. Default value is true.
(Inherited from SaveOptions)
exportHeadersFootersModeSpecifies how headers and footers are output to HTML, MHTML or EPUB. Default value is ExportHeadersFootersMode.PerSection for HTML/MHTML and ExportHeadersFootersMode.None for EPUB.
exportImagesAsBase64Specifies whether images are saved in Base64 format to the output HTML, MHTML or EPUB. Default is false.
exportLanguageInformationSpecifies whether language information is exported to HTML, MHTML or EPUB. Default is false.
exportListLabelsControls how list labels are output to HTML, MHTML or EPUB. Default value is ExportListLabels.Auto.
exportOriginalUrlForLinkedImagesSpecifies whether original URL should be used as the URL of the linked images. Default value is false.
exportPageMarginsSpecifies whether page margins is exported to HTML, MHTML or EPUB. Default is false.
exportPageSetupSpecifies whether page setup is exported to HTML, MHTML or EPUB. Default is false.
exportRelativeFontSizeSpecifies whether font sizes should be output in relative units when saving to HTML, MHTML or EPUB. Default is false.
exportRoundtripInformationSpecifies 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.
exportShapesAsSvgControls whether Shape nodes are converted to SVG images when saving to HTML, MHTML, EPUB or AZW3. Default value is false.
exportTextInputFormFieldAsTextControls how text input form fields are saved to HTML or MHTML. Default value is false.
exportTocPageNumbersSpecifies whether to write page numbers to table of contents when saving HTML, MHTML and EPUB. Default value is false.
exportXhtmlTransitionalSpecifies 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 (HtmlVersion.Html5) the DOCTYPE declaration is always written.
fontResourcesSubsettingSizeThresholdControls which font resources need subsetting when saving to HTML, MHTML or EPUB. Default is 0.
fontSavingCallbackAllows to control how fonts are saved when a document is saved to HTML, MHTML or EPUB.
fontsFolderSpecifies the physical folder where fonts are saved when exporting a document to HTML. Default is an empty string.
fontsFolderAliasSpecifies the name of the folder used to construct font URIs written into an HTML document. Default is an empty string.
htmlVersionSpecifies version of HTML standard that should be used when saving the document to HTML or MHTML. Default value is HtmlVersion.Xhtml.
imageResolutionSpecifies the output resolution for images when exporting to HTML, MHTML or EPUB. Default is 96 dpi.
imageSavingCallbackAllows to control how images are saved when a document is saved to HTML, MHTML or EPUB.
imagesFolderSpecifies the physical folder where images are saved when exporting a document to HTML format. Default is an empty string.
imagesFolderAliasSpecifies the name of the folder used to construct image URIs written into an HTML document. Default is an empty string.
imlRenderingModeGets or sets a value determining how ink (InkML) objects are rendered.
(Inherited from SaveOptions)
memoryOptimizationGets or sets value determining if memory optimization should be performed before saving the document. Default value for this property is false.
(Inherited from SaveOptions)
metafileFormatSpecifies in what format metafiles are saved when exporting to HTML, MHTML, or EPUB. Default value is HtmlMetafileFormat.Png, meaning that metafiles are rendered to raster PNG images.
navigationMapLevelSpecifies the maximum level of headings populated to the navigation map when exporting to EPUB, MOBI, or AZW3 formats. Default value is 3.
officeMathOutputModeControls how OfficeMath objects are exported to HTML, MHTML or EPUB. Default value is HtmlOfficeMathOutputMode.Image.
prettyFormatWhen true, pretty formats output where applicable. Default value is false.
(Inherited from SaveOptions)
removeJavaScriptFromLinksSpecifies whether JavaScript will be removed from links. Default is false.
replaceBackslashWithYenSignSpecifies whether backslash characters should be replaced with yen signs. Default value is false.
resolveFontNamesSpecifies whether font family names used in the document are resolved and substituted according to Document.fontSettings when being written into HTML-based formats.
resourceFolderSpecifies 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.
resourceFolderAliasSpecifies the name of the folder used to construct URIs of all resources written into an HTML document. Default is an empty string.
saveFormatSpecifies the format in which the document will be saved if this save options object is used. Can be SaveFormat.Html, SaveFormat.Mhtml, SaveFormat.Epub, SaveFormat.Azw3 or SaveFormat.Mobi.
scaleImageToShapeSizeSpecifies whether images are scaled by Aspose.Words to the bounding shape size when exporting to HTML, MHTML or EPUB. Default value is true.
tableWidthOutputModeControls how table, row and cell widths are exported to HTML, MHTML or EPUB. Default value is HtmlElementSizeOutputMode.All.
tempFolderSpecifies 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.
(Inherited from SaveOptions)
updateAmbiguousTextFontDetermines whether the font attributes will be changed according to the character code being used.
(Inherited from SaveOptions)
updateCreatedTimePropertyGets or sets a value determining whether the BuiltInDocumentProperties.createdTime property is updated before saving. Default value is false;
(Inherited from SaveOptions)
updateFieldsGets 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.
(Inherited from SaveOptions)
updateLastPrintedPropertyGets or sets a value determining whether the BuiltInDocumentProperties.lastPrinted property is updated before saving.
(Inherited from SaveOptions)
updateLastSavedTimePropertyGets or sets a value determining whether the BuiltInDocumentProperties.lastSavedTime property is updated before saving.
(Inherited from SaveOptions)
useAntiAliasingGets or sets a value determining whether or not to use anti-aliasing for rendering.
(Inherited from SaveOptions)
useHighQualityRenderingGets or sets a value determining whether or not to use high quality (i.e. slow) rendering algorithms.
(Inherited from SaveOptions)

Methods

NameDescription
createSaveOptions(saveFormat)Creates a save options object of a class suitable for the specified save format.
(Inherited from SaveOptions)
createSaveOptions(fileName)Creates a save options object of a class suitable for the file extension specified in the given file name.
(Inherited from SaveOptions)

Examples

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

let doc = new aw.Document(base.myDir + "Rendering.docx");

// Use a SaveOptions object to specify the encoding for a document that we will save.
let saveOptions = new aw.Saving.HtmlSaveOptions();
saveOptions.saveFormat = aw.SaveFormat.Epub;
saveOptions.encoding = "utf-8";

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

// Specify that we want to export document properties.
saveOptions.exportDocumentProperties = true;

doc.save(base.artifactsDir + "HtmlSaveOptions.Doc2EpubSaveOptions.epub", saveOptions);

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

let doc = new aw.Document(base.myDir + "Rendering.docx");

let imagesDir = path.join(base.artifactsDir, "SaveHtmlWithOptions");

if (fs.existsSync(imagesDir)) {
  fs.rmSync(imagesDir, { recursive: true, force: true });
}

fs.mkdirSync(imagesDir, { recursive: true });

// Set an option to export form fields as plain text instead of HTML input elements.
let options = new aw.Saving.HtmlSaveOptions(aw.SaveFormat.Html);
options.exportTextInputFormFieldAsText = true;
options.imagesFolder = imagesDir;

doc.save(base.artifactsDir + "HtmlSaveOptions.SaveHtmlWithOptions.html", options);

See Also