We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert PDF to .docx issue

Hi support team,
appreciate your help to support the below error, that was shown when trying to save PDF to .docx thru the DocSaveOptions method.

Note: The source working with library aspose-pdf-20.8.jar but it starts not working from 20.9 and above.
Error Meessage:

Exception in thread “Thread-2” java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:424)
at java.util.ArrayList.get(ArrayList.java:437)
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.l99l.lk.lI(Unknown Source)
at com.aspose.pdf.internal.l99l.lk.lt(Unknown Source)
at com.aspose.pdf.internal.l0j.lf.run(Unknown Source)
at java.lang.Thread.run(Thread.java:748)
Exception in thread “main” class com.aspose.pdf.exceptions.PdfException: java.lang.ArrayIndexOutOfBoundsException: -1
com.aspose.pdf.l4j.lI(Unknown Source)
com.aspose.pdf.l4j.lI(Unknown Source)
com.aspose.pdf.ADocument.lj(Unknown Source)
com.aspose.pdf.ADocument.lI(Unknown Source)
com.aspose.pdf.Document.lI(Unknown Source)
com.aspose.pdf.ADocument.lI(Unknown Source)
com.aspose.pdf.ADocument.save(Unknown Source)
com.aspose.pdf.Document.save(Unknown Source

Source Code:

public void ConvertPDFToDocx(String input , String output) {
		String originalPath = input;
		String currentPath = output;
		com.aspose.pdf.Document doc = new com.aspose.pdf.Document(originalPath);

		// Instantiate DocSaveOptions instance
		DocSaveOptions saveOptions = new DocSaveOptions();

		// Set output format
		saveOptions.setFormat(DocSaveOptions.DocFormat.DocX);

		// Set the recognition mode as Flow
		saveOptions.setMode(DocSaveOptions.RecognitionMode.Flow);

		saveOptions.setAddReturnToLineEnd(false);
		
		saveOptions.setCloseResponse(false);

		// Save resultant DOCX file
		doc.save(currentPath, saveOptions);
	}

Thanks
Lee

@Rammoslee

Can you please share your sample PDF document for our reference as well? We will test the scenario in our environment and address it accordingly.

liferay-portal-performance-best-practices.pdf (1.7 MB)

Hi @Asad
You may refer to attached file for the sample document.
Thank

@Rammoslee

We were able to replicate the issue in our environment while using 21.10 version of the API. Therefore, an issue as PDFJAVA-40989 has been logged in our issue tracking system for the sake of correction. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the incovnenience.