public class HeaderFooter extends XmlEntityWithInternals
Represents a header or footer of a page in a Pdf document.
[Java] Pdf pdf = new Pdf(); Section section = new Section(pdf); pdf.getSections().add(section); HeaderFooter hf1 = new HeaderFooter(section); section.setOddHeader ( section.setEvenHeader ( hf1)); hf1.setIsFirstPageOnly ( true); Text text = new Text(hf1); hf1.getParagraphs().add(text); Segment segment = new Segment(text); text.getSegments().add(segment); segment.setContent ( "header for first page"); HeaderFooter hf2 = new HeaderFooter(section); section.setAdditionalOddHeader ( hf2); hf2.setIsSubsequentPagesOnly ( true); text = new Text(hf2); hf2.getParagraphs().add(text); segment = new Segment(text); text.getSegments().add(segment); segment.setContent ( "odd header for subsequent pages"); HeaderFooter hf3 = new HeaderFooter(section); section.setAdditionalEvenHeader ( hf3); hf3.setIsSubsequentPagesOnly ( true); text = new Text(hf3); hf3.getParagraphs().add(text); segment = new Segment(text); text.getSegments().add(segment); segment.setContent ( "even header for subsequent pages"); for(int i = 1; i <= 6; i++) { Text text1 = new Text(section); text1.setIsFirstParagraph ( true); section.getParagraphs().add(text1); Segment segment1 = new Segment(text1); text1.getSegments().add(segment1); segment1.setContent ( "page " + i.toString()); } pdf.save(...); [XML] <?xml version="1.0" encoding="utf-8" ?> <Pdf xmlns="Aspose.Pdf"> <Section > <Header IsFirstPageOnly="true"> <Text> <Segment>header for first page</Segment> </Text> </Header> <Header Type="odd" IsSubsequentPagesOnly="true"> <Text> <Segment>odd header for subsequent pages</Segment> </Text> </Header> <Header Type="even" IsSubsequentPagesOnly="true"> <Text> <Segment>even header for subsequent pages</Segment> </Text> </Header> <Text IsFirstParagraph="true"> <Segment>page1</Segment> </Text> <Text IsFirstParagraph="true"> <Segment>page2</Segment> </Text> <Text IsFirstParagraph="true"> <Segment>page3</Segment> </Text> <Text IsFirstParagraph="true"> <Segment>page4</Segment> </Text> <Text IsFirstParagraph="true"> <Segment>page5</Segment> </Text> <Text IsFirstParagraph="true"> <Segment>page6</Segment> </Text> </Section> </Pdf>
Modifier and Type | Field and Description |
---|---|
float |
DistanceFromEdge
Gets or sets a float value that indicates the Header or Footer's distance from
the edge of the page.The unit is point.
|
GraphInfo |
GraphInfo
Gets or sets a
GraphInfo object that indicates the graph info
of the header or footer. |
boolean |
IsFirstPageOnly
Gets or sets a bool value that indicates whether the header or footer be printed on first page only.
|
boolean |
IsLastPageOnly
Gets or sets a bool value that indicates whether the header or footer be printed on last page only.
|
boolean |
IsSubsequentPagesOnly
Gets or sets a bool value that indicates whether the header or footer be printed not on first page but
on subsequent pages only.
|
MarginInfo |
Margin
Gets or sets a
MarginInfo object that indicates the margin info of the
header or footer. |
Paragraphs |
Paragraphs
Gets or sets a
Paragraphs collection that indicates all paragraphs in
the header or footer. |
TextInfo |
TextInfo
Gets or sets a
TextInfo object that indicates the text info of
the header or footer. |
Constructor and Description |
---|
HeaderFooter()
Initializes a new instance of the
HeaderFooter class. |
HeaderFooter(Section section)
Initializes a new instance of the
HeaderFooter class. |
Modifier and Type | Method and Description |
---|---|
void |
load(com.aspose.ms.System.Xml.XmlTextReader xmlReader,
LoadingContext context)
Clones a new
HeaderFooter object. |
public TextInfo TextInfo
Gets or sets a TextInfo
object that indicates the text info of
the header or footer.
public GraphInfo GraphInfo
Gets or sets a GraphInfo
object that indicates the graph info
of the header or footer.
public Paragraphs Paragraphs
Gets or sets a Paragraphs
collection that indicates all paragraphs in
the header or footer.
public MarginInfo Margin
Gets or sets a MarginInfo
object that indicates the margin info of the
header or footer.
public float DistanceFromEdge
Gets or sets a float value that indicates the Header or Footer's distance from the edge of the page.The unit is point. In XML,the default unit is point,but cm and inch are also supported. For example,"10cm" or "5inch".
public boolean IsFirstPageOnly
Gets or sets a bool value that indicates whether the header or footer be printed on first page only.
The default value is false.If this property is set to true, the IsSubsequentPagesOnly
should be false.
public boolean IsLastPageOnly
Gets or sets a bool value that indicates whether the header or footer be printed on last page only. The default value is false.
public boolean IsSubsequentPagesOnly
Gets or sets a bool value that indicates whether the header or footer be printed not on first page but
on subsequent pages only. The default value is false. If this property is set to true, the IsFirstPageOnly
should be false.
public HeaderFooter()
Initializes a new instance of the HeaderFooter
class.
public HeaderFooter(Section section)
Initializes a new instance of the HeaderFooter
class.
section
- The section object.
Section
object.
public void load(com.aspose.ms.System.Xml.XmlTextReader xmlReader, LoadingContext context)
Clones a new HeaderFooter
object. all format and conent is cloned.
load
in class XmlEntityWithInternals
Copyright © 2014 Aspose. All Rights Reserved.