Related question to this. Can you still not specify credentials when saving from HTML to Word? I similar to the issue identified here have a situation where images are hosted in a SP document library. If I use an absolute path url to an external site (which has anonymous access enabled) the image gets downloaded…
Thanks for your inquiry. We had added Document.IResourceloadingCallback property as per WORDSNET-927 and you can try using the following code:
public class ImageLoadingWithCredentialsHandler : IResourceLoadingCallback
{
public ImageLoadingWithCredentialsHandler()
{
mWebClient = new WebClient();
}
public ResourceLoadingAction ResourceLoading(ResourceLoadingArgs args)
{
if (args.ResourceType == ResourceType.Image)
{
Uri uri = new Uri(args.Uri);
if (uri.Host == "[www.aspose.com](https://www.aspose.com/)")
mWebClient.Credentials = new NetworkCredential("User1", "akjdlsfkjs");
else
mWebClient.Credentials = new NetworkCredential("SomeOtherUserID", "wiurlnlvs");
// Download the bytes from the location referenced by the URI.
byte[] imageBytes = mWebClient.DownloadData(args.Uri);
args.SetData(imageBytes);
return ResourceLoadingAction.UserProvided;
}
else
{
return ResourceLoadingAction.Default;
}
}
private WebClient mWebClient;
}