This script automatically emails the submission from a Google Form as a PDF. The PDF is created by populating a Google Doc template from the values in the Google responses spreadsheet.
The script takes the fields from the form submission row and using a Google Doc template (identified by TEMPLATE_ID) creates a PDF doc with these fields replacing the placeholders in the template. The place-holders are identified by having a % either side, for example, %Name%.
As well as being automatically triggered by a form submission it can also be invoked using the “Create PDF” custom menu in the responses spreadsheet.
You can optionally specify a name for the PDF file by providing a field called “File Name”.
Take a look at the Form Publisher add-on if you want an off the shelf solution.
Setting up the script
The easiest way to get going is to take a copy of the demo GSheet (File > Make a copy…). This contains the script and creates a new GForm for you to customise. You then need to create the “on form submission” trigger”, create a Google Doc template and link it to the script.
UPDATE: The menu has now been updated to allow you to enable/disable the form submission “create PDF” trigger.
- Open the script editor (Tools > Script editor…)
- Open the trigger’s (Edit > Current project’s triggers)
- Trigger createPdf() “on form submission”
- On clicking Save “Allow” the permissions the trigger requests
- Create your own Google Doc template for the PDF using place-holders of the form %[field name]%. For example %Name%. This is an example GDoc.
- In the script editor add the template doc ID (https://docs.google.com/document/d/ID NUMBER HERE/edit)
- Add you own EMAIL_SUBJECT and EMAIL_BODY in the script
You can now open the Google Form (probably called “Copy of PDF Creator – Email on form submit” at this point) and do a test submission to your own email address.
If you have already created the form you can copy the script below into your own responses sheet.
Here is the Gist of the script.