A document template merge service providing an API to manage templates and merge them with given data. It can also be used to convert Docx files to PDF.
Requirements
- docker
- docker-compose
After installing and configuring those, download docker-compose.yml and run the following command:
docker-compose up -dYou can now access the api at http://localhost:8000/api/v1/ which includes a browsable api.
The workaround has a setting called ISOLATE_UNOCONV, it is only enabled in the
development environment. If ISOLATE_UNOCONV is enabled the container needs
CAP_SYS_ADMIN. See docker-compose.override.yml.
cap_add:
- CAP_SYS_ADMIN
security_opt:
- apparmor:unconfined
environment:
- ISOLATE_UNOCONV=trueDepending on your system configuration (e.g. on Ubuntu versions >= 23.10), you might run into the following error (because unprivileged user namespaces are restricted by default):
unoconv failed with returncode: 1 stderr: b'unshare: write failed /proc/self/uid_map: Operation not permitted
To work around this you can set the following sysctl parameters to allow unprivileged user namespaces.
Create the following file /etc/sysctl.d/99-userns.conf
kernel.unprivileged_userns_clone=1
user.max_user_namespaces=28633
kernel.apparmor_restrict_unprivileged_userns=0
And apply with sudo sysctl -p (additionally reboot, and/or recreate the docker container).
Upload templates using the following:
curl --form template=@docx-template.docx --form name="Test Template" --form engine=docx-template http://localhost:8000/api/v1/template/After uploading successfully, you can merge a template with the following call:
curl -H "Content-Type: application/json" --data '{"data": {"test": "Test Input"}}' http://localhost:8000/api/v1/template/test-template/merge/ > output.docxTo convert a standalone Docx file the following call can be used:
curl -X POST --form file=@my-test-file.docx --form target_format="pdf" http://localhost:8000/api/v1/convert > example.pdf- Configuration - Further configuration and how to do a production setup
- Usage - How to use the DMS and it's features
- Contributing - Look here to see how to start with your first contribution. Contributions are welcome!
Code released under the GPL-3.0-or-later license.