Create a document from an embedded task form


#1

Hi there,

I would like to ask if and how can I create a document (like pdf for example) from an embedded task form.
Does anyone know please if Camunda supports this capability ?

Thanks in advance,
Steve


#2

Hi @steftriant,

do you want to create a PDF from data you provided or just upload a file using embedded forms?

KR
Martin


#3

Hi @martin.stamm and thanks for your feedback.

I simply want to create a pdf with the data I provided in the task form.
In the last stage of my process, one user receives a list of products and he can see this list in his taskform in Tasklist. I would like to generate a document which provides the same list.
Is this supported by some way in Camunda ?
Thank you,
Steve


#4

camunda itself does not offer this capability, but this can be achieved in 2 ways:

  1. Create the PDF in a separate Task and include a cam-file-download object

  2. Dynamically create the PDF in the form. jsPDF looks like it offers what you want to achieve. Include it as a custom script in Tasklist and you’re good to go.


#5

@martin.stamm, ok I 'm going to take a look as far as your 2nd hint is concerned.
About the 1st one, can I look somewhere in Docs ?

Which of these 2 ways do you recommend ?

Thanks,
Steve


#6

You can use a Service Task for option 1.

If you do not need the PDF for the rest of your process, you can create it in the Frontend. This also scales better than a service task.


#7

@martin.stamm, I need the pdf for the rest of my process, so I assume that if I select your 1st option here, I must do this via a Service Task.
But I would like to ask what do you mean by saying that I can create it in the Frontend ?

Thanks,
Steve


#8

In that case I recommend using a service task.

Basically option 2, your process would not know about the PDF because it is generated in the browser


#9

Hi @martin.stamm,

So, from your hints here, I assume that the dynamic creation of the PDF in the form (your 2nd option above) isn’t so convenient in my case.
Could you please make clear to me what do you mean here ?

 Basically option 2, your process would not know about the PDF because it is generated in the browser

What I want to do, is to simply send the generated pdf via email (so it could be done out of the process’s scope) and by this way my process is completed.
Could you please give me a hint (by Docs) about the creation of a document via a Service Task ?

Thank you a lot,
Steve


#10

Hi @steftriant,

You need to generate the PDF with a service task then :slight_smile:
A Service Task can execute arbitrary Java code. You can use a java library to generate your code, for example itext. There are many others.


#11

Hi @martin.stamm,

In your opinion, which implementation way is the easiest for a user like me (with very little experience in programming) ?
By calling Java code or in the form of an external task ?

Thanks a lot,
Steve


#12

Hi @steftriant,

As you want to send the PDF via email, you will have to create it by calling Java code.
There should not be much difference in complexity in my opinion.

KR


#13

Hi again @martin.stamm,

My exact purpose is to produce a pdf document (with iText library maybe) from an html task form like the following:

This task form is displayed when the user loads his form in “Receive the Selected Products” User Task:

So, I don’t want to create an empty pdf document but to convert the above html form.
Must I do sth before the conversion (such as to get the task form in the form of a file by REST API call for example) ?

Thanks a lot,
Steve