Java Code to Convert DOCX to PDF | Manage IllegalStateException Infinite Loop Detected Error

Hi,

The following sample code for converting docx to pdf, got the errors
“Infinite loop detected”.
This happens in “aspose-words-19.6.jar”,
works OK in “aspose-words-18.2-jdk16.jar”

            File converted = new File("c://temp//outputPdf.pdf");
            File docxFile   = new File("c://temp//bad.docx");
            String sourcePath = docxFile.getAbsolutePath();
          
            Document doc = new Document(sourcePath);
            doc.setWarningCallback(new WarningCallback(docxFile));
            doc.save(converted.getAbsolutePath(), saveOptions);

Exception caught while converting document to PDF. Will retry once more.
java.lang.IllegalStateException: Infinite loop detected.
at com.aspose.words.zzYVV.zzsI(Unknown Source)
at com.aspose.words.zzYVV.zzb(Unknown Source)
at com.aspose.words.zz90.zzF(Unknown Source)
at com.aspose.words.zz91.zzZOF(Unknown Source)
at com.aspose.words.zzZ74.zzZ3D(Unknown Source)
at com.aspose.words.Document.updatePageLayout(Unknown Source)
at com.aspose.words.Document.zzX9(Unknown Source)
at com.aspose.words.Document.getPageCount(Unknown Source)
at com.aspose.words.zz0C.zzY(Unknown Source)
at com.aspose.words.zz0C.zzZ(Unknown Source)
at com.aspose.words.zzZGI.zzZ(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)
at com

Thanks help!

Ruhong

@ruhongcai,

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

It works with the latest version aspose.words, thanks!

Ruhong

@ruhongcai,

Thanks for your feedback. It is great that you were able to resolve this issue on your end. Please let us know any time you may have any further queries in future.