Convert PDF to DOCX in Java | Aspose.PDF | java.lang.IndexOutOfBoundsException

I use aspose-pdf 21.4

        <dependency>
            <groupId>com.aspose</groupId>
            <artifactId>aspose-pdf</artifactId>
            <version>21.4</version>
        </dependency>

And I want to convert pdf file to docx by this code.

package akd;

import com.aspose.pdf.DocSaveOptions;
import com.aspose.pdf.Document;
import com.aspose.pdf.License;

import java.io.FileInputStream;
import java.io.FileOutputStream;

public class PDFHandler {
    public static void main(String[] args) throws Exception {
        {
            FileInputStream fis = new FileInputStream("../javad_resources/Aspose.Total.Java.lic");
            License license = new License();
            license.setLicense(fis);
            fis.close();
        }

        FileInputStream fis = new FileInputStream("/Users/bindung/Downloads/broken.pdf");
        FileOutputStream fos = new FileOutputStream("/Users/bindung/Downloads/broken.docx");
        Document doc = new Document(fis);
        DocSaveOptions saveOptions = new DocSaveOptions();
        saveOptions.setFormat(DocSaveOptions.DocFormat.DocX);
        saveOptions.setMode(DocSaveOptions.RecognitionMode.Flow);
        doc.save(fos, saveOptions);
    }
}

But broken.pdf (7.3 MB)
file failed with IndexOutOfBoundException

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 28
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
	at java.base/java.util.Objects.checkIndex(Objects.java:372)
	at java.base/java.util.ArrayList.get(ArrayList.java:458)
	at com.aspose.pdf.internal.l0j.ly.lf(Unknown Source)
	at com.aspose.pdf.internal.l0j.ly.lI(Unknown Source)
	at com.aspose.pdf.internal.doc.ml.MlParagraphConverter.addParagraph(Unknown Source)
	at com.aspose.pdf.internal.l98f.lk.lI(Unknown Source)
	at com.aspose.pdf.internal.l98f.lk.lI(Unknown Source)
	at com.aspose.pdf.internal.l0u.lh.lI(Unknown Source)
	at com.aspose.pdf.internal.l98f.lk.lf(Unknown Source)
	at com.aspose.pdf.internal.l98f.le.lk(Unknown Source)
	at com.aspose.pdf.internal.l15v.lv.lI(Unknown Source)
	at com.aspose.pdf.internal.l15v.lb.lf(Unknown Source)
	at com.aspose.pdf.internal.l15l.lj.lI(Unknown Source)
	at com.aspose.pdf.internal.l0j.lf.lI(Unknown Source)
	at com.aspose.pdf.l4v.lI(Unknown Source)
	at com.aspose.pdf.l4v.lI(Unknown Source)
	at com.aspose.pdf.ADocument.lj(Unknown Source)
	at com.aspose.pdf.ADocument.lI(Unknown Source)
	at com.aspose.pdf.Document.lI(Unknown Source)
	at com.aspose.pdf.ADocument.save(Unknown Source)
	at com.aspose.pdf.Document.save(Unknown Source)
	at akd.PDFHandler.main(PDFHandler.java:25)

How can I fix it?

@allganize

We also noticed the similar issue at our end while testing the scenario. It seems like API is not able to process this PDF document for conversion to DOCX. We have logged an issue as PDFJAVA-40467 in our issue tracking system for the sake of correction. We will further investigate it and let you know once it is fixed. Please be patient and spare us some time.

We are sorry for the inconvenience.

When can it be fixed? I’m having a big problem with this.

@allganize

The issue has recently been logged in our issue management system and is pending for analysis. It will be investigated and resolved on a first come first serve basis. We will surely inform you as soon as we have some definite updates regarding its resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.