Conversion API

Collabora Online allows you to convert between various file formats easily. To do so, all you need to do is to HTTP POST the content of the file to the specific endpoint.

API: HTTP POST to /cool/convert-to/<format>&<lang=xx-XX>

  • the format is e.g. png, pdf or txt

  • the pdf version (optional) for the respective type of PDF to be used for the output file. Example: PDFVer=PDF/A-2b

  • the file itself in the payload.

  • the language parameter (optional) sets the default format language, useful for date type cells. If passed, the load language is used and it determines the display/output format. Example: lang=fr-FR

Example:

curl -k -F "data=@test.txt" https://localhost:9980/cool/convert-to/docx > out.docx

Note: The -k in this example disables certificate validation as it is unlikely you have one in that situation. On a production system, please make sure you have valid certificates and to not disable the validation with -k.

  • or in HTML:

1<form action="https://localhost:9980/cool/convert-to/docx" enctype="multipart/form-data" method="post">
2 File: <input type="file" name="data"><br/>
3 <input type="submit" value="Convert to DOCX">
4</form>

Alternatively you can omit the <format>, and instead provide it as another parameter.

Example:

curl -k -F "data=@test.odt" -F "format=pdf" -F "PDFVer=PDF/A-2b" https://localhost:9980/cool/convert-to > out.pdf
# PDFVer is optional, PDF versions currently supported:
# PDF/A-1b, PDF/A-2b, PDF/A-3b, PDF-1.5, PDF-1.6

Note: Same as above, the -k in the example disables certificate validation.

  • or in HTML:

1<form action="https://localhost:9980/cool/convert-to" enctype="multipart/form-data" method="post">
2 File: <input type="file" name="data"><br/>
3 Format: <input type="text" name="format"><br/>
4 <input type="submit" value="Convert">
5</form>

Note: the convert-to endpoint is restricted to allowed host addresses that can be set in the /etc/coolwsd/coolwsd.xml configuration file. The IP addresses have to be added as dot-escaped net.post_allow.host entries.