Search code examples
javascriptpdfweb-applicationsweb-deploymentdmn

Automatic creation of PDF file from Template


for a project at university we are working on an application that is supposed to automatically create a file for the user after having queried several information from the user. The general idea is to use Decision Model and Notation "DMN" to perform the query and collect the information needed. The file input depends on the answers provided by the user. The application is further intended to be web-based.

My question is therefore, how we can put the strings that result from the DMN query into a PDF template that is ready to print/send? The template is currently set up to be a text document (.docx) that has several input fields that need to be filled.

Thanks!


Solution

  • You can use Kogito for the DMN execution side; it is JVM based but it exposes for you automatically generated REST (JSON) endpoints to evaluate the DMN model. Based on the requirements you listed, this should an easy way to achieve the DMN evaluation part; that is for Kogito you drop the .dmn model file into the src/main/resources directory and it will automatically provide for you a cloud-native based application exposing the REST endpoint.

    Further, the outcoming JSON payload (of the DMN evaluation results) could be fed into a template engine, in order to generate from the JSON of result the final PDF leveraging conversion from a more friendlier target. For instance, this could have also been done with Apache FreeMarker/Velocity template engine. You could use as target HTML or ODF, and finally achieve the final PDF conversion.