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: HtmlSaveOptions → SaveOptions
Constructors
Name | Description |
---|---|
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
Name | Description |
---|---|
allow_embedding_post_script_fonts | Gets or sets a boolean value indicating whether to allow embedding fonts with PostScript outlines when embedding TrueType fonts in a document upon it is saved. The default value is False .(Inherited from SaveOptions) |
allow_negative_indent | Specifies whether negative left and right indents of paragraphs are normalized when saving to HTML, MHTML or EPUB. Default value is False . |
css_class_name_prefix | 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. |
css_saving_callback | Allows to control how CSS styles are saved when a document is saved to HTML, MHTML or EPUB. |
css_style_sheet_file_name | 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. |
css_style_sheet_type | Specifies 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_template | Gets or sets path to default template (including filename). Default value for this property is empty string (). (Inherited from SaveOptions) |
dml_3d_effects_rendering_mode | Gets or sets a value determining how 3D effects are rendered. (Inherited from SaveOptions) |
dml_effects_rendering_mode | Gets or sets a value determining how DrawingML effects are rendered. (Inherited from SaveOptions) |
dml_rendering_mode | Gets or sets a value determining how DrawingML shapes are rendered. (Inherited from SaveOptions) |
document_part_saving_callback | Allows to control how document parts are saved when a document is saved to HTML or EPUB. |
document_split_criteria | Specifies 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_level | Specifies the maximum level of headings at which to split the document. Default value is 2 . |
encoding | Specifies 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_resources | Specifies whether to use CID (Content-ID) URLs to reference resources (images, fonts, CSS) included in MHTML documents. Default value is False . |
export_document_properties | Specifies whether to export built-in and custom document properties to HTML, MHTML or EPUB. Default value is False . |
export_drop_down_form_field_as_text | Controls how drop-down form fields are saved to HTML or MHTML. Default value is False . |
export_font_resources | Specifies whether font resources should be exported to HTML, MHTML or EPUB. Default is False . |
export_fonts_as_base64 | Specifies whether fonts resources should be embedded to HTML in Base64 encoding. Default is False . |
export_generator_name | When 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_mode | Specifies 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_base64 | Specifies whether images are saved in Base64 format to the output HTML, MHTML or EPUB. Default is False . |
export_language_information | Specifies whether language information is exported to HTML, MHTML or EPUB. Default is False . |
export_list_labels | Controls how list labels are output to HTML, MHTML or EPUB. Default value is ExportListLabels.AUTO. |
export_original_url_for_linked_images | Specifies whether original URL should be used as the URL of the linked images. Default value is False . |
export_page_margins | Specifies whether page margins is exported to HTML, MHTML or EPUB. Default is False . |
export_page_setup | Specifies whether page setup is exported to HTML, MHTML or EPUB. Default is False . |
export_relative_font_size | Specifies whether font sizes should be output in relative units when saving to HTML, MHTML or EPUB. Default is False . |
export_roundtrip_information | 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. |
export_shapes_as_svg | Controls 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_text | Controls how text input form fields are saved to HTML or MHTML. Default value is False . |
export_toc_page_numbers | Specifies whether to write page numbers to table of contents when saving HTML, MHTML and EPUB. Default value is False . |
export_xhtml_transitional | 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 (HtmlVersion.HTML5) the DOCTYPE declaration is always written. |
font_resources_subsetting_size_threshold | Controls which font resources need subsetting when saving to HTML, MHTML or EPUB. Default is 0 . |
font_saving_callback | Allows to control how fonts are saved when a document is saved to HTML, MHTML or EPUB. |
fonts_folder | Specifies the physical folder where fonts are saved when exporting a document to HTML. Default is an empty string. |
fonts_folder_alias | Specifies the name of the folder used to construct font URIs written into an HTML document. Default is an empty string. |
html_version | Specifies version of HTML standard that should be used when saving the document to HTML or MHTML. Default value is HtmlVersion.XHTML. |
image_resolution | Specifies the output resolution for images when exporting to HTML, MHTML or EPUB. Default is 96 dpi . |
image_saving_callback | Allows to control how images are saved when a document is saved to HTML, MHTML or EPUB. |
images_folder | Specifies the physical folder where images are saved when exporting a document to HTML format. Default is an empty string. |
images_folder_alias | Specifies the name of the folder used to construct image URIs written into an HTML document. Default is an empty string. |
iml_rendering_mode | Gets or sets a value determining how ink (InkML) objects are rendered. (Inherited from SaveOptions) |
memory_optimization | Gets 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_format | Specifies 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_level | Specifies 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_mode | Controls how OfficeMath objects are exported to HTML, MHTML or EPUB. Default value is HtmlOfficeMathOutputMode.IMAGE. |
pretty_format | When True , pretty formats output where applicable. Default value is False .(Inherited from SaveOptions) |
progress_callback | Called during saving a document and accepts data about saving progress. (Inherited from SaveOptions) |
replace_backslash_with_yen_sign | Specifies whether backslash characters should be replaced with yen signs. Default value is False . |
resolve_font_names | Specifies 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_folder | 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. |
resource_folder_alias | Specifies the name of the folder used to construct URIs of all resources written into an HTML document. Default is an empty string. |
save_format | Specifies 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_size | Specifies 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_mode | Controls how table, row and cell widths are exported to HTML, MHTML or EPUB. Default value is HtmlElementSizeOutputMode.ALL. |
temp_folder | Specifies 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_property | Gets or sets a value determining whether the BuiltInDocumentProperties.created_time property is updated before saving. Default value is False ;(Inherited from SaveOptions) |
update_fields | 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 .(Inherited from SaveOptions) |
update_last_printed_property | Gets or sets a value determining whether the BuiltInDocumentProperties.last_printed property is updated before saving. (Inherited from SaveOptions) |
update_last_saved_time_property | Gets or sets a value determining whether the BuiltInDocumentProperties.last_saved_time property is updated before saving. (Inherited from SaveOptions) |
use_anti_aliasing | Gets or sets a value determining whether or not to use anti-aliasing for rendering. (Inherited from SaveOptions) |
use_high_quality_rendering | Gets or sets a value determining whether or not to use high quality (i.e. slow) rendering algorithms. (Inherited from SaveOptions) |
Methods
Name | Description |
---|---|
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
- module aspose.words.saving
- class SaveOptions