←Select platform

DomainWhitelist Property

Summary

Optional domain whitelist to be used when loading HTML files.

Syntax
C#
VB
C++
public string DomainWhitelist { get; set; } 
Public Property DomainWhitelist() As String 
   Get 
   Set 
public:  
   property String^ DomainWhitelist 
   { 
      String^ get() 
      void set(String^ value) 
   } 

Property Value

Optional domain whitelist to be used when loading HTML files. The default value is null.

Remarks

DomainWhitelist can be used to allow loading resources from only certain domains when loading HTML files. The engine will loop through each resource in the input HTML and clears it if it does not belong to the specified domains.

By default, the value of DomainWhitelist is null and all domains are allowed. To allow domains only from certain domains, add them to this property as a string separated by the pipe (|) character.

The engine will remove the domains of the following HTML elements: <image> or <a> elements by selecting and clearing the src or href attributes. Therefore, domains not in the whitelist are not reached.

For instance, assume the following HTML file:

HTML
<!DOCTYPE html> 
<html> 
<head> 
    <title>Test</title> 
</head> 
<body> 
   <p>Image1</p> 
   <img src="https://www.domain1.com/images/image1.jpg"  title="DomainWhitelist Property"/> 
   <p>Image2</p> 
   <img src="https://www.domain2.com/images/image2.jpg"  title="DomainWhitelist Property"/> 
   <p>Image3</p> 
   <img src="https://www.domain3.com/images/image3.jpg"  title="DomainWhitelist Property"/> 
</body> 
</html> 

When loading this file as raster or SVG image, the HTML engine will downloads all images and renders them into the output.

To enable resources only from domain1, set the value of DomainWhitelist as follows:

C#
rasterCodecsInstance.Options.Html.Load.DomainWhitelist = "domain1.com"; 

Re-load the file and notice how only image1 is loaded and rendered.

To enable resources only from domain1 and domain2, set the value of DomainWhitelist as follows:

C#
rasterCodecsInstance.Options.Html.Load.DomainWhitelist = "domain1.com|domain2.com"; 

Re-load the file and notice how image1 and image 2 are loaded and rendered.

To disable all resources from external domains, set DomainWhitelist to a value that will always fail the test, for example:

C#
rasterCodecsInstance.Options.Html.Load.DomainWhitelist = "does-not-exist-domain"; 
Re-load the file and notice that no images are loaded and rendered.

Example

For an example, refer to CodecsHtmlOptions.

Requirements

Target Platforms

Help Version 20.0.2019.12.5
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly