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 -F "data=@test.txt" https://localhost:9980/cool/convert-to/docx > out.docx
  • 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 -F "data=@test.odt" -F "format=pdf" "PDFVer=PDF/A-2b" https://localhost:9980/cool/convert-to > out.pdf
# PDFVer is optional, PDF versions currently supported:
# - For 6.4: PDF/A-1b, PDF/A-2b, PDF-1.5, PDF-1.6
# - For 21: PDF/A-1b, PDF/A-2b, PDF/A-3b, PDF-1.5, PDF-1.6
  • 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.