Example Uses

pdfMachine merge is a powerful tool which sends batches of personalized emails with personalized PDF attachments. It can be configured to perform the merges in a number of different ways.

Each row sends an email

A personalized email is sent for every email address in the data source.

e.g. A personalized certificate is sent for each row of the data source.

Guide me

Each row creates a PDF attachment

Each row in the data source file will generate an attachment. Emails are grouped together on consecutive email address.

e.g. To send certificates of completion for different courses taken by the one person. A data source file which has consecutive rows with the same email, however each row has the information for a different course. In this case, an attachment for each row will be generated. Each attachment will have the information specific to the course. The attachments are sent in a single email.

Guide me

One or more rows generates an email

Consecutive rows in the data source file that have the same email address can be "bundled" together to form a single email with a single attachment. The rows become line items for either the body or the attachment.

This is often the case when using data produced from database queries. Example uses are statements and invoices.

HTML with Javascript
Guide me

Example: Each row sends an email

pdfMachine merge installs with ready made profiles to get you started.
This example is "Test Profile - Each row sends an email"

pdfMachine merge uses a PowerPoint template and a CSV data source. Each row will cause an email with a single PDF attachment to be sent. Both the email and the PDF attachment will be personalized with information from the corresponding row.

Steps to create a merge profile

Data Source

Create the data to personalise the emails and PDFs.

Template

Create the layout for your dynamically generated PDF attachment.

Merge Profile

Configure pdfMachine merge to create and send the emails.

Example : Each row sends an email - set up the data source

pdfMachine merge installs with ready made profiles to get you started.
This example is "Test Profile - Each row sends an email"

Create a data source (this one is a CSV file) that has merge fields as column headings. Each row must have an email address. Create a row for each email that will be sent.

In this example four emails will be sent, each with a single PDF attachment.

Example : Each row sends an email - set up the template

pdfMachine merge installs with ready made profiles to get you started.
This example is "Test Profile - Each row sends an email"

Create a template (this one was created in PowerPoint) that has merge fields surrounded by {{ }}. The names of the merge fields must exactly correspond to the column names in the data source. The merge fields can be formatted using the Liquid Templating Language.

Example : Each row sends an email - create the profile

pdfMachine merge installs with ready made profiles to get you started.
This example is "Test Profile - Each row sends an email"

Create a profile within pdfMachine merge. Merge fields can be used - surrounded by {{ }}. Attach your data source and template. Set the Rows To emails method to "Each row creates an email".

. . .

Example : Each row creates a PDF attachment

This example can be found in the latest version as
"Test Profile - Each row creates an attachment".

pdfMachine merge uses a PowerPoint template and a CSV data source. pdfMachine merge will iterate through the rows of the data source generating a personalized PDF attachment for each row, the merge fields are replaced with the appropriate data from each row. On reaching a change in email address, pdfMachine merge will send an email with the generated PDFs as attachments. Both the email and the attached PDFs are personalized with information from the corresponding rows.

Steps to create a merge profile

Data Source

Create the data to personalise the emails and PDFs.

Template

Create the layout for your dynamically generated PDF attachment.

Merge Profile

Configure pdfMachine merge to create and send the emails.

Example : Each row creates a PDF attachment

pdfMachine merge installs with ready made profiles to get you started.
This example is "Test Profile - Each row creates an attachment"

Create a data source (this one is a CSV file) that has merge fields as column headings. Each row must have an email address. Create consecutive rows with the same email address to have that data bundled as attachments to one email.

In this example four emails will be sent.

  • The first will have 4 attachments
  • The second will have 2 attachments
  • The third will have 1 attachment
  • The fourth will have four attachments

Example : Each row creates a PDF attachment

pdfMachine merge installs with ready made profiles to get you started.
This example is "Test Profile - Each row creates an attachment"

Create a template (this one was created in PowerPoint) that has merge fields surrounded by {{ }}. The names of the merge fields must exactly correspond to the column names in the data source. The merge fields can be formatted using the Liquid Templating Language.

Example : Each row creates a PDF attachment

pdfMachine merge installs with ready made profiles to get you started.
This example is "Test Profile - Each row creates an attachment"

Create a profile within pdfMachine merge. Merge fields can be used - surrounded by {{ }}. Attach your data source and template. Set the Rows To emails method to "Each row creates an atachment".

