Convert Docx to PDF
This endpoint allows you to convert Docx to PDF.
POST
https://api.cloudlayer.io/v1/docx/pdfMake a POST request to convert Docx to a PDF.
POST
/docx/pdf
This endpoint is used to convert a valid Docx file (such as a Microsoft Word, or Open Office document) to a PDF. It allows full configuration options described in the table below to be passed into the multi-part form body.
Param | Description |
---|---|
url (string) | Source URL to use for generating the PDF Required if no file |
file (file) | The input file for the multipart/form-data as part of the POST request. Required if no url |
timeout (number) | Amount of time that Chrome is allowed to run, if exceeded your job will be terminated and you will not be charged. Default: 30000 ms (30 seconds) |
delay (number) | The amount of time in milliseconds to wait for the page to complete rendering before conversion. Default: 0 |
filename (string) | If used with the inline:false, will set the Content-Disposition filename so that the downloaded file will be set to this value in the users browser. For inline:true it has no effect. Default: 'file.pdf' |
inline (boolean) | If set to true, set's the Content-Disposition to 'inline', if set to false it will set the Content-Disposition to 'attachment'. See 'filename' property if you want to set the filename value for the attachment. Default: false |
{
"url": "",
"file": "",
"timeout": 30000,
"delay": 0,
"filename": "file.pdf",
"inline": false
}
Copied!
Example
curl --request POST \
--url https://api.cloudlayer.io/v1/pdf/docx \
--header 'content-type: multipart/form-data' \
--header 'x-api-key: <api key>' \
--form [email protected] \
--form timeout=10000 \
--output test.docx
Copied!
Input

Result

As you can see in the example above, the results are pretty good but occasionally you will need to tweak the word document after conversion. For example, you will notice in the Troubleshooting section, the left margin of the second line needs to be adjusted. You can also tweak the PDF to prevent these types of conversion discrepancies.