Skip to content

Instantly share code, notes, and snippets.

@groupdocs-cloud-gists
Last active July 16, 2025 18:14
Show Gist options
  • Save groupdocs-cloud-gists/e8db90b8f00a3f737075df64c8d90419 to your computer and use it in GitHub Desktop.
Save groupdocs-cloud-gists/e8db90b8f00a3f737075df64c8d90419 to your computer and use it in GitHub Desktop.
Free Word to PDF converter
How to perform Word to PDF conversion.
using System;
using GroupDocs.Conversion.Cloud.Sdk.Api;
using GroupDocs.Conversion.Cloud.Sdk.Client;
using GroupDocs.Conversion.Cloud.Sdk.Model.Requests;
using System.IO;
using GroupDocs.Conversion.Cloud.Sdk.Model;
namespace GroupDocs.Conversion.CSharp
{
// Convert Word to PDF online
class PDFConversion
{
static void Main(string[] args)
{
try
{
// Get your API credentials
string clientId = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
string clientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
string myStorage = "test";
// Instantiate an instance of the Configuration class with the Client Secret & Client ID.
var configuration = new Configuration(clientId, clientSecret);
// Define the value of ApiBaseUrl to set the base url of the API.
configuration.ApiBaseUrl = "https://api.groupdocs.cloud";
// Initialize an object of the ConvertApi class with the object of the Configuration class.
var apiInstance = new ConvertApi(configuration);
// Create an instance of the ConvertSettings class.
var settings = new ConvertSettings
{
FilePath = "sample.docx",
Format = "pdf",
OutputPath = "converted/sample.pdf"
};
// call the API to trigger the Word to PDF conversion.
var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings));
Console.WriteLine("Successfully converted Docx to PDF in C#: " + response[0].Url);
}
catch (Exception e)
{
Console.WriteLine("Exception when calling GroupDocs Api: " + e.Message);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment