Skip to main content
We no longer support Internet Explorer. Please upgrade your browser to improve your experience. Find out more.

Populate pages in an instant with Affinity Publisher’s powerful Data Merge Manager

Nobody wants to spend a lot of time copying and pasting information into a publication. This efficient feature might save you the bother.

Data merge enables you to create versions of an Affinity Publisher document in which portions of content are replaced by data from a data merge source (herein referred to as a data source for brevity).

Common uses of data merge include print runs of business cards and personalised mailouts, and its power also quickly progresses more ambitious projects like catalogues and brochures.

This article will give you practical experience of using data merge. All the necessary files are provided for you.

How data merge works

A few steps need to be taken so that Affinity Publisher knows where you want it to insert data, which can be text and pictures.

To prepare an Affinity Publisher document for data merge:

  1. Ideally, design the document with data merge in mind from the start. Throughout this article, you’ll learn considerations to make.
  2. Connect a data source to the document. It can be in one of several specially formatted (yet common) file formats.
  3. Insert fields from the data source into the document. You’ll be familiar with fields already if you have ever told Affinity Publisher to automatically add page numbers to a document, for example.

You can then generate a new data-merged document, which repeats the original document’s pages as many times as necessary to display the data source’s records.

Let’s look at the process in more detail. Start by downloading and extracting the practice files. You’ll also need the Roboto and Roboto Condensed font families from Google Fonts.

Download Practice Files

Learn the fundamentals with business cards

Among the unpacked practice files, open the Business card folder.

The business-card.afpub file contains a single page for a one-sided card design. It needs to be prepared for data merge as described a moment ago.

The practice document contains a finished business card design but it requires a few extra steps to be ready for data merge.

Open employees.csv in a text editor, such as TextEdit (Mac) or Notepad (Win). Data sources tend to be machine-generated rather than hand-typed, but it’s helpful to understand the CSV (comma-separated values) format used here.

The CSV-formatted data merge source for the business cards, as it appears in a text editor.
  • The first line lists the names of fields. These will be displayed in Affinity Publisher’s Fields Panel.
  • A delimiter indicates the end of one field and the start of another. We’ve used a comma because it isn’t needed in any record values—see tip below.
  • Subsequent lines contain records. In this project, there is a record for each person who needs a business card.
  • Records are made up of values, which are separated by the same delimiter used in the first line. It is these values that will be merged with your document design.
  • Field names and values may optionally be surrounded by quotation marks. However, there should not be spaces between them.
  • An individual record does not have to contain a value for every field. In this data source, not everyone has a telephone number, which is indicated by two quotes with nothing between them.
  • A carriage return at the end of a line marks the end of a record.
  • The last line can contain a record or a blank line. Affinity Publisher will simply ignore the latter.

Close the data source.

Connect the data source

Return to the business card document in Affinity Publisher.

  1. Select Document > Data Merge Manager.
  2. At the bottom left of the manager, select Add Data Merge Source.
  3. Browse to and open the employees.csv file.
In the Data Merge Manager, confirm the CSV-formatted data merge source’s delimiter and quote characters are correct to ensure the source is properly interpreted.

In the manager’s Source section, the default Delimiter and Quote settings are correct for our data source. You’ll use the manager further in a moment but, for now, click Close.

Insert fields into the document

The document contains pre-styled text as placeholders for where an employee’s name, role and contact details will be displayed.

Replace the placeholders with fields from the data source.

  1. Select View > Studio > Fields to open the Fields Panel.
  2. On the panel, expand the section labelled Data Merge - employees.csv.
  3. For each placeholder in turn:
    1. Select all of its text.
    2. On the Fields Panel, double-click the corresponding field to replace the selection with it.
Inserting fields from a data source into an Affinity Publisher document.

Preview the data merge

Use the Data Merge Manager’s Preview section to check, one record at a time, that the real data fits well in your design.

This means you needn’t generate a data-merged document and scroll through its pages, which might take a while for a large data source—especially one that places images into picture frames.

Does any record’s text—a long name, say—overflow its frame or cause surrounding text to reflow in an unanticipated way?

The Data Merge Manager enables you to preview how different records, such as with empty or long values, will look in your document design.

If many records do not fit the design, amend the document before proceeding with data merge. You might do so even if there are just a few issues.

Generated documents are editable, though, so you can make changes in isolation when absolutely necessary. For example, you might not want to reduce a font size universally if only a few records need it.

Generate a data-merged document

The Data Merge Manager’s Filter section enables a subset of a data source’s records to be processed. This is a useful option but we’ll stick with the All Records setting in this article.

Click Generate to proceed with the data merge. Soon, you’ll see a new document in which each page is a different person’s business card, ready to export a PDF file for client approval and send to a printing service.

