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

Free Support Forum - aspose.com

Prevent from accessing Internet

Hi!

I would like Aspose.Words to prevent from accessing internet when parsing in my case mhtml documents. Is there a way to tell words not to download images, but only use what is embedded?

@christianberg123,

A class implementing the IResourceLoadingCallback interface can be used to control how resources such as images or CSS are handled when they need to be downloaded from an external source i.e a network or internet. Please see the following example which bans all network resources from loading:

Aspose.Words.Loading.LoadOptions loadOptions = new Aspose.Words.Loading.LoadOptions();
loadOptions.LoadFormat = LoadFormat.Mhtml;
loadOptions.ResourceLoadingCallback = new HandleResourceLoading();

Document doc = new Document(@"C:\Temp\in.mhtml", loadOptions);
doc.Save(@"C:\Temp\out.docx");

public class HandleResourceLoading : IResourceLoadingCallback
{
    public ResourceLoadingAction ResourceLoading(ResourceLoadingArgs args)
    {
        return ResourceLoadingAction.Skip;
    }
}