DOCX to PDF and PDF to DOCX conversion C# REST API

PDF to Word conversion logo

Microsoft Word including (DOCX, DOC, DOT, DOTX, DOTM, FlatOPC (XML) and OpenOffice (ODT, OTT) are among the popular office document processing/management formats. The support for rich text, document structuring, large blocks of text, page breaks, page numbering, hidden text, are among the exciting features which compel the users to select this particular format. Furthermore, it also provides the support to easily integrates with other Microsoft Office programs i.e. if you have a spreadsheet that you created on Microsoft Excel, you can easily paste it into a Word document.

Similarly, Portable Document Format (PDF) is also a leading document format used for data/information sharing. The feature of preserving document formatting on any platform (Mobile, desktop, Windows, Mac, etc) is one of the salient features of PDF format. However, in order to edit the PDF files, you need to use the applications which sometimes get quite expensive. Also, you may stumble upon a requirement to perform a minor change/update in the document and again render the output in PDF. Or, for long-term document archival, you need to have the documents in a specific format i.e. either Word or PDF where documents are combined to generate single unified output.

Table Of Contents

Document processing using REST API

Aspose.Words Cloud is one of our leading products which provides the feature to create as well as programmatically manipulate MS Word files. It also offers the feature to render output files in PDF/A, XPS, PS, JPEG, PNG, BMP, SVG, TIFF, EMF, PCL, SWF, CGM, HTML, etc. For more information related to supported formats, please visit document conversion.

DOCX to PDF conversion

The conversion of an MS Word file to PDF can be accomplished using a couple of code lines.

Load and save files locally

The following code snippets show the steps to load MS Word document from local drive and save it as a PDF.

  • Create an object of WordsApi class while passing Client ID and Client Secret as arguments
  • Create an object of ConvertDocumentRequest and provide input file path resultant output format as arguments
  • Call ConvertDocument(..) method of WordsApi to perform the conversion

The Client ID and Client Secret are assigned to each account subscribed over For more information, you may consider visiting Obtaining client ID and Client Secret.

Conversion on Cloud storage

Given below are the steps describing how to upload an MS Word file from the local system into Cloud storage. Then we perform the conversion operation to PDF format. After a successful conversion, the resultant file is also saved in the same storage.

  • Create an object of WordsApi class while passing Client ID and Client Secret as arguments
  • Load MS Word file from the local system and provide it as an argument to UploadFileRequest(..) instance
  • Create an instance of SaveOptionsData where we define the format as well as the name of the resultant file
  • Create an instance of SaveAsRequest class where input Word document (uploaded earlier) and SaveOptionsData information are provided as an argument
  • Call SaveAs(..) method of WordsApi class to initialize the conversion

PDF to DOCX conversion

We have a separate API named Apsose.PDF Cloud which provides the features to create, manipulate as well as it is also capable of converting PDF files to DOC/DOCX, etc, and other supported formats. However, if you only need to perform PDF to DOC conversion and perform other PDF file manipulation operations, then Aspose.PDF Cloud is a perfect choice. Whereas, if your main work resides with MS Word files manipulation and you also need to perform PDF to DOC conversion, then Aspose.Words Cloud is a perfect choice.

Please be aware that PDF documents support multilevel security options and are difficult to extract information. PDF format is the best choice when the document’s author allows others to read and print document copies only. Word document formats, in contrast, are great for collaborative development, but they aren’t always the best choice for distributing as they can be easily modified without the author’s permission.

cURL command

The command below shows how to get the JWT token as per your Client ID and Client Secret.

curl -v "" \
-d "grant_type=client_credentials&client_id=xxxx-xxx-xxx-xxx&client_secret=xxxxxx" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

The following cURL command can be used to perform PDF to DOC conversion over command prompt/console.
curl -X PUT "" \
-H "accept: application/json" \
-H "Authorization: Bearer <JWT Token>" \
-H "Content-Type: application/json" \
-d "{\"SaveFormat\":\"docx\",\"FileName\":\"myResultant.docx\",\"UpdateLastSavedTimeProperty\":true,\"UpdateSdtContent\":true,\"UpdateFields\":true,\"Dml3DEffectsRenderingMode\":\"Basic\",\"UpdateLastPrintedProperty\":true}"