It is often helpful to have different configurations based on the environment where the application is running. For example, you may wish to configure the scripts policy, override document style applying a custom user stylesheet, or handle any web requests from the application. Aspose.HTML provides the Configuration object that can be used exactly for these purposes.
A sandboxing flag set is a set of zero or more of the flags, which are used to restrict the abilities that potentially untrusted resources.
The following example demonstrates how to mark ‘Scripts’ as an untrusted resource. As a result, ‘Scripts’ will be disabled during the application execution.
All important functional is grouped into separated services for usability purpose and located into Aspose.Html.Services namespace.
User Agent Service
This service allows you to specify a custom user stylesheet, a primary character set for the document, language and fonts settings.
User Style Sheet
The user is able to specify a custom style information for a particular document. This information applies to the document according to the cascading rules and may affect the presentation of the document. The next code snippet shows how to use the UserStyleSheet property:
In order to parse and display an HTML document correctly, the application must know what character-set (encoding) is using for the document. If the character encoding is not directly specified in the header of the document, Aspose.HTML uses UTF-8, which is defined as the default for HTML5 specification. However, if you are sure that your HTML document is written using different from UTF-8 encoding, you can specify it manually, as it follows.
Set Path to the Font Folder
For a situation when you need to use the custom fonts instead of the fonts installed on OS, you can set the path to your custom folder, as it follows.
INetworkService allows you to control all incoming/outcoming traffic and implement your custom message handlers. It can be used for different purposes, such as: create custom caching mechanism, trace/logging request messages, etc.
The following example demonstrates how to use message handlers to log information about unreachable resources. First of all, you need to create a custom message handler:
and use it, as it follows: