PDF to Word

PDF to Word Converter | Save PDF to DOC / DOCX format online

This article explains the details on how to convert PDF to Word using C# .NET. We know that PDF files are widely used for data and information sharing because they preserve document fidelity when viewed on any platform including Desktop or Mobile. Owing to this wide acceptability and compatibility, PDF files are widely popular in organizations, Government institutes, universities, etc. However, the file may contain outdated or incorrect information, or you simply want to add a few more lines of text to it. So, it turns out that PDF editing through some applications can be cumbersome and licensing costs can make the task look even more daunting.

However, a viable solution is to transform the PDF file into a Word document (DOC). In this article, we are going to explore the steps on how to convert PDF to Word using .NET Cloud SDK.

Word Conversion API

Aspose.Words Cloud is a programming API offering the capabilities to open, create, edit, merge, split, compare and convert MS Word files to other supported file formats. To further facilitate our customers, we have created Aspose.Words Cloud SDK for .NET which is a wrapper around Cloud API. Simply integrate SDK in your application to get all Word processing capabilities. The SDK can be integrated into Desktop, Web, mobile, IoT, cloud, and microservices.

Installation

The first step is to install the SDK which is available on NuGet and GitHub. Please execute the following command in the terminal window to perform the installation for NuGet:

nuget install Aspose.Words-Cloud

If you are using Visual Studio, then the package can also be installed using the Package Manager Console. Please execute the following command:

 PM> Install-Package Aspose.Words-Cloud
Aspose.Words Cloud

Image 1:- Aspose.Words NuGet package installed.

NuGet Package Manager - Visual Studio

Another easiest approach is to install the SDK via NuGet Package Manager within Visual Studio IDE.

  1. Open the Solution Explorer.
  2. Expand the project and Right-click the Packages folder within your solution.
  3. Select Manage NuGet Packages… option
  4. Click on the Browse tab and search for “Aspose.Words-Cloud
  5. Click on the Aspose.Words-Cloud package, select the appropriate version in the right tab and click Add Package button
Image 2:- Aspose.Words Package in NuGet Package Manager.

Image 2:- Aspose.Words Package in NuGet Package Manager.

Cloud Dashboard

The next step is to create an account by visiting Aspose.Cloud dashboard. If you have GitHub or Google account, simply Sign Up or, click on the Create a new Account button and provide the required information. Now login to the dashboard using credentials and expand the Applications section from the dashboard and scroll down towards the Client Credentials section to see Client ID and Client Secret details.

Client Credentials

Image 3:- Client Credentials at Aspose.Cloud dashboard.

PDF to Word in C#

Please follow the steps given below to perform the conversion:

  • First of all, please create an instance of Configuration while passing Client ID and Client Secret credentials as arguments
  • Secondly, create an object of WordsApi while passing Configuration instance as an argument
  • Thirdly, read the PDF file using File.OpenRead object
  • Now create an instance of the UploadFileRequest file and use UploadFile(…) method to upload PDF to Cloud storage
  • Penultimate, create an instance of GetDocumentWithFormatRequest while passing input file name, resultant format, and output file name as argument
  • Finally, call the GetDocumentWithFormat(..) method to perform conversion and save the output to Cloud storage

The sample files used in the above example can be downloaded from awesome_table_in_pdf.pdf and converted.doc.

Convert PDF to DOC using cURL

You can use the cURL command-line tool to access Aspose.Words web services and convert PDF documents to Word format easily. The following code demonstrates how to convert PDF to DOCX with cURL. But, before performing the file conversion operation, please try creating a JWT access token based on your client credentials. Please execute the following cURL command to generate the JWT access token.

 curl -v "https://api.aspose.cloud/connect/token" \
 -X POST \
 -d "grant_type=client_credentials&client_id=4db2f826-bf9c-42e7-8b2a-8cbca2d15553&client_secret=d757548a9f2558c39c2feebdf85b4c44" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Now we need to execute the following command to upload the PDF file to Cloud storage:

curl -X PUT "https://api.aspose.cloud/v4.0/words/storage/file/awesome_table_in_pdf.pdf" \
-H  "accept: application/json" \
-H  "Authorization: Bearer <JWT Token>" \
-H  "Content-Type: multipart/form-data" \
-d {"fileContent":{}}

Finally, call the following command to convert the PDF file available in Cloud storage to DOC format:

curl -X GET "https://api.aspose.cloud/v4.0/words/awesome_table_in_pdf.pdf?format=DOC&outPath=converted.doc" \
-H  "accept: application/octet-stream" \
-H  "Authorization: Bearer <JWT Token>"

Conclusion

In this article, we have discussed the details of how to convert PDF to Word in a C# .NET application. Furthermore, we have also explored the steps to convert PDF to DOC using the cURL commands. The same SDK can also be used to develop Word to PDF converter. Please note that our SDKs are developed under the MIT license, so the complete code snippet can be downloaded from GitHub. If you encounter any issues while using the API, please feel free to contact us via the free product support forum.

We recommend visiting the following links to learn more about