Converting Word documents to PDF is a common requirement for creating secure, consistent, and shareable formats across platforms. Using GroupDocs.Conversion Cloud SDK for .NET, developers can easily convert DOC and DOCX files to PDF without installing Microsoft Office or relying on external software.

In this guide, we’ll walk through how to convert Word to PDF using C# in a .NET application via the GroupDocs.Conversion Cloud REST API.

API for DOCX to PDF Conversion

The GroupDocs.Conversion Cloud SDK for .NET offers a streamlined and platform-independent solution for converting Word documents into PDF format. It preserves layout, formatting, and embedded objects such as images, tables, and fonts.

Key Features

  • Convert DOC and DOCX files to PDF accurately.
  • No dependency on Microsoft Office.
  • Works entirely over REST API (cloud-based).
  • OAuth 2.0 secured authentication.
  • Supports storing output to cloud or downloading locally.
  • Integrates easily into any .NET (C#) application.

Install the SDK via NuGet:

Install-Package GroupDocs.Conversion-Cloud

Get your Client ID and Client Secret from GroupDocs Cloud Dashboard

Convert Word to PDF in C# .NET

Please follow the instructions to perform Word document to PDF format online using C# .NET:

  1. Configure API Credentials:
var config = new Configuration
{
    ClientId = "YOUR_CLIENT_ID",
    ClientSecret = "YOUR_CLIENT_SECRET"
};

var convertApi = new ConvertApi(config);
var fileApi = new FileApi(config);
  1. Upload the Word File to Cloud Storage:
using (var fileStream = File.OpenRead("sample.docx"))
{
    var uploadRequest = new UploadFileRequest("sample.docx", fileStream);
    fileApi.UploadFile(uploadRequest);
}
  1. Set Conversion Settings:
var settings = new ConvertSettings
{
    FilePath = "sample.docx",
    Format = "pdf",
    OutputPath = "converted/sample.pdf"
};
  1. Convert Word to PDF:
var request = new ConvertDocumentRequest(settings);
convertApi.ConvertDocument(request);

Console.WriteLine("Word document successfully converted to PDF.");

Convert Word to PDF Using cURL

You can also convert Word to PDF using a simple cURL request. The prerequisite is to generate a JWT token using your client credentials. After that, execute the following command to perform DOCX to PDF conversion:

curl -v "https://api.groupdocs.cloud/v2.0/conversion" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{  \"StorageName\": \"internal\",  \"FilePath\": \"{inputFile}\",  \"Format\": \"html\",  \"LoadOptions\": {    \"Format\": \"docx\"  },  \"OutputPath\": \"{resultantFile}\"}"

Please replace inputFile with the name of input Word document, resultantFile with the name of resultant PDF file and accessToken with personalized JWT access token.

DOC to PDF and download the resultant file to local drive:

curl -v "https://api.groupdocs.cloud/v2.0/conversion" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{  \"StorageName\": \"internal\",  \"FilePath\": \"{inputFile}\",  \"Format\": \"pdf\",  \"LoadOptions\": {    \"Format\": \"doc\"  }}" \
-o "converted.pdf"

Online DOC to PDF converter for free

Looking for a no-code solution? Try our free DOCX to PDF Conversion App powered by GroupDocs.Conversion Cloud.

Free DOCX to PDF converter

✅ Conclusion

Using GroupDocs.Conversion Cloud SDK for .NET, converting Word documents to PDF is fast, simple, and reliable. Whether you’re integrating it in a .NET application or using the REST API directly, the SDK ensures high-quality output with minimal effort.

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