Eventually, I decided to follow a different approach as far as the generation of the document.
My purpose here is to convert the following filled-in html form to a pdf document via a Service Task Java call.
As far as our recent discussion here is concerned, I managed to dynamically (on the submission of the form) generate and save in a directory path of my choice the PDF document
But, could I please ask for an additional help here ?
I would prefer to automatically download this document rather than simply save it.
From another thread here Dynamic cam variable name - #6 by steftriant I read that cam-file-download directive can only work on the initial load of the form and not on the submission like in my case.
Have you got any idea please on how could I overcome this issue ? I didn’t take any answer there.
First of all, thank you very much for your feedback
The PDF document is generated in the browser (on the submission of the task form) by using a Java library called openhtmltopdf.
Yes, of course the code part where the document is saved is the following :
Could you please guide me a bit on the required piece of code into the “submit” Event Listener ?
My generated doc isn’t previously declared as a process variable, so can I use the cam-file-download directive on the submission of the form ?
thank you for the information! I see that you use Java to create the PDF, so I believe that it is created on server side? I’m not a Java expert, so please correct me if I get something wrong.
So I can better get a better overview, can you please check: Is the PDF created on the server’s or on the client’s file system? How do you trigger the execution of the Java Code (e.g. Task Event Listener)?
thank you for your feedback!
I’m not also very experienced in Java but from what I read here https://www.quora.com/Is-Java-a-client-side-or-server-side-program
I imagine that since Java is considered to be a server-side language, you’re right.
I will ask a developper to be sure about your question with the file system and I will let you know of course
The Java class file (with the code for the creation of the pdf) is called by a “Complete” Task Listener in Modeler, yes
From what you wrote it seems to me that you create the PDF on the server. Before we can download it, you have to make it accessible to the Process Engine, e.g. by saving it as a process variable via the java API[1] instead of writing it to the file system.
Once you have that you can create a download link in a separate user Task.
I took a first look at your attached link and it seems very interesting, thanks a lot
Can I please ask you sth if you know ?
For created files which must be saved as process variables via the java API, the Typed Value API is considered to be more suitable ?
And do you know please what does it mean that “Files can be persisted as BLOBs in the database” ?
I have not worked with this part of the API yet, but from the documentation it seems that you need to use the Typed Value API to set metadata like filenames.
A BLOB is a Binary Large Object, so you can put any data you want in there.
Inside the Java code which is called via the “Complete” Task Listener, a new file value (with its metadata) is created (as described in the Typed Value Java API in the Docs here https://docs.camunda.org/manual/7.11/user-guide/process-engine/variables/#file-values) and in the succeeding html task form, the relative file can be downloaded via Camunda’s cam-file-download directive.
Thanks a lot again for your valuable hint
First: If you have problems with the Custom Scripts, please consider opening a new thread. Don’t necro-bump unrelated ones. Check https://forum.camunda.io/faq for our contribution guidelines.
Second: What excactly do you mean with “variable that references my library”? The post you are replying to shows a requireJS definition. You can rename jQuery to foobar in the config if you want to. It just loads a JS file. Check the requireJS documentation and Custom Script Documentation for more details.