ColdFusion 9.0 Resources |
Formatting headers and footersYou use DDX instructions to perform the following tasks:
Adding automatic page numbersTo add automatic page numbers, use the _PageNumber and _LastPagenumber built-in keys within the Header or Footer elements. The following code shows how to create footers with right-justified automatic page numbers: <Footer> <Right> <StyledText> <p>Page <_PageNumber/> of <_LastPageNumber/></p> </StyledText> </Right> </Footer> The first page of the output file is numbered “Page 1 of n”, and so on. For more information on built-in keys, see the Adobe LiveCycle Assembler Document Description XML Reference. Using style profilesThe previous example uses the StyledText element to define inline text formatting. To define styles that you can apply by reference, use the StyleProfile element. Style profiles let you apply a set of styles to different elements in the PDF output file. The following code shows how to define a style profile for the table of contents Header: <StyleProfile name="TOCheaderStyle"> <Header> <Center> <StyledText> <p> color="red" font-weight="bold" font="Arial">Table of Contents</p> </StyledText> </Center> </Header> </StyleProfile> To apply the style profile, specify the StyleProfile name by using the styleReference attribute of the Header element, as the following example shows: <?xml version="1.0" encoding="UTF-8"?> <DDX xmlns="http://ns.adobe.com/DDX/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ns.adobe.com/DDX/1.0/ coldfusion_ddx.xsd"> <PDF result="Out1"> <PDF source="Title"/> <TableOfContents> <Header styleReference="TOCheaderStyle"/> </TableOfContents> <PDF source="Doc1"/> <PDF source="Doc2"/> <PDF source="Doc3"/> <PDF source="Doc4"/> </PDF> <StyleProfile name="TOCheaderStyle"> <Header> <Center> <StyledText> <p> color="red" font-weight="bold" font="Arial">Table of Contents</p> </StyledText> </Center> </Header> </StyleProfile> </DDX> Grouping PDF documentsTo apply a style profile to a group of documents in the output PDF file, use the PDFGroup element. The following example shows how to create a group of chapters in the output file and apply a style profile to the Footer element for all of the documents in the group: <?xml version="1.0" encoding="UTF-8"?> <DDX xmlns="http://ns.adobe.com/DDX/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ns.adobe.com/DDX/1.0/ coldfusion_ddx.xsd"> <PDF result="Out1"> <PageLabel prefix="page " format="Decimal"/> <PDF source="Title"/> <TableOfContents> ... </TableOfContents> <PDFGroup> <Footer styleReference="FooterStyle" /> <PDF source="Doc1"/> <PDF source="Doc2"/> <PDF source="Doc3"/> <PDF source="Doc4"/> </PDFGroup> </PDF> <StyleProfile name="FooterStyle"> <Footer> <Left> <StyledText> <p font-size="9pt"><i>CFML Reference</i></p> </StyledText> </Left> <Right> <StyledText> <p font-size="9pt">Page <_PageNumber/> of <_LastPageNumber/></p> </StyledText> </Right> </Footer> </StyleProfile> </DDX> For a complete example, see Using DDX instructions to create a book. |