Issue converting to image when document contains footnotes

Hello,

One of our customer is facing serious issues when converting a Word document to images. The thread that performs this hangs deep inside Aspose code. This blocks all further image converting processing. The document concerned contains a set of footnotes.

We are using Aspose.Words java version 17.12 but also experienced the same issue with version 18.12. We cannot test with later version because license does not permit.

Stacktrace of the hanging thread:

Name: Attachment preview updater for dm: processing 0155C00133030182, update queue size: 1 (80), Alive: true interrupt
com.aspose.words.zzZ6X.zzD3(Unknown Source)
com.aspose.words.zzZ6X.zzD3(Unknown Source)
com.aspose.words.zzZZU.zzZ(Unknown Source)
com.aspose.words.zzYYE.zzZh4(Unknown Source)
com.aspose.words.zzYYE.zzZ(Unknown Source)
com.aspose.words.zzZEY.zzU(Unknown Source)
com.aspose.words.zzZEY.zzZ(Unknown Source)
com.aspose.words.zzXN.zzY(Unknown Source)
com.aspose.words.zzZ7H.zzZse(Unknown Source)
com.aspose.words.zzZ7H.zzS(Unknown Source)
com.aspose.words.zzZ6V.zzJ(Unknown Source)
com.aspose.words.zzYWE.zzn(Unknown Source)
com.aspose.words.zz93.zzJ(Unknown Source)
com.aspose.words.zz94.zz41(Unknown Source)
com.aspose.words.zzZMO.zz41(Unknown Source)
com.aspose.words.zz1F.zzZV8(Unknown Source)
com.aspose.words.zz1F.zzZ(Unknown Source)
com.aspose.words.zz1F.zzZw(Unknown Source)
com.aspose.words.Document.zzZ(Unknown Source)
com.aspose.words.Document.zzZ(Unknown Source)
com.aspose.words.Document.zzZ(Unknown Source)
com.aspose.words.Document.save(Unknown Source)
com.qonline.plugins.convert.handlers.ConvertHandlerImage.convert(ConvertHandlerImage.java:162)

Code that performs the save operation (is called for all pages in the document):

public ByteArrayOutputStream convert(Document doc, int page) throws Exception {
    if (doc == null) {
    	throw new IllegalArgumentException(EXCEPTION_DOCUMENT_NULL);
    }
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
    	if((page < doc.getPageCount()) && page >= 0) {
    		ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.JPEG);
    		saveOptions.setPaperColor(Color.WHITE);
    		saveOptions.setPageCount(1);
    		saveOptions.setPageIndex(page);

    		saveOptions.setJpegQuality(this.quality);
    		saveOptions.setResolution(this.dpi);
    		saveOptions.setUseAntiAliasing(this.anti);
    		saveOptions.setUseHighQualityRendering(this.hires);

    		doc.save(out, saveOptions);
    	} else {
    		throw new IllegalArgumentException(EXCEPTION_PAGE_INDEX);
    	}
    } finally {
    	out.close();
    }
    return out;
}

I have uploaded the document that isolates the problem. Note that when reducing to a single footnote, the image conversion works fine.

Footnotes simplified more.zip (21.2 KB)

Many thanks for helping out, regards,
Herm Flink

@hflink01

Please create a simple Java application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

We will investigate the issue on our side and provide you more information.

ConvertImages.zip (42.9 KB)
Please find attached the simple Java application for you to reproduce the issue. In the zip I have also included a Word document that successfully converts to images and a Word document that fails to convert (keeps hanging). The only difference between these document is the number of footnotes.

@hflink01

Please use the following code example to avoid the shared exception. Hope this helps you.

Document doc = new Document(MyDir + "Footnotes fail.docx");

ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.JPEG);
saveOptions.setPaperColor(Color.WHITE);

saveOptions.setJpegQuality(80);
saveOptions.setResolution(96);
saveOptions.setUseAntiAliasing(false);
saveOptions.setUseHighQualityRendering(false);

