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(save_format)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
allow_embedding_post_script_fontsGets 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)
allow_negative_indentSpecifies whether negative left and right indents of paragraphs are normalized when saving to HTML, MHTML or EPUB. Default value is False.
css_class_name_prefixSpecifies 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.
css_saving_callbackAllows to control how CSS styles are saved when a document is saved to HTML, MHTML or EPUB.
css_style_sheet_file_nameSpecifies 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.
css_style_sheet_typeSpecifies 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.
default_templateGets or sets path to default template (including filename). Default value for this property is empty string ().
(Inherited from SaveOptions)
dml_3d_effects_rendering_modeGets or sets a value determining how 3D effects are rendered.
(Inherited from SaveOptions)
dml_effects_rendering_modeGets or sets a value determining how DrawingML effects are rendered.
(Inherited from SaveOptions)
dml_rendering_modeGets or sets a value determining how DrawingML shapes are rendered.
(Inherited from SaveOptions)
document_part_saving_callbackAllows to control how document parts are saved when a document is saved to HTML or EPUB.
document_split_criteriaSpecifies 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.HEADING_PARAGRAPH for EPUB and AZW3.
document_split_heading_levelSpecifies 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 new UTF8Encoding(false) (UTF-8 without BOM).
export_cid_urls_for_mhtml_resourcesSpecifies whether to use CID (Content-ID) URLs to reference resources (images, fonts, CSS) included in MHTML documents. Default value is False.
export_document_propertiesSpecifies whether to export built-in and custom document properties to HTML, MHTML or EPUB. Default value is False.
export_drop_down_form_field_as_textControls how drop-down form fields are saved to HTML or MHTML. Default value is False.
export_font_resourcesSpecifies whether font resources should be exported to HTML, MHTML or EPUB. Default is False.
export_fonts_as_base64Specifies whether fonts resources should be embedded to HTML in Base64 encoding. Default is False.
export_generator_nameWhen True, causes the name and version of Aspose.Words to be embedded into produced files. Default value is True.
(Inherited from SaveOptions)
export_headers_footers_modeSpecifies how headers and footers are output to HTML, MHTML or EPUB. Default value is ExportHeadersFootersMode.PER_SECTION for HTML/MHTML and ExportHeadersFootersMode.NONE for EPUB.
export_images_as_base64Specifies whether images are saved in Base64 format to the output HTML, MHTML or EPUB. Default is False.
export_language_informationSpecifies whether language information is exported to HTML, MHTML or EPUB. Default is False.
export_list_labelsControls how list labels are output to HTML, MHTML or EPUB. Default value is ExportListLabels.AUTO.
export_original_url_for_linked_imagesSpecifies whether original URL should be used as the URL of the linked images. Default value is False.
export_page_marginsSpecifies whether page margins is exported to HTML, MHTML or EPUB. Default is False.
export_page_setupSpecifies whether page setup is exported to HTML, MHTML or EPUB. Default is False.
export_relative_font_sizeSpecifies whether font sizes should be output in relative units when saving to HTML, MHTML or EPUB. Default is False.
export_roundtrip_informationSpecifies 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.
export_shapes_as_svgControls whether Shape nodes are converted to SVG images when saving to HTML, MHTML, EPUB or AZW3. Default value is False.
export_text_input_form_field_as_textControls how text input form fields are saved to HTML or MHTML. Default value is False.
export_toc_page_numbersSpecifies whether to write page numbers to table of contents when saving HTML, MHTML and EPUB. Default value is False.
export_xhtml_transitionalSpecifies 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.
font_resources_subsetting_size_thresholdControls which font resources need subsetting when saving to HTML, MHTML or EPUB. Default is 0.
font_saving_callbackAllows to control how fonts are saved when a document is saved to HTML, MHTML or EPUB.
fonts_folderSpecifies the physical folder where fonts are saved when exporting a document to HTML. Default is an empty string.
fonts_folder_aliasSpecifies the name of the folder used to construct font URIs written into an HTML document. Default is an empty string.
html_versionSpecifies version of HTML standard that should be used when saving the document to HTML or MHTML. Default value is HtmlVersion.XHTML.
image_resolutionSpecifies the output resolution for images when exporting to HTML, MHTML or EPUB. Default is 96 dpi.
image_saving_callbackAllows to control how images are saved when a document is saved to HTML, MHTML or EPUB.
images_folderSpecifies the physical folder where images are saved when exporting a document to HTML format. Default is an empty string.
images_folder_aliasSpecifies the name of the folder used to construct image URIs written into an HTML document. Default is an empty string.
iml_rendering_modeGets or sets a value determining how ink (InkML) objects are rendered.
(Inherited from SaveOptions)
memory_optimizationGets or sets value determining if memory optimization should be performed before saving the document. Default value for this property is False.
(Inherited from SaveOptions)
metafile_formatSpecifies 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.
navigation_map_levelSpecifies the maximum level of headings populated to the navigation map when exporting to EPUB, MOBI, or AZW3 formats. Default value is 3.
office_math_output_modeControls how OfficeMath objects are exported to HTML, MHTML or EPUB. Default value is HtmlOfficeMathOutputMode.IMAGE.
pretty_formatWhen True, pretty formats output where applicable. Default value is False.
(Inherited from SaveOptions)
progress_callbackCalled during saving a document and accepts data about saving progress.
(Inherited from SaveOptions)
replace_backslash_with_yen_signSpecifies whether backslash characters should be replaced with yen signs. Default value is False.
resolve_font_namesSpecifies whether font family names used in the document are resolved and substituted according to Document.font_settings when being written into HTML-based formats.
resource_folderSpecifies 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.
resource_folder_aliasSpecifies the name of the folder used to construct URIs of all resources written into an HTML document. Default is an empty string.
save_formatSpecifies 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.
scale_image_to_shape_sizeSpecifies whether images are scaled by Aspose.Words to the bounding shape size when exporting to HTML, MHTML or EPUB. Default value is True.
table_width_output_modeControls how table, row and cell widths are exported to HTML, MHTML or EPUB. Default value is HtmlElementSizeOutputMode.ALL.
temp_folderSpecifies the folder for temporary files used when saving to a DOC or DOCX file. By default this property is None and no temporary files are used.
(Inherited from SaveOptions)
update_created_time_propertyGets or sets a value determining whether the BuiltInDocumentProperties.created_time property is updated before saving. Default value is False;
(Inherited from SaveOptions)
update_fieldsGets 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)
update_last_printed_propertyGets or sets a value determining whether the BuiltInDocumentProperties.last_printed property is updated before saving.
(Inherited from SaveOptions)
update_last_saved_time_propertyGets or sets a value determining whether the BuiltInDocumentProperties.last_saved_time property is updated before saving.
(Inherited from SaveOptions)
use_anti_aliasingGets or sets a value determining whether or not to use anti-aliasing for rendering.
(Inherited from SaveOptions)
use_high_quality_renderingGets or sets a value determining whether or not to use high quality (i.e. slow) rendering algorithms.
(Inherited from SaveOptions)

