Short explanation:
Template
+ JSON
= Document
with the format PDF
, ODT
, DOCX
or DOC
.
The template language is [jtwig], it should be a piece of cake for all who are a little bit familiar with django
, php-twig
or similar.
The code is directly written as content and can be styled how ever you like, to keep your templates readable.
The Document-Service
is designed to support any document format based on XML
. It is using the XML
fundamentals to separate code from the actual content and to place it meaningful in the XML
structure. So we can produce the expected document result.
Currently supported template format is ODT
. Other formats like DOCX
are not ready yet.
- docker
- make
For development:
- JDK 11
- gradle
Tip: use sdkman.io for a quick developer setup.
See conf.json and log4j2.json.
make build-docker
make run-docker
docker run -p 2115:2115 proxeus/document-service:latest
You can simply interact with the server using curl
.
# To compile a template to pdf (pdf is the default)
curl --form [email protected] --form [email protected] http://<server>/compile > result.pdf
# To compile a template to odt (available format are pdf, odt, docx or doc)
curl --form [email protected] --form [email protected] http://<server>/compile?format=odt > result.odt
# To embed the template rendering error in the pdf result (add the `error` query parameter
curl --form [email protected] --form [email protected] http://<server>/compile?error > result.pdf
# To get the variables used in a template
curl --data-binary @template.odt http://<server>/vars
curl --form [email protected] http:/<server>/vars
# To get the subset of the variable starting with a given prefix
curl --data-binary @template.odt http://<server>/vars?prefix=foo
curl --form [email protected] http:/<server>/vars?prefix=bar
# To add asset files
curl --form [email protected] --form [email protected] --form [email protected] http://<server>/compile > result.pdf
The API documentation can be accessed by <host>:<port>/api
or over the playground UI on the top right corner.
Here a simple overview:
If you are looking for an example implementation of the API please checkout the client source [here].
See the LICENSE file