GemBox.Document
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    HtmlSaveOptions Class

    Namespace:
    GemBox.Document
    Assembly:
    GemBox.Document.dll

    Represents options for saving to HyperText Markup Language (HTML) format.

    • C#
    • VB.NET
    public sealed class HtmlSaveOptions : SaveOptions
    Public NotInheritable Class HtmlSaveOptions
        Inherits SaveOptions
    Inheritance:
    System.Object
    SaveOptions
    HtmlSaveOptions
    Remarks

    Pictures are exported only if one of this is true:

    • HtmlType is Mhtml
    • Save(String) or Save(String, SaveOptions) overload is used
    • FilesDirectoryPath or EmbedImages is specified

    Constructors

    HtmlSaveOptions()

    Initializes a new instance of the HtmlSaveOptions class.

    • C#
    • VB.NET
    public HtmlSaveOptions()
    Public Sub New

    Properties

    ContentType

    Gets the content-type for HTML file format:

    • message/rfc822 if HtmlType is Mhtml, otherwise
    • "text/html; charset=" + Encoding.System.Text.Encoding.WebName.
    • C#
    • VB.NET
    public override string ContentType { get; }
    Public Overrides ReadOnly Property ContentType As String
    Property Value
    System.String

    The content-type for HTML file format.

    Overrides
    SaveOptions.ContentType

    EmbedImages

    Gets or sets a value indicating whether images are embedded directly within the HTML file in form of Base64 encoding.

    • C#
    • VB.NET
    public bool EmbedImages { get; set; }
    Public Property EmbedImages As Boolean
    Property Value
    System.Boolean

    true if images are embedded directly within the HTML file in form of Base64 encoding; otherwise, false.

    Remarks

    If the value of this property is true then each image element will contain raw image data in its source attribute. This value doesn't change the pictures export behavior when using Mhtml.

    EmbedOnlineVideos

    Gets or sets a value indicating whether Pictures whose OnlineVideo is not null are exported as EmbeddedHtml.

    • C#
    • VB.NET
    public bool EmbedOnlineVideos { get; set; }
    Public Property EmbedOnlineVideos As Boolean
    Property Value
    System.Boolean

    true if Pictures whose OnlineVideo is not null are exported as EmbeddedHtml; otherwise, false.

    Encoding

    Gets or sets the encoding for the HTML file.

    • C#
    • VB.NET
    public Encoding Encoding { get; set; }
    Public Property Encoding As Encoding
    Property Value
    System.Text.Encoding

    The encoding for the HTML file.

    Exceptions
    System.ArgumentNullException

    Value is set to null.

    FilesDirectoryPath

    Gets or sets the physical directory where Pictures will be saved.

    • C#
    • VB.NET
    public string FilesDirectoryPath { get; set; }
    Public Property FilesDirectoryPath As String
    Property Value
    System.String

    The physical directory where Pictures will be saved.

    Remarks

    If value is null or System.String.Empty and HTML export is called with Save(String) or Save(String, SaveOptions) overload, value will be automatically set to htmlFileNameWithoutExtension + "_files". This directory will be created in the same location as HTML file.

    FilesDirectorySrcPath

    Gets or sets the relative directory that will be used when referencing Pictures in the HTML.

    • C#
    • VB.NET
    public string FilesDirectorySrcPath { get; set; }
    Public Property FilesDirectorySrcPath As String
    Property Value
    System.String

    The relative directory that will be used when referencing Pictures in the HTML.

    Remarks

    If value is null or System.String.Empty and HTML export is called with Save(String) or Save(String, SaveOptions) overload, value will be automatically set to htmlFileNameWithoutExtension + "_files".

    HtmlType

    Gets or sets the type of export.

    • C#
    • VB.NET
    public HtmlType HtmlType { get; set; }
    Public Property HtmlType As HtmlType
    Property Value
    HtmlType

    The HtmlType value for type of export.

    Remarks

    For Html and HtmlInline values, pictures will be exported only if Save(String) or Save(String, SaveOptions) overload is used or if FilesDirectoryPath is specified or if EmbedImages is set to true.

    For Mhtml value, pictures are always exported.

    IgnoreStyles

    Gets or sets a value indicating whether to ignore styling information when generating an HTML.

    Use this property if you want that generated HTML contains only HTML elements without any style attributes.

    Default value is false meaning that document element's styling information will be written to output HTML.

    • C#
    • VB.NET
    public bool IgnoreStyles { get; set; }
    Public Property IgnoreStyles As Boolean
    Property Value
    System.Boolean

    true if styling information should be ignored when generating an HTML; otherwise, false.

    KeepImageLinks

    Gets or sets a value indicating whether to keep linked images as links.

    • C#
    • VB.NET
    public bool KeepImageLinks { get; set; }
    Public Property KeepImageLinks As Boolean
    Property Value
    System.Boolean

    true if linked images should be kept as links; otherwise, false.

    Remarks

    If the value is set to true, all linked images in the model will not be downloaded to FilesDirectoryPath. They will be exported to HTML with original source paths. Otherwise, images will be downloaded and their links will be replaced with local paths.

    UseContentIdHeaders

    Gets or sets a value indicating whether CID (Content-ID) should be used to reference images within MHTML file.

    • C#
    • VB.NET
    public bool UseContentIdHeaders { get; set; }
    Public Property UseContentIdHeaders As Boolean
    Property Value
    System.Boolean

    true to reference images with Content-ID headers, false to reference images with Content-Location headers.

    Remarks

    Some MHTML viewers fail to load image resources when they're referenced with Content-Location headers, for example MS Outlook. In that case, try exporting the images with CID references by setting UseContentIdHeaders to true.

    UseSemanticElements

    Gets or sets a value indicating whether to use semantic elements when generating an HTML.

    To maintain backward compatibility, default value is false.

    The type of the semantic element that will be used is inferred either from a document element type, some of its properties or its style. For example, <h1> to <h6> HTML elements will be used for paragraphs with 'Heading 1' to 'Heading 6' styles. This feature is currently not fully implemented. Support for various HTML semantic elements (especially those defined in HTML5) will be added gradually.

    • C#
    • VB.NET
    public bool UseSemanticElements { get; set; }
    Public Property UseSemanticElements As Boolean
    Property Value
    System.Boolean

    true if semantic HTML elements should be used when generating an HTML; otherwise, false.

    Inherited Properties

    DocxDefault

    Gets the default saving options for Microsoft Word file format. Word file will be saved in Docx format.

    (Inherited from SaveOptions)

    HtmlDefault

    Gets the default saving options for HyperText Markup Language (HTML) format.

    (Inherited from SaveOptions)

    ImageDefault

    Gets the default saving options for image file format. Image will be saved in Bmp format.

    (Inherited from SaveOptions)

    OdtDefault

    Gets the default saving options for Open Document file format.

    (Inherited from SaveOptions)

    PageCount

    Gets or sets the number of pages which should be saved.

    (Inherited from SaveOptions)

    PageNumber

    Gets or sets the zero-based page number of the document's first page which should be saved.

    (Inherited from SaveOptions)

    PdfDefault

    Gets the default saving options for Portable Document Format (PDF).

    (Inherited from SaveOptions)

    RtfDefault

    Gets the default saving options for Rich Text (RTF) format.

    (Inherited from SaveOptions)

    TxtDefault

    Gets the default saving options for Plain Text (TXT) format.

    (Inherited from SaveOptions)

    XmlDefault

    Gets the default saving options for XML file format.

    (Inherited from SaveOptions)

    XpsDefault

    Gets the default saving options for XML Paper Specification (XPS) format.

    (Inherited from SaveOptions)

    Examples

    Convert between Word files and HTML pages in C# and VB.NET
    Convert Word and HTML to PDF in C# and VB.NET
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.