Free Support Forum - aspose.com

Coverting doc to jpgs too slow

Hi all,

I use the java library of aspose words to convert docs to jpgs and overall this works fine but I now have a document that takes around 58 seconds for conversion which is too long for our purposes; similar sized documents take about 10 seconds to be converted.
I already added a custom ResourceLoadingCallback with ResourceLoadingAction.SKIP to make sure external resources are not the issue.
What more can we do to speed up the conversion process? Can you help us finding the cause of the slow loading or rendering?
VZ_-Huurovereenkomst_zelfstandige_woning-_uitnodiging_teke.doc.zip (34.4 KB)

@berendvervelde,

Thanks for your inquiry. We have tested the scenario using latest version of Aspose.Words for Java 18.3 with following code example and have not found the shared issue. Please use Aspose.Words for Java 18.3.

Document doc = new Document(MyDir + "VZ_-_Huurovereenkomst_zelfstandige_woning_-_uitnodiging_teke.doc");

ImageSaveOptions opts = new ImageSaveOptions(SaveFormat.JPEG);
opts.setPageIndex(0);
opts.setPageCount(doc.getPageCount());

opts.setPageSavingCallback(new HandlePageSavingCallback());
doc.save(MyDir + "18.3.png", opts);

class HandlePageSavingCallback implements IPageSavingCallback
{
    public void pageSaving(PageSavingArgs args)
    {
        args.setPageFileName(MyDir + "Page_"+ args.getPageIndex()  + ".jpeg");
    }
}

I did use an older version of Aspose Words but upgrading did not help much. What did work was using the HandlePageSavingCallback I saw in your code example. I used a simple for loop and somehow that is much slower.

My previous code:

        Document doc = new Document(sourcePath);
        ImageSaveOptions options = new ImageSaveOptions(SaveFormat.JPEG);  
        options.setJpegQuality(80);
        options.setResolution(100);

        for (int i = 0; i < doc.getPageCount(); i++) {
             String imageFilePath = sourcePath + "_output_" + i + ".jpeg";  
             options.setPageIndex(i);  
             doc.save(imageFilePath, options);
        } 

Anyway, thanks for the help. For me the issue is solved.

@berendvervelde,

Thanks for your inquiry. Please implement IPageSavingCallback as shared in my previous post and use latest version of Aspose.Words for Java 18.3 to avoid this performance issue.