Working with Spreads
QXML for spread
Spread is represented by the <qx-spread> node. It contains the following attributes:
|
Attribute |
Value |
Description |
|
|
number |
Index of the spread |
Create new spread
To create a new spread:
-
Get the DOM of the active layout.
-
Create a new
<qx-spread>element. -
Set the
spread-indexattribute in the<qx-spread>element. -
Append the
<qx-spread>element as a child of the<qx-layout>node.
Sample JavaScript:
var newSpread = document.createElement("qx-spread");
newSpread.setAttribute("spread-index", "2");
var page = document.createElement('qx-page');
page.setAttribute("page-index", "2");
page.setAttribute("applied-master-page", "A-Master A");
page.setAttribute("page-position", "right");
newSpread.appendChild(page);
var spread = layout.getElementsByTagName('qx-spread')[0];
spread.parentNode.appendChild(newSpread);
Delete existing spread
To delete existing spread:
-
Get the DOM of the active layout.
-
Get the
<qx-spread>node corresponding to the spread to be deleted. -
Remove the
<qx-spread>child node from the<qx-layout>node.
Sample JavaScript:
var layout=app.activeLayoutDOM();
var spreads=layout.getElementsByTagName('qx-spread')[1];
layout.removeChild(spreads);