Join David Blatner for an in-depth discussion in this video Including images in your data, part of InDesign Insider Training: Data Merge and Database Publishing.
All the data that we've imported so far with data merge has been text. Now let's take it to the next level by adding images too. And remember, data merge can only understand CSV and tab-delimited text files. And neither of those can include image data. They're just text files. Even CSV is just a text file. So we can't put the image itself into the data file. Instead, we use the path to the image on disk. Here inside my Links folder in my Exercise Files folder, I see a bunch of images that I want to import with Data Merge.
That are all called these mysterious numbers for some reason. Now let's open this catalog data Excel file. I'll just double-click on that and it opens in Excel. And you can see that our spreadsheet has a column called Image. And that column contains the same file names, the same images that we were just looking at. Each image is associated with one record, one row in our document. Now there's two problems here. First, we need to tell InDesign's Data Merge feature that these are images, actual files on disk, not just text that should import like these other columns over here.
And the way you do that is by changing the header row slightly. For example, right now, it says Image. I'm going to change that by clicking up here in the data field, and I'm going to add an @ sign before the word Image. That's the trick. Any header that starts with the @ sign tells InDesign that this column is all images. Unfortunately the @ symbol means something special in Excel, it indicates a function. So if you're using Excel like I am here, you can't just type an @ sign.
It'll just give you an error. Instead, put a single quote, an apostrophe, just before the @ sign. I'll click here, and type quote. Then I'll press Return or Enter. And you'll see it works. I don't know why that works, but it does. Notice that the apostrophe doesn't even show up here inside the cell, but it's there. By the way, I should also point out that you don't have to call this column Image. You could call it Pictures or Graphics or anything else you want, but it has to have that @ sign at the beginning.
Okay. The second problem is that we have the names of all the files here but InDesign won't know where to find them. Like, are these inside a folder, are they on a server, are they in the same folder or different folders? In Design has no idea, so you have two choices here. One option is more complex but more flexible. The other is simple, but relies on all the images being inside the same folder. Let's look at the complex method first. In this method, you can put images anywhere you want, any folder you want, and even have different images in different folders.
The tricky part is, if you do that, you need to insert the actual file path instead of just the file name. Now, what do I mean by file path? Well, one way to find an image's file path is to place it in InDesign. Let me show you. I'll switch to InDesign, and I'll go to the File menu and create a new document. I'm just going to use the default settings here, doesn't matter at this point. And I'm going to go back to the File menu and choose Place. I'm going to grab any of these images, and click Open. And then I'll click and drag.
So I've placed this image inside my InDesign document, and now I can open my Links panel and I simply hover my cursor over that image. There it is. The tool tip shows me the path to this image. All the way from my computer, down to my users, down to my links file, and the image itself. Of course, seeing that path doesn't really help us. We need the text itself, the actual path. Fortunately, that's easy to grab. All I need to do is go to the Links Panel menu, scroll down to Copy Info, and then choose Copy Platform Style Path.
You don't want the full path, you want the platform style path. Platform here means Mac versus Windows, because the file path is slightly different on each. On the Mac, you get colons between the folder names. On Windows, you get backslashes. Anyway, I'll choose Copy Platform Style Path, and it copies that path onto my clipboard. Now, I could go back to Excel, select one of these cells over here. And then I'll paste with Cmd+V or Ctrl+V on Windows. You can see that that file name has been replaced with the actual path to the file.
So obviously if you had a bazillion images you would not want to do this one at a time, but if you had some database that generated the file paths for you, then this might work great. Okay, let's go look at the simpler method. The one that only works if all the images are in the same folder. And in this case, they are in the same folder. So it's going to work great. Let's undo this by pressing Cmd+Z, or Ctrl+Z on Windows. And the trick here is really, really easy. All you have to do is place your data file inside the same folder as the images. Your InDesign file can be anywhere.
But the data file, that csv or text file with the data in it, that should be in the same folder as the pictures. To do that, I'm just going to save a csv file out of Excel here, go to the File menu, choose Save As, go back to my links folder, and I'm going to call this CatalogDataSpring. And of course, I need to change this from a xlsx to csv. Once again, Excel always seems to warn me that it's going to lose data but it's not in this case because I'm just getting a csv file, so I'll click Continue.
Hey, by the way, I should mention that whether you choose the simple or complex method, the fact remains that the graphic, the image, has to be on disk. That means this will not work if your image is inside your database. You know, like if you pasted a photograph into FileMaker or whatever database you are using. Data merge can't deal with that. The image has to be on disk as a file. Okay. Now that we have our images and our data file, let's look at how to get all that data, including the images, into InDesign.
- Understanding data merge
- Setting up the data
- Creating the template
- Building a merged document
- Adding images
- Updating the data
- Extending Data Merge
- Helpful third-party plugins and scripts