## LoadOptions.ResourceLoadingCallback property

Allows to control how external resources (images, style sheets) are loaded when a document is imported from HTML, MHTML.

```csharp
public IResourceLoadingCallback ResourceLoadingCallback { get; set; }
```

## Examples

Shows how to handle external resources when loading Html documents.

```csharp
LoadOptions loadOptions = new LoadOptions();
loadOptions.ResourceLoadingCallback = new HtmlLinkedResourceLoadingCallback();

// When we load the document, our callback will handle linked resources such as CSS stylesheets and images.
Document doc = new Document(MyDir + "Images.html", loadOptions);
doc.Save(ArtifactsDir + "LoadOptions.LoadOptionsCallback.pdf");
```

Shows how to handle external resources when loading Html documents (HtmlLinkedResourceLoadingCallback).

```csharp
/// <summary>
/// Prints the filenames of all external stylesheets and substitutes all images of a loaded html document.
/// </summary>
private class HtmlLinkedResourceLoadingCallback : IResourceLoadingCallback
{
    public ResourceLoadingAction ResourceLoading(ResourceLoadingArgs args)
    {
        switch (args.ResourceType)
        {
            case ResourceType.CssStyleSheet:
                Console.WriteLine($"External CSS Stylesheet found upon loading: {args.OriginalUri}");
                return ResourceLoadingAction.Default;
            case ResourceType.Image:
                Console.WriteLine($"External Image found upon loading: {args.OriginalUri}");

                const string newImageFilename = "Logo.jpg";
                Console.WriteLine($"\tImage will be substituted with: {newImageFilename}");

                byte[] imageBytes = File.ReadAllBytes(ImageDir + newImageFilename);
                args.SetData(imageBytes);

                return ResourceLoadingAction.UserProvided;
        }

        return ResourceLoadingAction.Default;
    }
}
```

### See Also

* interface [IResourceLoadingCallback](../../iresourceloadingcallback/)
* class [LoadOptions](../)
* namespace [Aspose.Words.Loading](../../../aspose.words.loading/)
* assembly [Aspose.Words](../../../)
