Skip to main content

Conversions 101

We provide two API endpoints for converting docx documents to PDF/UA. The first endpoint should be used if you prefer specifying the input data in separate files, the second endpoint should be used if you prefer to specify the input data in a single JSON file.

Conversion with separate input files

The first endpoint is /docx2pdfua and expects the following input:

  • template - the docx file to be converted
  • data - a JSON file containing the data to be inserted into the template
  • images - an optional array of images to be inserted into the template

Example:

curl --location --request POST 'http://localhost:8000/docx2pdfua' \
--form 'template=@"/home/pathfindr/example/generic.docx"' \
--form 'data=@"/home/pathfindr/example/generic.json"' \
--form 'images=@"/home/pathfindr/example/png.jpg"' \
note

The template parameter is required, the data and images parameters are optional.

tip

You can download generic.docx, generic.json and the logo.png files here.

Conversion with single input file (since version 1.3.0)

The second endpoint is /docx2pdfua_packed and expects a single JSON file containing the following fields:

  • template: json object with the property "templateBase64": containing the base64 encoded word document
  • data: json object with arrays, objects, strings, numbers and booleans
  • images: array of json objects containing the "name" (string) to be replaced, the base 64 encoded image in the "base64" property, the "title" and the "alt" text for the image itself
note

Here you can study the JSON schema, we use to validate the input or download the json file

Example:

curl --location --request POST 'http://localhost:8000/docx2pdfua_packed' \
--header 'Content-Type: application/json' \
--data-binary '@/home/pathfindr/dev/docx2pdfua/example/generic.packed.json'
tip

You can download generic.packed.json here

Now that you have converted your first document, it is time to get aquanted with merge fields or if you want to learn more about the API, please visit the API documentation.