IExternalResourceHandler

IExternalResourceHandler interface

Decides, for each resource a document asks an engine to load, whether it is loaded, skipped or supplied.

public interface IExternalResourceHandler

Methods

Name Description
OnLoading(ExternalResourceLoadingArgs) Called before a resource is loaded.

Remarks

Set an implementation on ExternalResourceHandler. For every resource, SkipExternalResources and WhitelistedResources decide first, then OnLoading is called with Skipped set to that decision. The handler can keep it, set Skipped to false to load the resource or to true to skip it, or set Data to supply its content, in which case nothing is requested.

The handler is also called for content the document carries, such as data: URIs and cid: parts, with Skipped set to false; skipping one removes it from the output.

UNC paths and javascript: or vbscript: references are offered with Skipped set to true and never load, whatever the handler sets. While scripts are not executed, no script file is offered.

The same resource can be offered more than once in one conversion, for example an image in an HTML page converted to a spreadsheet. It loads only when every call allows it.

For some formats the handler can allow or skip a resource but Data has no effect; for XBRL and inline XBRL it can only skip, and while SkipExternalResources is false it is not called for them. A 3D document reads its dependencies as local files only, so a remote dependency can be supplied only through Data.

While SkipExternalResources is true, the document type declaration of an XML-based document is removed before an engine reads it. Its external DTD and external entities are offered with Skipped set to true, and the declaration is kept only when the handler allows each of them. A declaration with neither is removed without an offer.

If the handler throws, that resource is skipped, and the operation throws GroupDocsConversionException with the handler’s exception as its inner exception.

The handler can be called from several threads at once, on threads other than the one that started the operation, so it must be thread-safe.

See Also