PDF to Word

Learn how to convert PDF to Word Online

PDF files offer unique advantages over other file formats and can transform business workflows into seamless, secure processes where progress can be closely tracked. Furthermore, sharing files in PDF format ensures all viewers see the document as intended, regardless of the native application, viewer, operating system, or device used. However, PDF editing becomes a cumbersome job because only specialized software provides these capabilities. But, in case we convert PDF to Word format, we can easily edit the file.

PDF to Words Conversion API

Aspose.PDF Cloud SDK for Java is REST based solution providing the features to create, edit and manipulate PDF files within Java applications. Please add the following details in your pom.xml of maven build type.

<repository>
    <id>aspose-cloud</id>
    <name>Aspose Cloud Repository</name>
    <url>https://repository.aspose.cloud/repo/</url>
</repository>

<dependency>
  <groupId>com.aspose</groupId>
  <artifactId>aspose-pdf-cloud</artifactId>
  <version>21.11.0</version>
  <scope>compile</scope>
</dependency>

After the installation, we need to create an account and lookup/create Client ID and Client Secret at Cloud Dashboard.

Convert PDF to Word in Java

Please follow the instructions given below to convert PDF to DOC format.

  • First, we need to create an instance of PdfApi by providing client credentials as arguments
  • Secondly, read the input PDF file into the File instance
  • Now upload the PDF file to cloud storage using the uploadFile(…) method
  • Finally, call putPdfInStorageToDoc(…) method to convert PDF to DOCX and save the output to cloud storage

Convert local PDF to DOC

In this section, we are going to learn the details on how to load the PDF from the local drive, convert it to DOC format and save the resultant file in cloud storage.

  • First, we need to create an instance of PdfApi by providing client credentials as arguments
  • Secondly, read the input PDF file into the File instance
  • Call the putPdfInRequestToDoc(…) method to convert PDF to DOC and save the output to cloud storage

PDF to DOC using cURL Commands

Let’s discuss the details of how we can load the input file from the local drive, and convert it to DOC format using cURL Commands. However, we need to first generate a JWT access token using the following command.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bbf94a2c-6d7e-4020-b4d2-b9809741374e&client_secret=1c9379bb7d701c26cc87e741a29987bb" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Once the JWT token is generated, please execute the following command to convert PDF to DOC format.

curl -v -X PUT "https://api.aspose.cloud/v3.0/pdf/input.pdf/convert/doc?outPath=Resultant.docx&format=DocX&mode=Flow" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"

Conclusion

In this article, we have explored the options on how to convert PDF to Word using Java code snippets as well as how we can convert PDF to DOC using cURL Commands. Please note that the SDK also offers other exciting features related to PDF file manipulation. You may explore the Developer Guide to learn about the plethora of features the API offers. Please note the complete source code of SDK is available for download over GitHub.

We highly recommend visiting the following links to learn more about: