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 converteddata
- a JSON file containing the data to be inserted into the templateimages
- 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"' \
The template
parameter is required, the data
and images
parameters are optional.
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 documentdata
: json object with arrays, objects, strings, numbers and booleansimages
: 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
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'
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.