This InDesign XML tutorial describes a sample end-to-end workflow for XML pagination in Adobe InDesign. We’ll learn how to create a car catalog importing a XML file in InDesign.
You can freely download the InDesign XML project template from the button above and start practice with XML import in InDesign.
In your downloaded zip file, you will find a sample XML file, an IDML template, and the final document in PDF and InDesign format, complete with images and fonts.
InDesign XML workflows allow for close control over a document’s graphical elements and enable you to automate almost any kind of layout. But XML has a steep learning curve, and a dedicated team can be required to establish, maintain, and troubleshoot the logic behind even relatively simple operations.
Let’s start by taking a brief look at the XML file structure. In this tutorial we want to merge a list of cars. Each car has attributes that need to be imported (‘BRAND’, “CAR_MODEL’, ‘TYPE’ etc.) as well as an image.
The next step involves two InDesign tools. The first is the Structure panel. This panel contains all elements from our XML content. It also allows us to add, edit and delete elements and attributes to/from the existing structure. Access the Structure panel through View -> Structure -> Show Structure.
The second tool is the Tags panel. This panel contains a list of tags that are used for assigning XML elements that should be imported to the InDesign document. We can assign tags to texts and image placeholders. Access the Tags panel through Window -> Utilities -> Tags.
Return to the document’s first page and open the Structure panel. Click on ‘Import XML’ from the menu in the panel’s top-right corner (or through File -> Import XML in the main InDesign menu).
This option will open a new dialog box. Choose our XML file and check the ‘Show XML Import Options’ and ‘Merge Content’ options before opening it.
Uncheck all boxes in the next dialog box and then press ‘OK’.
The XML file has now been imported into our document. The document structure has been populated like the XML file, and the Tags panel has also been populated with the XML file’s corresponding elements.
We only need one car element for the mapping stage. Delete the rest from the Structure panel by selecting them, right clicking and pressing ‘Delete’.
We map the imported XML file by dragging and dropping elements from the Structure panel into the document or assigning tags to the document from the Tags panel.
Start by assigning the car’s root element with a specific object within the document. Do this by selecting a car from the Structure panel and dragging it over the main text frame on the first page. The frame will then be populated with all of the values and images that are contained within the car’s structure.
All fields are marked with square brackets and labeled with colors that match the Tags panel.
Be aware that some unwanted characters may have been inserted alongside the imported fields (e.g. tab and paragraph return characters). A useful tool for removing these characters can be found by selecting the text and choosing Edit -> Edit in Story Editor.
Reveal hidden characters by choosing Type -> Show Hidden Characters. Then proceed to delete any that are unnecessary.
Note: making text changes directly within the text frame offers the same results as edits made in the Story Editor, but using the Story Editor shows XML fields’ full names (vs. only simple brackets). This extended form can drastically simplify the editing process.
We can now customize our fields with InDesign’s graphic tools (paragraph styles, character styles, frame options etc.). In our example we’ve added labels before each field and given these labels a bold character style.
We can also make changes to the fields found above our main image – BRAND, CAR_MODEL and TYPE. We start this process by creating paragraph styles called ‘Brand’ and ‘Model’.
Next click on the top-right menu in the Tags panel and click on ‘Map Tags to Styles’. This will display a dialog box in which we can assign one of our paragraph styles to each tag – so in our case the ‘Brand’ paragraph style to the BRAND tag and the ‘Model’ paragraph style to the CAR_MODEL and TYPE tags.
Clicking ‘OK’ should reveal the following result:
Our final customization step involves adjusting the image frame. Start by selecting the frame and reducing the width. Then right click inside the frame, select Fitting -> Frame Fitting Options and selecting ‘Auto-Fit’ and ‘Fit Content Proportionally’. Ensure that all ‘Crop Amount’ values are set to 0. All newly imported images will now be fitted to the same frame size.
We’ve now completed the graphical customization. The following screenshot compares the preview and standard versions of our car style:
Save the document as an InDesign template (.indt format) and then close and reopen it.
The close and reopen step is important as we’re now opening an unnamed template instead of a named document. We can therefore reuse the template across numerous projects, which is especially useful if you’re creating huge catalogs, e.g. to have different, custom-named documents for each category.
The last section of this InDesign XML tutorial will see all of the cars’ elements imported to our template.
The process uses the same ‘Import XML’ method as above. As such: open the Structure panel and click on ‘Import XML’ from the menu in the panel’s top-right corner (or through File -> Import XML in the main InDesign menu). Choose our XML file and check both the ‘Show XML Import Options’ and ‘Merge Content’ options.
We now need to choose several options in the ‘XML Import Options’ dialog:
Create link: Ensures that any changes made to the imported XML file will be reflected in the new InDesign document.
Clone repeating text elements: Useful when your XML files have repeating elements, e.g. the repeating car elements in our file. InDesign will check these elements during the import process and clone them in the new document.
Do not import contents of whitespace-only elements: Prevents the import of elements that contain only whitespaces or break characters (e.g. paragraph returns).
Delete elements, frames and content that do not match imported XML: Deletes all content in the new document that is not found in the XML file.
Click on ‘OK’ in ‘XML Import Options’ to merge the new InDesign document with the XML elements.
You may notice that the BRAND and CAR_MODEL elements have been separated:
Correct this by selecting the ‘Brand’ paragraph style from the Paragraphs panel, right clicking and choosing ‘Edit Brand’. Then navigate to the ‘Keep Options’ section and add ‘1’ to the ‘Keep with Next’ field. This option will keep all ‘Brand’ styles together with the next styles.
Adobe InDesign Server is far less known than its desktop alternative. In this article, we outline what Adobe InDesign Server is, when to use it, and why and how Adobe InDesign Server is different from Adobe InDesign Desktop.
Users often find InDesign XML Import to be complicated and inefficient because:
You have to convert your data to XML and this is a complex project by itself (free tutorial and samples data here: from Excel to XML)
XML templates creation and InDesign field-mapping are rigid, and you have to foresee and hard-wire many basic typographic conventions in your templates.
To overcome these limitations there is a powerful solution that helps you create your documents faster and easier, and is called Pagination.