## ResourceLoadingAction enumeration

Specifies the mode of resource loading.

To learn more, visit the [Specify Load Options](https://docs.aspose.com/words/net/specify-load-options/) documentation article.

```csharp
public enum ResourceLoadingAction
```

### Values

| Name | Value | Description |
| --- | --- | --- |
| Default | `0` | Aspose.Words will load this resource as usual. |
| Skip | `1` | Aspose.Words will skip loading of this resource. Only link without data will be stored for an image, CSS style sheet will be ignored for HTML format. |
| UserProvided | `2` | Aspose.Words will use byte array provided by user in [`SetData`](../resourceloadingargs/setdata/) as resource data. |

## Examples

Shows how to customize the process of loading external resources into a document.

```csharp
Document doc = new Document();
doc.ResourceLoadingCallback = new ImageNameHandler();

DocumentBuilder builder = new DocumentBuilder(doc);

// Images usually are inserted using a URI, or a byte array.
// Every instance of a resource load will call our callback's ResourceLoading method.
builder.InsertImage("Google logo");
builder.InsertImage("Aspose logo");
builder.InsertImage("Watermark");

Assert.That(doc.GetChildNodes(NodeType.Shape, true).Count, Is.EqualTo(3));

doc.Save(ArtifactsDir + "DocumentBase.ResourceLoadingCallback.docx");
```

Shows how to customize the process of loading external resources into a document (ImageNameHandler).

```csharp
/// <summary>
/// Allows us to load images into a document using predefined shorthands, as opposed to URIs.
/// This will separate image loading logic from the rest of the document construction.
/// </summary>
private class ImageNameHandler : IResourceLoadingCallback
{
    public ResourceLoadingAction ResourceLoading(ResourceLoadingArgs args)
    {
        // If this callback encounters one of the image shorthands while loading an image,
        // it will apply unique logic for each defined shorthand instead of treating it as a URI.
        if (args.ResourceType == ResourceType.Image)
            switch (args.OriginalUri)
            {
                case "Google logo":
                    using (HttpClient client = new HttpClient())
                    {
                        byte[] imageData = client.GetByteArrayAsync("http://www.google.com/images/logos/ps_logo2.png").GetAwaiter().GetResult();
                        args.SetData(imageData);
                    }

                    return ResourceLoadingAction.UserProvided;

                case "Aspose logo":
                    args.SetData(File.ReadAllBytes(ImageDir + "Logo.jpg"));

                    return ResourceLoadingAction.UserProvided;

                case "Watermark":
                    args.SetData(File.ReadAllBytes(ImageDir + "Transparent background logo.png"));

                    return ResourceLoadingAction.UserProvided;
            }

        return ResourceLoadingAction.Default;
    }
}
```

### See Also

* namespace [Aspose.Words.Loading](../../aspose.words.loading/)
* assembly [Aspose.Words](../../)
