Take a survey

Developing Applications Using APIs > Assembling PDF Documents > Adding and Manipulating Page Content > Adding and removing headers and footers > Adding headers and footers

Adding headers and footers
The Header and Footer elements specify page content that appears at the top and bottom of the page, respectively. Headers and footers are located on the page as follows:
The outer margins are determined by the PageMargins elements in effect for the given page. (See Page margins.) For headers, the left, top, and right margins apply. For footers, the left, bottom, and right margins apply. The default margins are 36 points (.5 inches).
Header and Footer elements have the child elements Left, Center and Right, which specify parts of the header or footer:
Left supplies content that is justified to the left margin.
Center supplies content that is centered on the page.
Right supplies content that is justified to the right margin.
Note: The page margins determine where to place the text or graphics but do not provide a clipping boundary. For example, a left-justified header can overflow the right margin if it is too wide.
Header and Footer elements can be children of the following elements, which correspond to the pages on which they can appear:
PDF or PDFGroup elements (source pages)
TableOfContents or TableOfContentsPagePattern elements (table of contents pages)
BlankPage elements (blank pages)
You can also specify Header and Footer elements within named StyleProfile elements (see Using style profiles) so that they can be referred to by name from within the parent elements.
In LiveCycle 7, when you specified a header or footer for a page (even if it contained no text or graphics), any header or footer that was previously added to the page was removed. In LiveCycle ES 8.0 and later you can retain pre-existing headers and footers by setting the replaceExisting attribute to false. For more information, see the Document Description XML Reference.
You can specify a different Header or Footer for even and odd pages within a given scope (see Odd and even pages).
If Header or Footer are not explicitly specified for the current scope but are specified for a parent scope, the parent Header or Footer apply to the current scope.
You can specify the contents of the header and footer fields in one of two ways:
By using a page from a PDF document (specified by a PDF source element) as a graphic. The first page from the pages specified by the PDF source is used.
The next figure shows the elements of a header and footer including the padding below the header, and padding above the foot and the margins. The following example shows the corresponding DDX.
Example: Adding headers and a footer
<PDF result="doc2.pdf">
	<PDF source="doc1.pdf">
		<Header padding=".3in">
			<Right> 
				<StyledText><p>Right-justified header</p></StyledText>
			</Right>
			<Left> 
				<StyledText><p>Left-justified header</p></StyledText>
			</Left>
		</Header>
		<Footer padding=".25in">
			<Center> 
				<StyledText><p>A centered footer</p></StyledText>
			</Center>
		</Footer>
	</PDF>
</PDF>	
Here is an alternative way to specify the same information:
Example: Specifying headers and footers with the styleReference attribute
<PDF result="doc2.pdf">
	<PDF source="doc1.pdf">
		<Header styleReference="myProfile"/>
		<Footer styleReference="myProfile"/>
	</PDF>
</PDF>	
<StyleProfile name="myProfile">
	<Header padding=".3in">
		<Right> 
			<StyledText><p>Right-justified header</p></StyledText>
		</Right>
		<Left> 
			<StyledText><p>Left-justified header</p></StyledText>
		</Left>
	</Header>
	<Footer padding=".25in">
		<Center> 
			<StyledText><p>A centered footer</p></StyledText>
		</Center>
	</Footer>
</StyleProfile>
In the example, the Header and Footer elements have a styleReference attribute that refers to a style profile. Style profiles (specified by the StyleProfile element) can contain information about headers, footers, watermarks, backgrounds, tables of contents, or date patterns. See Using style profiles for more information.
Note: In terms of scope, Header and Footer elements that refer to definitions within StyleProfile elements are treated as if the definition appeared directly inline.
The next example shows different headers specified for odd and even pages and also specifies different page margins for odd and even pages. In addition, the Header elements specify true for the shrinkContentToFit attribute, which means that the content of the page is reduced in size to fit between the header and the bottom of the page. The default value is false, which means the header could possibly overlap some of the content at the top of the page.
Example: Specifying headers and footers for alternating pages
<PDF result="doc2.pdf">
	<PDF source="doc1.pdf">
		<PageMargins left="1in" top="0.5in" right="0.5in" 
			bottom="0.5in" alternation="OddPages"/>
		<PageMargins left="0.5in" top="0.5in" right="1in" 
			bottom="0.5in" alternation="EvenPages"/>
		<Header alternation="EvenPages" shrinkContentToFit="true">
			<Center> <StyledText><p>Confidential</p></StyledText></Center>
			<Left><StyledText><p>Draft</p></StyledText></Left>
		</Header>
		<Header alternation="OddPages" shrinkContentToFit="true">
			<Center> <StyledText><p>Confidential</p></StyledText></Center>
			<Right><StyledText><p>Draft</p></StyledText></Right>
		</Header>
	</PDF>
</PDF>
The other sections in this chapter contain additional examples of creating headers and footers.

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/assemblePDFPage_content.103.3.html