Pages, spreads and layers
This document is about the structure of a document: spreads that hold pages, pages that hold elements, master spreads that repeated pages share — and layers that order it all. If you want to put something onto a page, first read the shapes and text frames chapters.
Table of contents
How it fits together
A document is a collection of spreads. A spread holds the pages that are visible next to each other. Every page holds the elements — rectangles, text frames, images. A master spread can be applied to pages so they inherit the same layout. Layers are the vertical ordering of all objects, like in InDesign.
Spread
A Spread is the container for the pages of your document. Set it up with the Factory — it is registered in the Content object automatically:
<?php
use BitAndBlack\IdmlCreator\Factory;
$factory = new Factory();
$spread = $factory->createSpread();
If you want to set your own unique identifier, create the Spread like that: $factory->createSpread('UniqueName');
Adding pages
Every page must be added to a spread:
<?php
use BitAndBlack\IdmlCreator\Content\Enum\Spread\PagePosition;
/** @var \BitAndBlack\IdmlCreator\Content\Spread\Spread $spread a spread, created above */
/** @var \BitAndBlack\IdmlCreator\Content\Page $page a page, set up below */
$spread->addPage($page, PagePosition::RIGHT);
The second parameter defines the position of that page:
LEFT: The page will appear on the left side of a document with facing pagesRIGHT: The page will appear on the right side of a document with facing pagesLEFT_OUTER: The page will appear on the outer left side of a document with facing pages. Every new page added with this option will be appended on the leftLEFT_INNER: The page will appear on the inner left side of a document with facing pages. Every new page added with this option will be appended on the right of all left pagesRIGHT_OUTER: The page will appear on the outer right side of a document with facing pages. Every new page added with this option will be appended on the rightRIGHT_INNER: The page will appear on the outer right side of a document with facing pages. Every new page added with this option will be appended on the left of all right pages
This will be the position of all options:
| LEFT_OUTER | LEFT | LEFT_INNER | Binding | RIGHT_INNER | RIGHT | RIGHT_OUTER |
|---|---|---|---|---|---|---|
| Left outer pages | Left page | Left inner pages | I | Right inner pages | Right page | Right outer pages |
| Latest added page left | Single page | Latest added page right | I | Latest added page left | Single page | Latest added page right |
Page
A Page is the sheet you place objects onto:
<?php
use BitAndBlack\IdmlCreator\Content\Page;
$page = new Page();
Format
Add the format like that:
<?php
use BitAndBlack\IdmlCreator\Content\Enum\Unit;
/** @var \BitAndBlack\IdmlCreator\Content\Page $page a page, created above */
$page->setFormat(210, 297, Unit::MILLIMETERS);
Add Unit::MILLIMETERS as third parameter if you prefer numbers in millimeters.
Margin
Add the margin like that:
<?php
use BitAndBlack\IdmlCreator\Content\Enum\Unit;
/** @var \BitAndBlack\IdmlCreator\Content\Page $page a page, created above */
$page->setMargin(10, 10, 10, 10, Unit::MILLIMETERS);
Columns
Set columns like that:
<?php
use BitAndBlack\IdmlCreator\Content\Enum\Unit;
/**
* @var \BitAndBlack\IdmlCreator\Content\Page $page a page, created above
* This will define 6 columns with a bridge of 5 millimeters
*/
$page->setColumns(6, 5, Unit::MILLIMETERS);
Let's count all together: We have a page width of 210 millimeters and margin of 10 on all sides, this gives us a type area of 210 – 10 – 10 = 190 millimeters. There are 6 columns and so are 5 bridges with a width of 5 millimeters, in total 25 millimeters. 190 – 25 = 165 millimeters width for all columns. 165 width divided by 6 columns = 27.5 millimeters width for each column.
Adding elements
Place the objects of the shapes and text frames chapters onto the page:
<?php
/** @var \BitAndBlack\IdmlCreator\Content\Page $page a page, created above */
/** @var \BitAndBlack\IdmlCreator\Content\Rectangle $rectangle a rectangle, created in the "shapes" chapter */
/** @var \BitAndBlack\IdmlCreator\Content\TextFrame\TextFrame $textFrame a text frame, created in the "text frames" chapter */
$page->addElement($rectangle, $textFrame);
MasterSpread
A MasterSpread holds pages that other pages can inherit their layout from. Set it up like a normal spread:
<?php
/** @var \BitAndBlack\IdmlCreator\Factory $factory the factory, initialized in the "Spread" section */
$masterSpread = $factory->createMasterSpread();
If a page should use the master spread, add the master spread to the page:
<?php
/** @var \BitAndBlack\IdmlCreator\Content\Page $page a page, created above */
/** @var \BitAndBlack\IdmlCreator\Content\Spread\MasterSpread $masterSpread the master spread created above */
$page->setAppliedMaster($masterSpread);
Be careful here! A page may inherit the objects like TextFrames or Rectangles, but you need to define the width, columns and bleed anyway by your own.
Layer
Layers order the objects of a document vertically. Set up a Layer object:
<?php
use BitAndBlack\IdmlCreator\Content\Layer;
$layer = new Layer();
Every layer needs to be added to the DesignMap:
<?php
/** @var \BitAndBlack\IdmlCreator\Factory $factory the factory, initialized in the "Spread" section */
/** @var \BitAndBlack\IdmlCreator\Content\Layer $layer the layer created above */
$factory->getDesignMap()
->addLayer($layer)
;
Color
Layers may have different colors when working in InDesign. Add a color from the Color Enum like that:
<?php
use BitAndBlack\IdmlCreator\Content\Enum\Color;
/** @var \BitAndBlack\IdmlCreator\Content\Layer $layer the layer created above */
$layer->addColor(Color::OLIVEGREEN);
Placing objects onto a layer
When working with layers in InDesign, the logic is to place an object into a layer. Our logic is different here: you need to tell an object to which layer it belongs.
<?php
use BitAndBlack\IdmlCreator\Content\Layer;
use BitAndBlack\IdmlCreator\Content\Rectangle;
$rectangle = new Rectangle();
/** @var \BitAndBlack\IdmlCreator\Content\Layer $layer the layer created above */
$rectangle->setItemLayer($layer);