Batch generate PDF tickets from HTML template based on CSV records in Power Automate

This article describes how to batch generate tickets from an HTML template for conference visitors or any event attendees based on CSV rows data. Let’s imagine you have a CSV file with conference visitors’ information. You need to generate personal invitations to the event for every attendee and send them by email.

We’ll show you how to automate this case using Processes and the Parse CSV action by Plumsail Documents in Power Automate (Microsoft Flow).

Processes are an intuitive interface for creating documents from templates.

Parse CSV is an action for MS Flow which parses a CSV file into an array of objects with properties.

Configure the process

First, we will configure the Process and then create a Flow.

Create a new process

Go to the Processes section in your Plumsail account.

You can use the HTML template of event tickets for conference visitors. We have prepared it beforehand.

HTML event invitation template for conference visitors

Click on the Add process button and select Upload a document when creating the process and upload the template you downloaded earlier.

Upload HTML template using Upload a document

If you would like to create the template yourself, select Start from blank when creating the process.

Add process button in Plumsail Documents

Set the Process name. Then select HTML for a template type.

Create process with HTML template type selected

Click on the Create to continue.

Configure a template

Once you’ve created the process, you need to Configure Template.

There are several template configuration options:

  • Editor;

  • Settings.

In Editor, you can create the template from scratch or upload a pre-made one. It’s also possible to modify the uploaded template online.

Templating syntax

Our HTML template is very simple. The template contains a few tokens: {{NameOfEvent}}, {{date}}, {{time}}, and {{place}}. They will be replaced by information about the conference.

To get familiar with the template syntax, read the HTML templates documentation.

Test the template

To check how the final document looks, click on the Test template button.

You’ll see a form with fields from your template tokens. You can adjust the default form. Find more information in the Adjust auto-generated form documentation.

Test form for HTML event invitation template

To test the HTML template, enter some data into the fields.

Note

It’s a test. We’ll pass data from the parsed CSV file to the process.

Once you’ve tested the template, press Save.

Switch process mode to Production to remove Plumsail watermarks from resulting documents.

Switch template mode to Production

Template settings

Go to the Template settings and configure the following settings:

  • Fill Output filename of the result file

  • Select PDF format for the Output file type

Configure PDF output and result file name for HTML template

Once you’ve customized all the settings, you can test the template to see the result.

When everything is done here, click on Save.

Delivery

The next step is delivery. We select Gmail delivery to send event invitations to conference visitors.

Enter {{email}} to the email field. The Parse CSV action will retrieve every conference visitor’s email. We will pass it to the Process to send personalized emails automatically.

Define the message’s subject and body. Inside them use tokens as well to make invitations personalized. For instance, we put {{Name}} at the beginning of the email body. This token will be replaced by real conference visitors’ names from the CSV file.

Configure Gmail delivery for generated PDF invitations

You can configure as many deliveries as you need. Check out the list of available deliveries as well.

Start the process

We will start our Process from Power Automate (Microsoft Flow).

Create a flow

This is how our Flow looks:

Power Automate flow for generating PDF tickets from CSV data

Flow trigger

You can pick any trigger. For example, you can start this Flow on event creation in the Office 365 Outlook calendar. We use Manually trigger a flow for simplicity.

Get file content

We store our CSV file sample in OneDrive. To read its content, we assign the action Get file content from the OneDrive connector. This action gets the content of the file in the OneDrive folder. You just need to specify the path to it.

Get CSV file content from OneDrive

It’s possible to use the Get file content action from other connectors. It depends on where you store the source file.

For you to try the same case as in the article, you can download the sample CSV file.

Parse CSV

This is an action from Plumsail Documents connector. It parses a CSV file into an array of objects with properties in Power Automate (Microsoft Flow).

Using the action for the first time, you’ll be asked for Connection Name and Access Key.

Create Plumsail Documents connection in Power Automate

You can type any name for the connection. For example, Plumsail Documents.

Then create an API key in your Plumsail Account page, copy and paste it into the Access Key field.

Parse CSV action has two mandatory parameters:

  • Content of CSV document. Select an output from the previous step File content in Dynamic content.

  • Headers. List all the headers you will use, separated by commas. We need the following information about the conference visitors - First Name, Last Name and Email.

Configure Parse CSV action with CSV content and headers

You can find more detailed information about Parse CSV action in the Parse CSV action documentation.

Start document generation process with json

Before adding this action, set up the Apply to each control. It will help to generate as many tickets as there are rows in the CSV file and send an email to each event attendee from the CSV file.

Start document generation process with json is also an action from the Plumsail Documents connector for Power Automate. It will start the process which we have already created and configured on the step Configure the Process.

The action has two parameters:

  • Process name. Select the process you need from the available ones.

  • Template data. Use the output of Parse CSV to specify JSON data. We use First Name and Last Name for token {{Name}} and Email output for {{email}} to pass all the emails from the CSV to the Process.

Do not forget to set values for tokens from the HTML template - the conference details.

Configure document generation process with process name and template data

Our Flow is ready. It will apply data from CSV rows to the HTML template to generate personal invitations in PDF and send them by email.

Each event visitor will receive a personalized email with the conference ticket attached:

Personalized email with generated PDF ticket attached Generated PDF event ticket

It’s one of many examples. You can use the same logic for your own scenarios.

Sign up for Plumsail Documents

To start optimizing processes, register a Plumsail account and follow the steps described in the article to batch generate event tickets from HTML templates based on CSV rows data.