HtmlToMarkdownConverter Class

Converts a web page at a given URL or a HTML string to Markdown. The headings, paragraphs, lists, tables, links, images, quotes and code of the HTML document are written with the Markdown syntax. The resulting Markdown text can be returned as a string or written to a file. The HTML to Markdown conversion requires the same runtime as the HTML to PDF conversion

Definition

Namespace: EvoPdf.Next
Assembly: EvoPdf.Next (in EvoPdf.Next.dll) Version: 15.1.0
C#
public class HtmlToMarkdownConverter
Inheritance
Object    HtmlToMarkdownConverter

Constructors

HtmlToMarkdownConverter Creates a HTML to Markdown converter object with default options

Properties

AllowInsecureContent Allows loading insecure HTTP content in secure HTTPS pages. The default value is false
AuthenticationOptions This property can be set with a username and password to authenticate with the web server before accessing the HTML page
BlockedHosts A list of hosts the converter is not allowed to access when loading the page and its resources. An entry also blocks the subdomains of the host. Hosts are compared by name, so blocking an IP address does not block the host names that resolve to it
ConversionDelay An additional time in seconds to wait for asynchronous items to be completely loaded or for a web page redirect to finish before starting the conversion in HTML to Markdown converter. It is used when the conversion triggering mode is Auto. Default value is 0
ConvertedElementsSelector Gets or sets the CSS selector used to identify the elements to include in the Markdown output. If this is not set or matches no elements, the entire HTML document will be converted
DisableWebSecurity Disables web security features such as CORS and same-origin policy. The default value is false
EnableElevatedRendering Enables the HTML renderer to inherit the elevated privileges of the application using the library when the application is running elevated on Windows. The default value is true
EnableSiteIsolation Enables site isolation, which renders the frames of a page that come from different sites in separate processes. The default value is false
EnableSoftwareGpuRendering When set to true, hardware GPU rendering is disabled and software rendering is used. When set to false, hardware GPU rendering is allowed and is further controlled by GpuRenderingEnabled and GpuCompositingEnabled. The default value is false
EncodeHttpPostFields When true (default), the converter applies application/x-www-form-urlencoded encoding to the names and values in the HttpPostFields collection when building the POST request body. Set to false only if the names and values are already form-urlencoded
ExcludedElementsSelector Gets or sets the CSS selector used to identify elements that should be excluded from the Markdown output
GpuCompositingEnabled A flag indicating if hardware GPU compositing is enabled in the HTML to Markdown converter. This property has effect only when EnableSoftwareGpuRendering is false. The default value is false
GpuRenderingEnabled A flag indicating if hardware GPU rendering is enabled in the HTML to Markdown converter. This property has effect only when EnableSoftwareGpuRendering is false. The default value is false
HtmlLoaderFilePath Sets the full path of the HTML loader file
HtmlViewerHeight Gets or sets the HTML viewer height in pixels. The default value is 2048 pixels
HtmlViewerWidth Gets or sets the HTML viewer width in pixels. A responsive HTML document shows the content it has for this width. The default value is 1024 pixels
HttpPostFields Returns the collection of HTTP POST fields to be used when accessing a web page in HTML to Markdown converter. Each entry contains a parameter name and value. By default the converter form-urlencodes the names and values when building the POST body; see EncodeHttpPostFields if the values are already encoded
HttpRequestCookies Gets a collection of custom HTTP cookies to be sent by the HTML to Markdown converter to the web server when the web page to convert and the resources referenced by the web page are requested
HttpRequestHeaders Gets a collection of custom HTTP headers to be sent by the HTML to Markdown converter to the web server when the web page is requested from a URL
IgnoreCertificateErrors Ignores certificate validation errors such as expired, self-signed or invalid certificates. The default value is false
ImageMode Gets or sets how the images of the HTML document are written in Markdown. The default value is Link
IncludeLinks A flag indicating if the links of the HTML document are written as Markdown links. When false only the text of the links is written. The default value is true
JavaScriptEnabled A flag indicating if JavaScript execution is enabled in HTML to Markdown converter. The default is true
LazyImagesLoadMode The lazy content loading mode used by the HTML to Markdown converter. This property has effect only if LoadLazyImages is also true. The default mode is Browser
LoadLazyImages A flag indicating if the content loaded only when it becomes visible, like the lazy images, is loaded before the conversion. The default value is true
LocalFilesEnabled This property controls if the converter can convert local file. The default value is true
LocalhostEnabled This property controls if the converter can convert URLs from localhost. The default value is true
MaxHtmlViewerHeight Gets or sets the maximum HTML viewer height in pixels used to load the lazy content. Value 0 means unlimited. The default value is 32000 pixels
MaxJsRedirects Gets or sets the maximum number of JavaScript-initiated redirects to follow in the main frame after the initial page load and before starting the conversion. Set this value to 0 to disable following JavaScript redirects. The default value is 10
MediaType Gets or sets the media type of the HTML document used by the HTML to Markdown converter. By default is not set to any value and the 'screen' CSS media is used
NavigationTimeout The HTML to Markdown converter navigation timeout in seconds. Default value is 120
PersistentHttpRequestHeaders This property can be set to true to send the custom headers defined by the HttpRequestHeaders property whenever an external resource referenced by the web page is requested. The default value of this property is false
ProxyOptions The network proxy used to load the HTML page and its resources. By default no proxy is set and the network settings of the system are used
ScriptToExecuteAfterLoad A JavaScript code to execute immediately after the page was loaded. It can be used to automatically click buttons or for other operations before conversion. By default this property is null
TriggeringMode The conversion triggering mode used by the HTML to Markdown converter. The default value is Auto
UncPathEnabled This property controls if the converter can convert files from local network. The default value is true
WaitForAfterLoadScript A flag indicating if the HTML to Markdown converter should wait for the script specified by ScriptToExecuteAfterLoad to finish execution before continuing conversion. By default, this flag is set to false and the conversion continues immediately after the script is started
WaitForSelector Gets or sets the CSS selector of an element to wait for before starting the conversion. The conversion starts when the HTML document contains an element matching the selector and ends with a navigation timeout error if no such element appears. By default this property is null
WriteHtmlToFileBeforeConvert When true, the HTML string is first written to a temporary file before conversion. When false, the HTML string is passed directly to the converter without file system involvement. The default value is false

