We have few images in sharepoint Picture document library. while genrating the report, we are converting the entire report to an HTML format as below giving this HTML as input to Aspose.words.
The images in this HTML are not rendering if we not enable the Ananymouns access at web application level.
Thanks for your inquiry and sorry for the delayed response. I am afraid, currently there is no way you can set network credentials using Aspose.Words. I have linked your request to appropriate feature (WORDSNET-927) in our issue tracking system. You will be notified as soon as this feature is supported. Sorry for the inconvenience.
Moreover, in the mean time, you may want to use the following code snippet as a temporary work around:
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")
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;
}