saveOptions.setPageSavingCallback(new IPageSavingCallback() {
    public void pageSaving(PageSavingArgs args)
    {
        args.setPageFileName(MyDir + "Page_"+ args.getPageIndex()  + ".jpeg");
    }
});

doc.save(MyDir + "output.jpeg", saveOptions);

Thank for you answer. I took your code, but the issue is still there. I used Aspose Words 17.2.
Also, you mention exception, but there is no exception. The program hangs forever in the call to doc.save().
I have added the changed code in a Simple Java application againConvertImages.zip (43.0 KB)

@hflink01

We have not found the hangs forever issue while using the latest version of Aspose.Words for Java 19.6. We suggest you please use Aspose.Words for Java 19.6 and code shared in my previous post to get the desired output.

Ok, so we paid for a new license and upgraded to Aspose Words 19.6, but the sample code you provided does not allow for specific page saves, as could be seen in my first code.

First of all, I extended your code in the following way:

ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.JPEG);
saveOptions.setPaperColor(Color.WHITE);
saveOptions.setPageCount(1);
saveOptions.setPageIndex(0);

saveOptions.setJpegQuality(80);
saveOptions.setResolution(96);
saveOptions.setUseAntiAliasing(false);
saveOptions.setUseHighQualityRendering(false);			

saveOptions.setPageSavingCallback(new IPageSavingCallback() {
	public void pageSaving(PageSavingArgs args)
	{
		args.setPageFileName("PageX_"+ args.getPageIndex()  + ".jpeg");
	}
	});

doc.save("output.jpeg", saveOptions);

saveOptions.setPageIndex(1);
doc.save("output.jpeg", saveOptions);

saveOptions.setPageIndex(2);
doc.save("output.jpeg", saveOptions);

Note setPageIndex(1) and setPageIndex(2) are added, Now, testing again with the failing doc, you will see that only the first of the three pages is converted. The program hangs, again, deep inside the Aspose doc.save() method.

Furthermore, when invoking doc.getPageCount() before the conversion, as in the example below, the program hangs again in the save() method. We need getPageCount(), it should not harm the doc content, right?

int count = doc.getPageCount();

ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.JPEG);
saveOptions.setPaperColor(Color.WHITE);

saveOptions.setJpegQuality(80);
saveOptions.setResolution(96);
saveOptions.setUseAntiAliasing(false);
saveOptions.setUseHighQualityRendering(false);			

saveOptions.setPageSavingCallback(new IPageSavingCallback() {
	public void pageSaving(PageSavingArgs args)
	{
		args.setPageFileName("PageX_"+ args.getPageIndex()  + ".jpeg");
	}
	});

doc.save("output.jpeg", saveOptions);    

Note that both code samples above work fine when tested with the other doc from the zip. There is definitely some issue here, and I would like to urge you to have a deeper look and try to find a solution that works for us so we can convert specific pages from the document.
In the end, we do not wish to anticipate on hanging threads when doing operations with Aspose. This makes our code less clean and maintainable.

@hflink01

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-18740. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Thanks for picking this up as an issue. Can you please give an estimate when and in which version this gets fixed?

@hflink01

We try our best to deal with every customer request in a timely fashion, we unfortunately cannot guarantee a delivery date to every customer issue. We work on issues on a first come, first served basis. We feel this is the fairest and most appropriate way to satisfy the needs of the majority of our customers.

Currently, your issue is pending for analysis and is in the queue. Once we complete the analysis of your issue, we will then be able to provide you an estimate.

You reported this issue in free support forum and it will be treated with normal priority. To speed up the progress of issue’s resolution, we suggest you please check our paid support policies from following link.
Paid Support Policies

The issues you have found earlier (filed as WORDSNET-18740) have been fixed in this Aspose.Words for .NET 20.1 update and this Aspose.Words for Java 20.1 update.