Methods

NameDescription
create_save_options(save_format)Creates a save options object of a class suitable for the specified save format.
(Inherited from SaveOptions)
create_save_options(file_name)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.

doc = aw.Document(MY_DIR + 'Rendering.docx')
# Use a SaveOptions object to specify the encoding for a document that we will save.
save_options = aw.saving.HtmlSaveOptions()
save_options.save_format = aw.SaveFormat.EPUB
save_options.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.
save_options.document_split_criteria = aw.saving.DocumentSplitCriteria.HEADING_PARAGRAPH
# Specify that we want to export document properties.
save_options.export_document_properties = True
doc.save(ARTIFACTS_DIR + 'HtmlSaveOptions.doc2_epub_save_options.epub', save_options)

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

doc = aw.Document(MY_DIR + 'Rendering.docx')
images_dir = os.path.join(ARTIFACTS_DIR, 'SaveHtmlWithOptions')
if os.path.exists(images_dir):
    shutil.rmtree(images_dir)
os.makedirs(images_dir)
# Set an option to export form fields as plain text instead of HTML input elements.
options = aw.saving.HtmlSaveOptions(aw.SaveFormat.HTML)
options.export_text_input_form_field_as_text = True
options.images_folder = images_dir
doc.save(ARTIFACTS_DIR + 'HtmlSaveOptions.image_folder.html', options)

See Also