Using data merge layouts

With the technique you’ve learned so far, each generated variation of your original document’s pages contains data from a single record.

In publications like catalogues and brochures, a single page might need to display data from multiple records. To achieve this, you’ll use Affinity Publisher’s Data Merge Layout Tool.

A data merge layout is a table-like structure in which objects added to the top-left cell are repeated in all other cells.

For hands-on experience of this, do the following:

  1. Create a new document that contains two facing pages.
  2. Select the Data Merge Layout Tool.
  3. On the left page, draw a data merge layout that fills the page to its margins. Keep the layout selected.
  4. Use the Ellipse Tool to draw a circle within the layout’s top-left cell. The shape is automatically repeated in all other cells.
Drawing a data merge layout and drawing new objects directly into it.

Note that the top-left cell can contain multiple objects, including text objects that contain fields.

The power of data merge layouts

Think back to the business card example. For each record in the data source, a copy of the original document’s page was generated in the data-merged document.

Let’s say you inserted a second instance of a field, either on the existing page or a second one (for a double-sided card design). Each generated page, or group of two pages, would display the corresponding value from a single record in both places.

What’s special about data merge layouts is that each cell is populated with data from a different record.

Also, you’ll soon see that each data merge layout in a document needn’t use the same visual design or display the same number of columns and rows.

Let’s get more ambitious

From the practice files, look in the Catalogue folder and open catalogue.afpub. The picture frame and text frame on its left page need to repeat in columns and rows across both pages.

To ensure the document is connected to the data source, open the Data Merge Manager, click Select, browse to the Catalogue folder and open products.tsv.

Previously, you selected a data merge layout and drew objects directly into it. Objects can be included in a layout even if they were drawn outside of it, so let’s see how this is done:

  1. On the left page, draw a data merge layout that fills the page to its margins.
  2. On the context toolbar, set Columns to 2, Rows to 3, and Gutter to 1.5mm.
  3. Deselect the data merge layout. (This is just to emphasise the point.)
  4. On the Layers Panel, select the picture and text frames’ layers.
  5. Drag the layers to the bottom of the data merge layout’s layer and then slightly to the right, and drop them when an insertion point appears.
Adding existing objects to a data merge layout.

You have established a parent-child relationship between the data merge layout and both frames, respectively.

Positioning objects within the top-left cell’s visual boundary is important, but it’s this relationship that tells Affinity Publisher to repeat them in all of a data merge layout’s cells.

How data flows into data merge layouts

Duplicate the data merge layout in the equivalent position on the right page. Your document should now look like this:

Each of these two pages contains one data merge layout. In fact, a page can contain several. You’ll see an example of how that is useful later.

The Data Merge Manager is automatically aware of all the data merge layouts in a document. So, unlike linking text frames to specify how text flows through them, you don’t need to do the same for data merge layouts.

The manager uses the number of cells in all of the layouts to calculate how many times it needs to repeat the original document’s pages.

When there are insufficient records to populate all of the cells in the repeated pages, the objects repeated in those cells are simply deleted, leaving white space on the last page or spread. Remember that generated documents are fully editable, enabling you to adapt the design in this situation.

Two things to take care of in a generated document: the design ramifications of insufficient records, and pictures that need resizing within their frames.

Automatically placing images

Data merge works for images as well as text. In the generated document shown above, the data source included references to externally stored images.

Inserting a field into a picture frame is simple. Select a picture frame and then double-click the relevant field on the Fields Panel. A photo-like icon indicates a picture frame contains a field.

A photo-like icon is displayed in a picture frame that contains a field.

Your workflow might address image composition with data merge and picture frame dimensions in mind. If not, check generated documents and resize pictures within their frames as necessary.

Get creative with data merge layouts

From the practice files, open catalogue-2.afpub and, like earlier, use the Data Merge Manager to ensure it is connected to the products.tsv data source.

Earlier, we mentioned that each data merge layout in a document can have different settings. Compare the presentation of the data merge layouts on pages 1 and 2 of this document.

Presentation of records can differ between a document’s data merge layouts. Here, the left page contains a single picture frame that isn’t part of a data merge layout at all.

On Page 1, the large picture frame is intended to display a single image of multiple catalogue items. It is independent of the data merge layout, which doesn’t display any picture frames—unlike the data merge layout on Page 2.

The Data Merge Manager will ignore Page 1’s picture frame, so a picture has to be manually placed in it.

Explore the other pages of the document to see how differently they incorporate data merge layouts.

Check generated documents for overflowing text and edit as necessary. When images are placed manually, as here, you might add annotation badges or lines to establish connections to generated text.

When you first drew a data merge layout, its table-like look might have seemed uninspiringly rigid. By now, though, you can see that data merge layouts can be used in practical and creative ways.