- How to replace images within a template document in Zapier
- 1. Create a template document in Google Docs
- 2. Add a 'Copy doc & fill in {{placeholders}}' action
- 3. Configure the action
- 4. Specify the new value of the placeholders tags and images
- 5. Export the Google Document to PDF or XLSX (Microsoft Word)
- Learn more about integrating with Google Docs and Google Drive
- Related blog posts
How to replace images within a template document in Zapier
Create a template document in Google Docs
If you don't have a template document already, create one in Google Docs. Tip: use the docs.new shortcut (did you know relay.new also exists? 😊)
What is a template document? It's a document that contains one or more {{placeholder}} tags wrapped in curly brackets. These documents are often used for templates for invoices, customer agreements, meeting notes, etc. These documents may also contain images that can be replaced
Add a 'Copy doc & fill in {{placeholders}}' action
Once you have a template document, add the Copy doc & fill in {{placeholders}} action to your playbook
Configure the action
Next, we'll configure the Copy doc & fill in {{placeholders}} action:
- First, we'll select our template document in the Template to copy picker
- Second, we'll define the naming pattern for all newly created copies from this template. We'll want to use some variable fields in the name of the new document. It's common to include a date or timestamp. In this case, we'll just use the name of the image file that was added to Google Drive that triggered the playbook.
- And finally, we select all the {{placeholder}} tags and images that we want to replace for each copy that's made
Specify the new value of the placeholders tags and images
Because our example template was simple and short, this will be quick.
- We'll use the Title of the newly uploaded image in Google Drive as to replace the {{file name}} placeholder in our template
- We'll use the actual file to replace the placeholder image in the document. Note that while in this case the file is coming from Google Drive, it can come from any other app that your playbook integrates with.
And that's it! Every time this playbook runs, a copy of the Google Document will be made and the placeholder tag and image will be replaced with the name and contents of the image that was uploaded to Google Drive.
Let's add one more step that shows how you can easily use and export the Google Document in various formats.
Export the Google Document to PDF or XLSX (Microsoft Word)
As it's not always desired to use a Google Document as the final output, it's very easy in Relay to export a Google Document to e.g. a PDF or XLSX (Microsoft Word) file. Various other formats are supported as well.
To do so, add any automation where you want to attach, insert or upload a file. In this example, let's send an email via Gmail.
The Attachments dropdown shows all file variables that are available in the playbook. You'll also see the newly copied Google Document listed there, with various export formats in the submenu. From here, you can pick PDF, Microsoft Word (XLSX), or any other format including HTML and even EPUB!