Methods

ConvertHtml Converts a HTML string to Markdown using a base URL to resolve external resources and returns the Markdown text. A new instance of HtmlToMarkdownConverter must be created for each call to this method
ConvertHtmlAsync Asynchronously converts a HTML string to Markdown using a base URL to resolve external resources and returns the Markdown text. A new instance of HtmlToMarkdownConverter must be created for each call to this method
ConvertHtmlToFile Converts a HTML string to Markdown using a base URL to resolve external resources and writes the Markdown text into a file encoded as UTF-8. A new instance of HtmlToMarkdownConverter must be created for each call to this method
ConvertHtmlToFileAsync Asynchronously converts a HTML string to Markdown using a base URL to resolve external resources and writes the Markdown text into a file encoded as UTF-8. A new instance of HtmlToMarkdownConverter must be created for each call to this method
ConvertUrl Converts an URL to Markdown and returns the Markdown text. A new instance of HtmlToMarkdownConverter must be created for each call to this method
ConvertUrlAsync Asynchronously converts an URL to Markdown and returns the Markdown text. A new instance of HtmlToMarkdownConverter must be created for each call to this method
ConvertUrlToFile Converts an URL to Markdown and writes the Markdown text into a file encoded as UTF-8. A new instance of HtmlToMarkdownConverter must be created for each call to this method
ConvertUrlToFileAsync Asynchronously converts an URL to Markdown and writes the Markdown text into a file encoded as UTF-8. A new instance of HtmlToMarkdownConverter must be created for each call to this method
Equals
(Inherited from Object)
Finalize
(Inherited from Object)
GetHashCode
(Inherited from Object)
GetType
(Inherited from Object)
MemberwiseClone
(Inherited from Object)
ToString
(Inherited from Object)

See Also