2022.2

Table Of Contents
beusedtocreateaTableOfContents(TOC),asexplainedinthetopic:"CreatingaTableOfContents"
onthenextpage.
ThistopicexplainswhataPostPaginationScriptisandhowtoaddittoatemplate.
Thebasicsofscript-writingintheDesignerareexplainedinthefollowingtopic:"Writingyourown
scripts"onpage368.
WhatPostPaginationScriptsare
PostPaginationScriptsareaspecialkindofDesignerscript:theyareappliedtotheoutputofallsec-
tionsinaPrintcontextafterthecontenthasbeenpaginated.
PostPaginationScriptsdifferfromStandardScriptsandControlScriptsintwoways:
l
PostPaginationScriptsrunafterallotherscripts,moreprecisely:afterthecontenthasbeen
paginated.ThepaginationprocessappliespagebreakstothecontentofaPrintsection,adds
MasterPagesandsetstheMedia.APostPaginationScriptmayquerytherendereddocument
andcollectinformationaboutelements(forinstance,onwhichpagetheyresideon)andsections
(forinstance,whethertheyareenabled).Ifneeded,aPostPaginationScriptcanchangethe
sheetconfigurationandre-paginateasection.
l
PostPaginationScriptsonlyapplytothePrintcontext.Theoutputofothercontextsisnotpagin-
ated.
JustlikeStandardScripts,PostPaginationScriptshaveaselector(see:"SelectorsinOLConnect"on
page385).Aselectorselectspartsofthecontentofasectionandstoresthemintheresultsobject,
sothattheycanbemodifiedinthescript(see"results"onpage844).
ThesecondmostimportantobjectinaPostPaginationScript,justlikeinaControlScript,isasection
(see"section"onpage848).
WhattouseaPostPaginationScriptfor
AfterallPrintsectionshavebeenpaginated,PostPaginationScriptsmaysearchthroughtherendered
documentandcollectinformationaboutelements(forinstance,whichpagetheyresideon)andsec-
tions(forinstance,whethertheyareenabled).Withthisinformation,aPostPaginationScriptcando
twothings:
l
Modify the output.Thescriptmaymodifytheoutputofasection.Itcould,forexample,use
informationlikepagenumberstocreateaTableOfContents(TOC),asexplainedinthetopic:
"CreatingaTableOfContents"below.Ifneeded,aPostPaginationScriptcanchangethesheet
configurationandre-paginatethesection(see"paginate()"onpage855.
l
Add information to the Connect database.Thescriptmayaddproductioninformation,such
asthepage,sizeorpositionofelementsafteramerge,ascustompropertiestoaPrintContent
Page 410