This document is about the basic workflow of setting up and creating an IDML document.

Table of contents


To create an IDML document, a Content object is needed, holding all the IDML components. Inside the Content object are all styles, spreads, pages, stories, and so on.

All classes can be initialized manually, but the recommended way is to use the Factory class. It will register the objects automatically in the Content object, which allows us to write less code. Here's an example:

Initialize the Factory at first:


use IDML\Factory;

$factory = new Factory();

Create objects using the factory:


$paragraphStyle = $factory->createParagraphStyle('Body Text')

When your document is ready and every piece of content has been created, create a new writer object and give it your content:


use IDML\Writer\File\Tree;
use IDML\Writer\Writer;

$writer = new Writer(
    new Tree()

Write the IDML content into a file:



You can find more information about using the Content and the Factory classes here.