How do I load a PDF file into Aspose.Words

I am trying to open a PDF file using com.aspose.words.Document and save it as docx file using “aspose-words-20.11-jdk17.jar”.

Document pdfDocument = new Document(“TestDoc.pdf”);

When code executes above line, it throws following exception

com.aspose.words.UnsupportedFileFormatException: Unsupported file format: Unknown

 at com.aspose.words.zzX.zzZ(Unknown Source)
 at com.aspose.words.Document.zzY(Unknown Source)
 at com.aspose.words.Document.zzZ(Unknown Source)
 at com.aspose.words.Document.(Unknown Source)
 at com.aspose.words.Document.(Unknown Source)

On the other hand, same code will work well in aspose word for dotnet and can also save PDF file in docx format successfully. However, in aspose word jar for java it failes and throws the above error.

Kindly suggest how can I open pdf file using aspose.words jar and save it as docx file?

@ashokramakr Unfortunately loading PDF documents is not supported in java version of Aspose.Words. This feature is supported in .NET and Python versions. Implementation of this feature WORDSJAVA-2511 in java has been postponed and is not yet scheduled for development.

You can consider using Aspose.PDF for Java to convert PDF documents to DOCX:
https://docs.aspose.com/pdf/java/convert-pdf-to-word/