Html |
The HtmlLoadOptions type exposes the following members.
Name | Description | |
---|---|---|
HtmlLoadOptions | Initializes a new instance of the HtmlLoadOptions class. |
Name | Description | |
---|---|---|
BaseAddress | Gets or sets the base address for images with relative location. | |
DefaultFontColor | Gets and sets a default font color for the loading HTML document. Default value: SautinSoft.Document.Color.Black. | |
DefaultFontFamily | Gets and sets a default font family for the loading HTML document. Default value: "Times New Roman". | |
DefaultFontSize | Gets and sets a default font size for the loading HTML document. Default value: 12f. | |
DeviceCategory | Gets and sets all possible device kinds. Default: Screen. | |
DeviceHeight | Gets and sets the height of the device in pixels. Default: 1080. | |
DeviceWidth | Gets and sets the width of the device in pixels. Default: 1920. | |
Encoding | Gets or sets the encoding for the HTML file. | |
FastLoadHtml | Disable all parent css styles of each element and use only last css for element. Default: false. Notice: Attention, this option does not allow to read full html styles correctly. | |
ListIndentsAdjust | Indentation in numbered lists. Adjust list Indents using Tab character, Space, Nothing. Default: Auto. | |
PageSetup | Gets and sets the page setup properties: paper type, orientation, margins and so forth. | |
PreserveHyperlinks | Get and set the value whether to preserve hyperlinks during the HTML loading or skip them. Default value: true. | |
PreserveImages | Preserve images or skip them. Default value: true. | |
TableAutoFit | Gets or sets a value indicating whether the table shall automatically resize to fit contents. Default value: false. |
See Developer Guide: How to load a HTML document
using System; using System.IO; using SautinSoft.Document; namespace Example { class Program { static void Main(string[] args) { // Get your free 100-day key here: // https://sautinsoft.com/start-for-free/ LoadHtmlFromFile(); //LoadHtmlFromStream(); } /// <summary> /// Loads an HTML document into DocumentCore (dc) from a file. /// </summary> /// <remarks> /// Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/load-html-document-net-csharp-vb.php /// </remarks> static void LoadHtmlFromFile() { string filePath = @"..\..\..\example.html"; // The file format is detected automatically from the file extension: ".html". // But as shown in the example below, we can specify HtmlLoadOptions as 2nd parameter // to explicitly set that a loadable document has HTML format. DocumentCore dc = DocumentCore.Load(filePath); if (dc != null) Console.WriteLine("Loaded successfully!"); Console.ReadKey(); } /// <summary> /// Loads an HTML document into DocumentCore (dc) from a MemoryStream. /// </summary> /// <remarks> /// Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/load-html-document-net-csharp-vb.php /// </remarks> static void LoadHtmlFromStream() { // Get document bytes. byte[] fileBytes = File.ReadAllBytes(@"..\..\..\example.html"); DocumentCore dc = null; // Create a MemoryStream using (MemoryStream ms = new MemoryStream(fileBytes)) { // Load a document from the MemoryStream. // Specifying HtmlLoadOptions we explicitly set that a loadable document is HTML. dc = DocumentCore.Load(ms, new HtmlLoadOptions()); } if (dc != null) Console.WriteLine("Loaded successfully!"); Console.ReadKey(); } } }
Imports System Imports System.IO Imports SautinSoft.Document Module Sample Sub Main() LoadHtmlFromFile() 'LoadHtmlFromStream(); End Sub ''' Get your free 100-day key here: ''' https://sautinsoft.com/start-for-free/ ''' <summary> ''' Loads an HTML document into DocumentCore (dc) from a file. ''' </summary> ''' <remarks> ''' Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/load-html-document-net-csharp-vb.php ''' </remarks> Sub LoadHtmlFromFile() Dim filePath As String = "..\..\..\example.html" ' The file format is detected automatically from the file extension: ".html". ' But as shown in the example below, we can specify HtmlLoadOptions as 2nd parameter ' to explicitly set that a loadable document has HTML format. Dim dc As DocumentCore = DocumentCore.Load(filePath) If dc IsNot Nothing Then Console.WriteLine("Loaded successfully!") End If Console.ReadKey() End Sub ''' <summary> ''' Loads an HTML document into DocumentCore (dc) from a MemoryStream. ''' </summary> ''' <remarks> ''' Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/load-html-document-net-csharp-vb.php ''' </remarks> Sub LoadHtmlFromStream() ' Get document bytes. Dim fileBytes() As Byte = File.ReadAllBytes("..\..\..\example.html") Dim dc As DocumentCore = Nothing ' Create a MemoryStream Using ms As New MemoryStream(fileBytes) ' Load a document from the MemoryStream. ' Specifying HtmlLoadOptions we explicitly set that a loadable document is HTML. dc = DocumentCore.Load(ms, New HtmlLoadOptions()) End Using If dc IsNot Nothing Then Console.WriteLine("Loaded successfully!") End If Console.ReadKey() End Sub End Module