is now part of!

Make Scalable Shapes with Data Merge

4 0

Data Merge is a feature of InDesign that I use regularly to prepare personalized mail campaigns. (Editor’s note: see Colin’s excellent in-depth article about Data Merge in InDesign Magazine issue 52.) Recently, I discovered a feature that made it possible to scale shapes during a Data Merge! It uses a combination of Data Merge, some “no fill or stroke” type, and the auto-size feature of text boxes introduced in InDesign CS6.

For this to work, a few things are required:

  • A csv or txt file that has numbers between 1-1000 in the fields;
  • The font “Chartwell Bars” (actually, I’ll talk about how you can do it without this font at the end of this article)
  • The shape to be scaled… it has to be a closed vector that can be drawn either in InDesign or cut and pasted from Illustrator to InDesign.

Here is how this trick works:

  1. From the Data Merge palette, choose “Select Data Source” to begin a data merge. The data field that will be responsible for changing the size of the shape needs to have numbers between 1-1000 within that field.
  2. Make the appropriate shape in InDesign (or cut and paste a single solid shape from Illustrator into InDesign) and make sure it is a text frame. If necessary, turn the shape into text-frame by clicking inside the shape with the text tool.
  3. Add the variable data field containing the variable number to the shape, and set the font to Chartwell Bars. Make sure Discretionary Ligatures formatting is turned on, and give the text a fill and stroke of None.
  4. Then you need to change some text frame options: particularly the auto-size drop down field in the Text Frame Options dialog box. If a shape is to be scaled proportionally, select “height and width (keep proportions)”, and then set a height (or width, it doesn’t really matter) constraint for the minimum size to zero. If the shape is to be distorted, then the appropriate height/width only option is selected, again with a minimum size of the shape of zero. Its origin point is then one of the nine points that can be selected from the auto-size feature. The appearance of the shape can also be influenced by the vertical justification of the text.

The following pictures show what is happening. To understand how this works, I’ve set the font color to black in the images below, and I’ve inserted pink dots to indicate the origin points of the shapes. The word «no» indicates the data merge number field.


More after the jump! Continue reading below
Free and Premium members see fewer ads! Sign up and log-in today.

The blue triangle scales left to right only, while the circle and star will scale proportionally based on their origin points. Here is what happens when the preview checkbox is toggled on, showing the value of the first record (527):


And now, to the next record (the number 165):


Finally, here is how the shapes look when the Chartwell Bars font is coloured with no fill or stroke:


As you can see, the value in the field changes the size of the object!

There are some conditions with the trick:

  • The value of the variable data must a whole number be between 1 and 1000. It cannot be blank, zero, or anything else.
  • This slows down the speed of the data merge, even more so when this trick is used more than once on a page.
  • The shape has to be a single shape that can become a text placeholder when a text cursor is placed into it. Luckily the shape can be complicated and even contain effects from InDesign’s effects panel.

For users who do not have the Chartwell Bars font, a similar trick can be achieved by replacing the numbers with short or long words. Because the font within the scalable shape has no fill or stroke, the words used won’t be seen, but instead the space the words occupy will shrink or expand the scalable shape. Using the Chartwell Bars font works better for shapes that require precision or a greater range of scalability.

A prepress operator and graphic designer for a South Australian commercial printer, with close to 20 years of experience in the trade. He is also a regular contributor to this site and InDesign Magazine, and hosts his own prepress blog "Colecandoo".
  • This card game designer thanks you. It’d be trivial to follow this process up with a search/replace to remove the filler text, and less trivial but do-able to script a way to drop images into all of these shapes. My brain is popping with ideas for this. :D

  • Jean-Claude Tremblay says:

    Really clever trick! Using tabular lining number could be use and size calculated easily.

    That a fabulous first blog post on indesignsecrets. Keep them coming Colin.

  • Kyla says:

    Is there any way to control *whether or not* the shapes appear, rather than their size?


    • Data Merge doesn’t have many “triggers” (i.e. if/else statements), if any at all. GREP styles are the closest feature available, and allows incoming data to formatted to a limited extent – that is the font size, style colour can be changed, but not adding/removing anything from the data (e.g. formatting the number 15999 to be $15,999.00 isn’t possible).

      An alternative would be to make your shapes in illustrator and call the shapes in as images using data merge. Any scaling will need to be done in the images themselves, so if the image size changes, these changes have to be done as separate images. The up-side is if a shape shouldn’t appear, then there is a blank in the database, therefore an image won’t appear.

  • >