Page 1 of 1

Dynaform to PDF

Posted: Tue Sep 26, 2017 10:42 pm
by heemalkumar
Good Day All,
I am trying to figure out a way the form attached to the last Task prints to PDF by itself and gets saved somewhere.
Please advise how this could be done.

Many Thanks.

Re: Dynaform to PDF

Posted: Wed Sep 27, 2017 4:19 pm
by amosbatto
You need to create an Output Document with the variables used in your DynaForm in its template. Then, you can use a trigger to generate a PDF of the Output Document and then copy that PDF to a location. See example 3 in PMFGenerateOutputDocument().

Remember that if you fire a trigger immediately after a DynaForm, then the variables in that DynaForm have not yet been saved to the database, so you need to use PMFSendVariables() to save those variables (see the example). The other option is to fire the trigger before the next step in the task (or before assignment if the last step in the task), when the variables have been saved to the database.

If you don't want to use a trigger, then simply set the Output Document as a step in a task and let the user download the file and manually store the PDF file.

Re: Dynaform to PDF

Posted: Wed Sep 27, 2017 5:44 pm
by heemalkumar
Thanks Amos.
I would like my Dynaform to print to PDF just the way the user sees it when they were actioning a task. Would that be possible?

Re: Dynaform to PDF

Posted: Thu Sep 28, 2017 9:10 pm
by amosbatto
ProcessMaker provides an option to show a print button on DynaForms, which will generate a PDF similar to an Output Document.
printFormProperty.png
printFormProperty.png (27.14 KiB) Viewed 12536 times
It appears in the upper right hand corner of the DynaForm:
PrintUpperCorner.png
PrintUpperCorner.png (12.51 KiB) Viewed 12536 times
If clicked, then it opens a print dialog box for your operating system:
PrintIconUpperRightCorner.png
PrintIconUpperRightCorner.png (28.78 KiB) Viewed 12534 times
But it creates a PDF file without formatting:
PDFGeneratedFromScreen.png
PDFGeneratedFromScreen.png (18.5 KiB) Viewed 12536 times
If you want to automatically open the print dialog box when the DynaForm is submitted, then add this JavaScript code to your DynaForm:
Code: Select all
var printed = false;
getFormById( $("form").prop("id") ).setOnSubmit( function() {
  if (printed == false) {
     $("a.print-button").click();
     printed = true;
     return false;
  }
});
The problem is if you want the PDF to have the same style as your DynaForm. You can use an outside library like html2canvas, that creates a screenshot based on the DOM. I haven't tried it, so I don't know if it will render all the CSS correctly. There are also many plugins to take screenshots of web browsers. For example: http://designwebkit.com/web-design/fire ... re-addons/
There is no way (that I know) to use JavaScript with these plugins to take a screenshot of your DynaForm, so you have to rely on the user to do it manually.

Re: Dynaform to PDF

Posted: Thu Sep 28, 2017 11:25 pm
by heemalkumar
Hi There
Do you know if there is any Process Maker plugin which should do this task?

Re: Dynaform to PDF

Posted: Fri Sep 29, 2017 8:40 pm
by amosbatto
We don't have a plugin to take screenshots in PM. Your best bet is to use html2canvas or a similar library.

Re: Dynaform to PDF

Posted: Wed Nov 15, 2017 10:35 pm
by heemalkumar
Hi Amos,
So I have an issue now. I have an image appearing on my Dynaform.
Image goes from task to task properly and appears. however, when I am trying to Print the Dynaform to PDF, the image disappears. I am using the print button on Process Maker.
But when I just do a Ctrl+P, then the image does show up.

Would you know why that happens.
Attached screenshot.

Re: Dynaform to PDF

Posted: Thu Nov 16, 2017 7:42 pm
by amosbatto
Is your image a digital signature? If so, which digital signature (SigPlus, E-Lock or DocuSign)?

Re: Dynaform to PDF

Posted: Mon Nov 20, 2017 6:16 pm
by heemalkumar
Hi Amos
Yes, It is Topaz systems Inc.

Re: Dynaform to PDF

Posted: Mon Nov 20, 2017 7:53 pm
by amosbatto
PM doesn't have an integration with Topaz Systems. Are you implementing this in a Panel control in your DynaForm?

You should contact Topaz Systems and ask them if there is a way to save their digital signature as a graphics file. If so, you can fire a trigger after the DynaForm which uses the PMFAddInputDocument() function to add the signature graphics file as an Input Document. If the graphics file is only saved on the local PC, then you will have to upload the file to the PM server. See:
http://wiki.processmaker.com/3.0/Proces ... ding_Files

Then, your next step in the task can be an Output Document which contains:
<img src="/path/to/signature/file.jpg">

If Topaz Systems doesn't provide a way to save the digital signature as a graphics file, then you will have to use a web browser screenshot plugin like FireShot.