Class HTMLExport
Represents the conversion implementation of Word document as HTML file.
Inheritance
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Base.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()
SaveAsXhtml(WordDocument, String)
Saves the Word document as XHTML file.
Declaration
public void SaveAsXhtml(WordDocument doc, string fileName)
Parameters
Type | Name | Description |
---|---|---|
WordDocument | doc | The WordDocument to be saved as html. |
System.String | fileName | The string that specifies the name to save the html file. |
Examples
The following code example demonstrates how to convert Word to XHTML file.
//Loads an existing document
WordDocument document = new WordDocument("Template.docx");
HTMLExport export = new HTMLExport();
//Save the document as Xhtml file
export.SaveAsXhtml(document, "WordtoXHtml.html");
document.Close();
'Loads an existing document
Dim document As New WordDocument("Template.docx")
Dim export As New HTMLExport()
'Save the document as Xhtml file
export.SaveAsXhtml(document, "WordtoXHtml.html")
document.Close()
SaveAsXhtml(WordDocument, String, Encoding)
Saves the Word document as XHTML file with specified encoding.
Declaration
public void SaveAsXhtml(WordDocument doc, string fileName, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
WordDocument | doc | The WordDocument to be saved as html. |
System.String | fileName | The string that specifies the name 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 with specified encoding.
//Loads an existing document
WordDocument document = new WordDocument("Template.docx");
HTMLExport export = new HTMLExport();
//Save the document as Xhtml file
export.SaveAsXhtml(document, "WordtoXHtml.html", Encoding.Unicode);
document.Close();
'Loads an existing document
Dim document As New WordDocument("Template.docx")
Dim export As New HTMLExport()
'Save the document as Xhtml file
export.SaveAsXhtml(document, "WordtoXHtml.html", Encoding.Unicode)
document.Close()