Skip Downloading of Unreachable Images during Word DOC to Text Conversion to Improve Timing | Implement IResource Loading Callback Java

Hi,

We are currently using the 14.4 version of Aspose, but it is taking time for conversion for Chinese file. I tested with the latest version(20.4) but taking the time (35-40sec).
Will you please check this.

File shared by - nidhi@rchilli.com

Regard,
Vinod

@rchilli,

Have you also tried the latest 20.8 version of Aspose.Words for Java on your end? In case the problem still remains, then please ZIP and upload your input Word DOC document(s) you are getting this problem with here for testing. We will then investigate the issue on our end and provide you more information.

Yes, I tried the latest version 20.8, but facing the same timing issue.
I am attaching the ZIP. Please check it.

Chinese.zip (6.3 KB)

@rchilli,

Problem occurs because there are images in Word DOC files that are referring to following paths:

  • http://img.miaohr.com//1a/196/234/0e4b4db206a65b8d188df1affb10601b.jpg
  • http://img.miaohr.com//3ca/370/34a/bd705730f28dc1d28c96ac88416b8f8b.jpg
  • http://img.miaohr.com//1e9/198/328/42b69de07a5661ca37a982af1f30b063.jpg

Aspose.Words tries to download images from above paths but these sites are not available. If you disconnect from internet and then Aspose.Words processes these documents quickly. You can use the following Java code of Aspose.Words to workaround this problem:

LoadOptions opts = new LoadOptions();
opts.setResourceLoadingCallback(new HandleResourceLoadingCallback());
Document doc = new Document("C:\\Temp\\Chinese\\input.doc", opts);
doc.save("C:\\Temp\\Chinese\\awjava-20.8.txt");

private static class HandleResourceLoadingCallback implements IResourceLoadingCallback {
    public int resourceLoading(ResourceLoadingArgs args) {
        if (args.getResourceType() == ResourceType.IMAGE) {
            return ResourceLoadingAction.SKIP;
        }
        return ResourceLoadingAction.DEFAULT;
    }
}

Please refer to IResourceLoadingCallback Interface for more information.