Looks like since the input file has links to some online images, Aspose is trying to download all of that while loading the file, but since the machine where my application is running doesn’t have internet connection, Aspose waits until the timeout before proceeding further, and that’s why the long delay.
Is there any way to turn off this image download option OR reduce the timeout ??
Thanks for your inquiry. We suggest you please use HtmlLoadOptions.WebRequestTimeout property. You can set the number of milliseconds to wait before the web request times out using this property. The number of milliseconds that Aspose.Words waits for a response, when loading external resources (images, style sheets) linked in HTML and MHTML documents.
Moreover, LoadOptions.ResourceLoadingCallback property allows to control how external resources (images, style sheets) are loaded when a document is imported from HTML, MHTML.
Please check the following code example. Hope this helps you.
HtmlLoadOptions loadOptions = new HtmlLoadOptions();
loadOptions.setLoadFormat(LoadFormat.MHTML);
loadOptions.setWebRequestTimeout(10);
loadOptions.setResourceLoadingCallback(new HandleResourceLoading());
Document doc = new Document(MyDir + "Sample.mhtml",loadOptions);
doc.save(MyDir + "18.2.pdf");
public class HandleResourceLoading implements IResourceLoadingCallback
{
public int resourceLoading(ResourceLoadingArgs args)
{
//ResourceLoadingArgs.OriginalUri
if (args.getResourceType() == ResourceType.IMAGE)
return ResourceLoadingAction.SKIP;
return ResourceLoadingAction.DEFAULT;
}
}
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.