We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Option to ignore external images

I’m using Aspose.Words .NET to convert Word Documents to PDF and Images.

The process has been working great, but recently I’ve encountered the process hanging as it attempts to process word documents which contain links to external images (hosted on the internet).

The process is isolated from the internet, so no surprise that it can’t retrieve the images. The desired behavior is that it should complete processing with a text tag a blank space in place of the linked document.

What is the easiest way to make Aspose.Words ignore/replace unreachable links during conversion to Image?


If your document contains URL to images or styles sheets, Aspose.Words loads such resources via internet. You can use LoadOptions.ResourceLoadingCallback property to control how external resources (images, style sheets) are loaded when a document is imported.

You can use following code example to skip such resources while importing document.

public class HandleResourceLoading : IResourceLoadingCallback
    public ResourceLoadingAction ResourceLoading(ResourceLoadingArgs args)
        String url = args.OriginalUri;
        if (args.ResourceType == ResourceType.Image || url.Contains("http://"))
            return ResourceLoadingAction.Skip;

        return ResourceLoadingAction.Default;

LoadOptions loadOptions = new LoadOptions();
loadOptions.ResourceLoadingCallback = new HandleResourceLoading ();
var document = new Document(MyDir + "input.docx", loadOptions);
1 Like

Thank you. That code worked.

Since my use case has users submitting a word document without any other context, I believe that I want to skip ALL resource loading.
So my ResourceLoading simply is return ResourceLoadingAction.Skip; for all cases.

Thank you again.