Xamarin.Android

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class HTMLExport

    Show / Hide Table of Contents

    Class HTMLExport

    Represents the conversion implementation of Word document as HTML file.

    Inheritance
    System.Object
    HTMLExport
    Namespace: Syncfusion.DocIO.DLS
    Assembly: Syncfusion.DocIO.Portable.dll
    Syntax
    public class HTMLExport : Object
    Remarks

    This class, its properties and methods are not supported in Silverlight, Windows Phone, Universal, Universal Windows Platform and Xamarin applications.

    Examples

    The following code example demonstrates how to convert Word to HTML file.

    private void Button1_Click(System.Object sender, System.EventArgs e)
    {
        //Loads an existing document
        WordDocument document = new WordDocument("Template.docx");
        HTMLExport export = new HTMLExport();
        //The images in the input document will be copied to this folder
        document.SaveOptions.HtmlExportImagesFolder = @"D:\Data\";
        //The headers and footers in the input will be exported
        document.SaveOptions.HtmlExportHeadersFooters = true;
        //Export the text form fields as editable
        document.SaveOptions.HtmlExportTextInputFormFieldAsText = false;
        //Set the style sheet type
        document.SaveOptions.HtmlExportCssStyleSheetType = CssStyleSheetType.External;
        //Set name for style sheet
        document.SaveOptions.HtmlExportCssStyleSheetFileName = "UserDefinedFileName.css";
        //Set the use absolute path as true
        export.UseAbsolutePath = true;
        //Save the document as html file
        export.SaveAsXhtml(document, "WordtoHtml.html");
        document.Close();
    }
    Private Sub button_Click(sender As Object, e As EventArgs)
        'Loads an existing document
        Dim document As New WordDocument("Template.docx")
        Dim export As New HTMLExport()
        'The images in the input document will be copied to this folder
        document.SaveOptions.HtmlExportImagesFolder = "D:\Data\"
        'The headers and footers in the input will be exported
        document.SaveOptions.HtmlExportHeadersFooters = True
        'Export the text form fields as editable
        document.SaveOptions.HtmlExportTextInputFormFieldAsText = False
        'Set the style sheet type
        document.SaveOptions.HtmlExportCssStyleSheetType = CssStyleSheetType.External
        'Set name for style sheet
        document.SaveOptions.HtmlExportCssStyleSheetFileName = "UserDefinedFileName.css"
        'Set the use absolute path as true
        export.UseAbsolutePath = True;
        'Save the document as html file
        export.SaveAsXhtml(document, "WordtoHtml.html")
        document.Close()
    End Sub

    Constructors

    HTMLExport()

    Declaration
    public HTMLExport()

    Properties

    UseAbsolutePath

    Gets or sets the value indicating whether to use the absolute path.

    Declaration
    public bool UseAbsolutePath { get; set; }
    Property Value
    Type Description
    System.Boolean

    True if absolute path is specified, otherwise false.

    Methods

    SaveAsXhtml(WordDocument, Stream)

    Saves the Word document as XHTML file in a stream.

    Declaration
    public void SaveAsXhtml(WordDocument doc, Stream stream)
    Parameters
    Type Name Description
    WordDocument doc

    The WordDocument to be saved as html.

    System.IO.Stream stream

    The System.IO.Stream to save the html file.

    Examples

    The following code example demonstrates how to convert Word to XHTML file in a stream.

        //Creates a new Word document
        WordDocument document = new WordDocument();
        //Adds new section to the document
        IWSection section = document.AddSection();
        //Adds new paragraph to the section
        IWParagraph paragraph = section.AddParagraph();
        //Adds new text to the paragraph
        paragraph.AppendText("Hello World!");
        HTMLExport export = new HTMLExport();
        MemoryStream stream = new MemoryStream();
        //Save the document as Xhtml file
        export.SaveAsXhtml(document, stream);
        document.Close();
        'Creates a new Word document
        Dim document As New WordDocument()
        'Adds new section to the document
        Dim section As IWSection = document.AddSection()
        'Adds new paragraph to the section
        Dim paragraph As IWParagraph = section.AddParagraph()
        'Adds new text to the paragraph
        paragraph.AppendText("Hello World!")
        Dim export As New HTMLExport() 
        Dim stream As New MemoryStream()
        'Save the document as Xhtml file
        export.SaveAsXhtml(document, stream)
        document.Close()

    SaveAsXhtml(WordDocument, Stream, Encoding)

    Saves the Word document as XHTML file in a stream with specified encoding.

    Declaration
    public void SaveAsXhtml(WordDocument doc, Stream stream, Encoding encoding)
    Parameters
    Type Name Description
    WordDocument doc

    The WordDocument to be saved as html.

    System.IO.Stream stream

    The System.IO.Stream to save the html file.

    System.Text.Encoding encoding

    The character encoding to use.

    Examples

    The following code example demonstrates how to convert Word to XHTML file in a stream with specified encoding.

        //Creates a new Word document
        WordDocument document = new WordDocument();
        //Adds new section to the document
        IWSection section = document.AddSection();
        //Adds new paragraph to the section
        IWParagraph paragraph = section.AddParagraph();
        //Adds new text to the paragraph
        paragraph.AppendText("Hello World!");
        HTMLExport export = new HTMLExport();
        MemoryStream stream = new MemoryStream();
        //Save the document as Xhtml file
        export.SaveAsXhtml(document, stream, Encoding.Unicode);
        document.Close();
        'Creates a new Word document
        Dim document As New WordDocument()
        'Adds new section to the document
        Dim section As IWSection = document.AddSection()
        'Adds new paragraph to the section
        Dim paragraph As IWParagraph = section.AddParagraph()
        'Adds new text to the paragraph
        paragraph.AppendText("Hello World!")
        Dim export As New HTMLExport() 
        Dim stream As New MemoryStream()
        'Save the document as Xhtml file
        export.SaveAsXhtml(document, stream, Encoding.Unicode)
        document.Close()

    See Also

    SaveOptions
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved