In order to generate a document, go to templates and create a new one. Give this template a code, description and start filling it. The template has a built-in editor which can be used. Or you can create the content with pure html (click code).
The template can be filled with fields gathered during the script. Add the following in case you have used a form in your script [flow:firstname]. Instead of “firstname” select any relevant name of database field (see forms). Or make use of the system field names: eg [user:Full Name]