. . .

One or more rows generates an email

(HTML with Javascript)

pdfMachine merge installs with ready made profiles to get you started.
This example is "Test Profile - HTML template with line items"

pdfMachine merge uses a HTML template and an Excel data source. Consecutive rows in the data source file that have the same email address are "bundled" together to form a single email with a single attachment. The rows become line items for either the body or the attachment. Javascript is used to iterate through the bundled rows, displaying them as line items within the PDF. An email with a single PDF attachment will be sent. Both the email and the PDF attachment will be personalized with information from the corresponding rows.

Javascript is a procedural language that supports such things as "for loops", "conditionals", and "math operations". More info here

Steps to create a merge profile

Data Source

Create the data to personalise the emails and PDFs.

Template

Create the layout for your dynamically generated PDF attachment.

Merge Profile

Configure pdfMachine merge to create and send the emails.

One or more rows generates an email

(HTML with Javascript)

pdfMachine merge installs with ready made profiles to get you started.
This example is "Test Profile - HTML template with line items"

Create a data source (this one is a CSV file) that has merge fields as column headings. Each row must have an email address. Create consecutive rows with the same email address for each line item that you want in the PDF.

In this example 3 emails will be sent each with a single attachment.

  • The first will have 5 line items
  • The second will have 4 line items
  • The third will have 1 line item

One or more rows generates an email

(HTML with Javascript)

pdfMachine merge installs with ready made profiles to get you started.
This example is "Test Profile - HTML template with line items"

Create a template using HTML

  • Surround the merge fields that are not to be used as line items with {{ }}. The names of the merge fields must exactly correspond to the column names in the data source. The merge fields can be formatted using the Liquid Templating Language.
  • <tr>
        <td>Invoice Number</td>
        <td>{{invoice_id}}</td>
    </tr>
  • Create the javascript to iterate through the bundled rows (as shown below).
  • Sample Javascript

    Your HTML template should contain the following special tag:

    var data = {{json_here}};

    When processed by pdfMachine merge HMTL templates will have this substituted with a JSON (JavaScript Object Notation) string containing all the data for the bundled rows. This allows a you to write javascript that iterates through the data, for calculation or rendering. This allows a you to write javascript that iterates through the data, for calculation or rendering. The "json_here" tag will look like:
    var data = [
    {"email": "wayne@acme.com","customer": "Acme Corp","invoice_id":223,"invoice_date": "23/01/2011 12:00:00 AM","item": "blue widget","unit_cost":23,"quantity":4,"amt_due":391},
    {"email": "wayne@acme.com","customer": "Acme Corp","invoice_id":223,"invoice_date": "23/01/2011 12:00:00 AM","item": "red widget","unit_cost":21,"quantity":2,"amt_due":391},
    ];

    Javascript can then be used to iterate through the data array to create HTML to display the line items.

    function generateLineItems()
    {
        var html = "<table class='hor-minimalist-b'><thead><tr><th>Item</th><th>Quantity</th><th>Unit Cost</th><th>Price</th></tr></thead>\
        <tfoot><tr><td></td><td></td><td></td><td class='amountDue'>${{amt_due}}</td></tr></tfoot><tbody>";
    
        for (var i = 0; i < data.length; i++)
        {
            var ob = data[i];
            html += "<tr><td>" +
            ob.item + "</td><td>" +
            ob.quantity + "</td><td>" +
            ob.unit_cost + "</td><td>" +
            "$" + ob.quantity*ob.unit_cost + "</td></tr>";
        }
        html += "</tbody></table>";
    
        document.getElementById("lineItemsTable").innerHTML =html;
    }
                        
  • When using HTML templates, don't forget set your page setup in Internet Explorer for things such as Paper Size and Orientation, Headers, Footers, Margins, Background printing, and shrink to fit page. You should also set your Broadgun pdfMachine print preferences. This example should be set up as :
  •  

One or more rows generates an email

(HTML with Javascript)

pdfMachine merge installs with ready made profiles to get you started.
This example is "Test Profile - HTML template with line items"

Create a profile within pdfMachine merge. Merge fields can be used - surrounded by {{ }}.

The Rows To emails method is set at "One or more rows generates an email".

. . .