PTC ALD in Arbortext Styler > Components of Documents and Templates > Driving Page Layout > Page And Document Sequence Control > Page Sequence Control Streams
  
Page Sequence Control Streams
A page sequence control stream defines the page types that should appear in a sequence such as a chapter, a book, or a module of data. The page sequence control stream defines the conditions under which a page type should be used. It is represented in the Formatting Object Model by the fPageSequence object. This object is created using the fContent.createPageSequence() method, as shown in this example:
var pSeq;
pSeq = template.content.getPageSequence("myChapterPageSequence");
if (!pSeq) {
pSeq = template.content.createPageSequence("myChapterPageSequence");
}
This example tests if the page sequence myChapterPageSequence exists, and creates it if not. This is a recommended practice when creating objects, to avoid errors.
The fPageSequence object has a single rules property. The property is an array of the rules that define the page types that PTC Arbortext Layout Developer should apply. Rules are added and removed using the fPageSequence.addRule(), fPageSequence.removeRule(), and fPageSequence.clearRules() methods. The addRule() and removeRule() methods take an fPageSequenceItem object.
The fPageSequenceItem object represents three types of rule:
A single page of a particular type
This type of rule is typically used for title pages. For example:
var singlePage = new fPageSequenceItem;
singlePage.layout = "myTitlePage";
singlePage.maxRepeats = 1;
where myTitlePage is the name of the layer group which defines the page type to use. Setting the maxRepeats property to a value of 1 outputs a single page.
A repeating sequence of the same page type
This type of rule is used when a single page layout is required throughout a document, for example in a simple book. Use similar code to that shown in the previous example, setting the maxRepeats property to the required value:
var repeatedPage = new fPageSequenceItem;
repeatedPage.layout = "myTitlePage";
repeatedPage.maxRepeats = 0;
A value of 0 for the maxRepeats property instructs PTC Arbortext Layout Developer to use that page layout until it receives an instruction to stop.
Set maxRepeats to a specific value, for example 9, to repeat a page a set number of times. When PTC Arbortext Layout Developer has completed the set number, it moves on to the next rule defined in the page sequence control stream. If that next rule is empty, it ends the page sequence.
If no page layouts are defined, PTC Arbortext Layout Developer stops formatting.
A repeating set of alternatives from which PTC Arbortext Layout Developer selects the most appropriate layout based on conditions
The majority of publications require different page layouts for left and right pages, first pages, blank pages, and so on. PTC Arbortext Layout Developer’s page sequences provide the conditions property on the fPageSequenceItem to support this requirement. The conditions property is a list of fPageSequenceCondition objects which define the layout to use and the circumstances under which to use it.
A simple condition is to output alternative left and right pages. For example:
var leftRightPages = new fPageSequenceItem;
//Create right page condition
rightPageCondition = new fPageSequenceCondition;
rightPageCondition.layout = "myRightPageLayout";
rightPageCondition.testPosition = fPageSequenceCondition.POSITION_ANY;
rightPageCondition.testSide = fPageSequenceCondition.SIDE_ODD;
rightPageCondition.textContent = fPageSequenceCondition.CONTENT_ANY;
leftRightPages.addCondition(rightPageCondition);
//Create left page condition
leftPageCondition = new fPageSequenceCondition;
leftPageCondition.layout = "myLeftPageLayout";
lefttPageCondition.testPosition = fPageSequenceCondition.POSITION_ANY;
lefttPageCondition.testSide = fPageSequenceCondition.SIDE_ODD;
leftPageCondition.textContent = fPageSequenceCondition.CONTENT_ANY;
leftRightPages.addCondition(leftPageCondition);
The fPageSequenceItem object has four properties:
layout — specifies the layer group to apply if the condition is selected
testPosition — defines where the page layout should be used within the sequence, whether it is first, last, or any page. Use this property if you want a first left or right page that is different from the others in the sequence. Supported values are provided in the fPageSequenceCondition.PageSequenceConditionPosition constant.
testSide — instructs PTC Arbortext Layout Developer to apply the layout on odd or even pages. The supported values are provided in the fPageSequenceCondition.PageSequenceConditionSide constant.
testContent — instructs PTC Arbortext Layout Developer to apply the page either as a blank or with content. These blank pages are used when the page sequence is applying blank pages to meet force start and force end conditions, not because there are multiple page breaks in the content. The supported values are provided in the fPageSequenceCondition.PageSequenceConditionContent constant.
Using these tests together allows you to build up a set of conditional page layouts based on almost any conditions.