Working with Pages
QXML for page
Page is represented by the <qx-page> node. It contains the following attributes:
|
Attribute |
Value |
Description |
|
|
|
number |
Index of the page |
|
|
|
|
Specifies whether a page should be on the left or right of the spine |
|
|
|
Specifies that page is on left side of the spine |
||
|
|
Specifies that page is on right side of the spine |
||
|
|
text |
Identifies the master-page that is applied to a page |
|
Create a new page
To create a new page:
-
Get the DOM of the active layout.
-
Create a new
<qx-page>element. -
Set the
page-indexattribute in the<qx-page>element. -
Set the
page-positionattribute in the<qx-page>element. -
Set the
applied-master-pageattribute in the<qx-page>element. -
Append the
<qx-page>element as a child of the<qx-spread>node.
Sample JavaScript:
var layout = app.activeLayoutDOM();
var spread= layout.getElementsByTagName('qx-spread')[0];
var page = document.createElement('qx-page');
page.setAttribute('page-index','2');
page.setAttribute('page-position','right');
page.setAttribute('applied-master-page','A-Master A');
spread.appendChild(page);
Delete existing page
To delete an existing page:
-
Get the DOM of the active layout.
-
Get the
<qx-page>node corresponding to the page to be deleted. -
Remove the
<qx-page>child node from the<qx-spread>node.
Sample JavaScript:
var layout = app.activeLayoutDOM();
var spread= layout.getElementsByTagName('qx-spread')[0];
var page = layout.querySelector("qx-page[page-index='2']");
spread.removeChild(page);