How to Automatically Create PDFs with Google Form Responses
Google Forms are the best tool for creating online polls, surveys, quizzes, and questionnaires. The form submissions are automatically stored in Google Spreadsheets, making it easier for you to analyse the submissions, and your forms can receive an unlimited number of responses.
When a user submits your Google Form, a row is added to the destination Google Sheet with all the answers. The tutorial explains how you can save your Google Form responses in a customized PDF file in Google Drive and have it emailed automatically to one or more recipients via Gmail.
For this example, we are building an event registration form with Google Forms. The attendees fill the form, select the session(s) they wish to attend and an email confirmation is sent to them instantly. A PDF document is attached and it contains the form answers and also a dynamic QR Code that can be scanned at the event venue.
Create PDFs with Google Forms - DEMO
Before we get into the implementation details, please try the live workflow so you have a better idea of what we are building.
First, fill-in this Google Form and submit. Your form response is saved in this Google Sheet and, within a few seconds, you’ll receive a personalized email with a PDF attachment. It contains a QR code and a unique registration ID that is generated automatically with the QRCODE formula.
Internally, the workflow is using this Google Document to merge the Google Forms data into a PDF file. We picked PDF for this example but you can generate documents in any format including Word documents, Excel Spreadsheets, PowerPoint Slides, ePub and more.
How to Create PDF Documents with Google Form Responses
To get started, create a new Google Form and choose a destination Google Spreadsheet where the responses would get saved.
Next, create a template in either Google Docs, Google Slides or Google Sheets. In your template, the variable fields should be enclosed inside double curly braces and the field name should exactly match the question title in your Google Form.
For example, if your Google Form question is “Full Name”, the marker in your document template would be {{Full Name}}
and it will be automatically replaced with the answer submitted by the form submitter.
Next, install Document Studio for Google Sheets and authorize the add-on. Now open the Google Spreadsheet that is storing your Google Form responses, go to the Add-ons menu, choose Document Studio and open the sidebar to build the workflow.
First, expand the Document Merge section and choose the document template from Google Drive that you have created in the previous step. Choose a file name of the exported file - it can be a fixed name - like event.pdf - or a dynamic name like {{full name}}.pdf
where the file name is customized based on file answers.
Next, expand the Mail Merge section in Document Studio’s sidebar, turn on the “Send Emails” option and create an email template using the built-in WYSIWYG editor.
You can customize the template by adding variable placeholders, like {{First Name}}
, in the email subject and message body for personalized emails. Choose the field where you asking for the submitter’s email address to send them an email when they submit the form. You can add more emails (comma-separated) in the “Email Specific People” to notify more people when forms are submitted.
If you would like to add markers to the merged document that aren’t present in the Google Form, you can use the help of Google Sheets array formulas.
For instance, if your Google Form question is Full Name, you can add a new column in the Google Sheet for First Name and use the following formula to automatically get the first name from Google Form submissions that can be used in the email and document template.
Also see: How to Send Personalized Emails with Gmail
Finally, expand the “Finish and Merge” section and check the option Merge on Form Submit. Click Save to turn the workflow and submit a test entry in your Google Form.
You should find a personalized email with the merged document as a PDF attachment in your Gmail sent items. A copy of the PDF file is saved in your Google Drive that you can use to automatically print the Google Form response via Google Cloud Print.
If you are stuck, please watch the video tutorial for a visual walkthrough.
Amit Agarwal
Google Developer Expert, Google Cloud Champion
Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.
Amit has developed several popular Google add-ons including Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory