Skip to main content

Convert Word to PDF


Easily convert Word documents to PDFs using The DynamicPDF API's pdf endpoint.

Convert Word documents to PDFs using the pdf endpoint. Call the pdf endpoint directly or using one of our client libraries.

tip

Check out Getting Started and Task Roadmap if you are new to The DynamicPDF API.

Calling Endpoint Directly

Convert from a Word document to a PDF using the word element in a JSON instructions document.

The following example illustrates the steps in converting a simple word document to a PDF.

  • Create an instructions.json document that specifies word as the input and the word document as the resourceName.
{
"inputs":[
{
"type":"word",
"resourceName":"Doc1.docx"
}]
}
  • Add the authorization key as a header.
  • Add the Instructions document as a file and the Word document as a file.
curl --location 'https://api.dpdf.io/v1.0/pdf'
--header 'Authorization: Bearer --api-key--
--form 'Instructions=@C:/temp/solutions/word-pdf/instructions.json'
--form 'Resource=@C:/temp/solutions/word-pdf/Doc1.docx'

Run In Postman

tip

See the Merge PDFs and Other Resources for more information on how you can merge multiple Word documents and other resources into a combined PDF.

Calling Endpoint Using Client Library

Easily convert a Word to a PDF using the WordInput class or its equivalent using the C#, Java, Node.js, PHP, Go, or Python. More details and examples are provided in the pdf Inputs documentation.

The following example illustrates creating a PDF from a Word document.

Pdf pdf = new Pdf();
pdf.ApiKey = apiKey;
pdf.AddWord(new WordResource(basePath + "/Doc1.docx"));
PdfResponse pdfResponse = pdf.Process();
Source: WordConversion.cs
tip

You can also add a resource using an input, as this Word example illustrates.

Pdf pdf = new Pdf();
WordResource wordResource = new WordResource(basePath + "Doc1.docx");
WordInput word = new WordInput(wordResource);
pdf.Inputs.Add(word);
return pdf;
info

The pdf endpoint takes a JSON instructions document that provides instructions for creating, transforming, merging, and formatting inputs into a combined PDF. Refer to documentation on the instructions schema for information on how to use the pdf endpoint.

   Follow us on social media for latest news!