Workflow

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

Table of contents

Workflow

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:

<?php 

use IDML\Factory;

$factory = new Factory();

Create objects using the factory:

<?php

$paragraphStyle = $factory->createParagraphStyle('Body Text')
    ->setPointSize(12)
    ->setLineHeight(14.4)
;

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

<?php

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

$writer = new Writer(
    $factory->getContent(), 
    new Tree()
);

Write the IDML content into a file:

<?php

$writer->create('myFile.idml');

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