回复 1楼fenghud的帖子
TX 的页眉和页脚只能以奇数页偶数页、FirstPageHeader和FirstPageFooter进行操作,无法单独操作特定于页面和页脚。
- TXTextControl.Section currentSection = textControl1.Sections.GetItem();
- TXTextControl.HeaderFooter currentHeader =
- currentSection.HeadersAndFooters.GetItem(TXTextControl.HeaderFooterType.EvenHeader);
- if (currentHeader == null)
- {
- currentSection.HeadersAndFooters.Add(TXTextControl.HeaderFooterType.EvenHeader);
- currentHeader = currentSection.HeadersAndFooters.GetItem(TXTextControl.HeaderFooterType.EvenHeader);
- }
- currentHeader.Selection.Text = "This is a header with an image aligned to the right.";
- TXTextControl.HeaderFooter currentFooter =
- currentSection.HeadersAndFooters.GetItem(TXTextControl.HeaderFooterType.Footer);
- if (currentFooter == null)
- {
- currentSection.HeadersAndFooters.Add(TXTextControl.HeaderFooterType.Footer);
- currentFooter = currentSection.HeadersAndFooters.GetItem(TXTextControl.HeaderFooterType.Footer);
- }
- currentFooter.Selection.Text = "Page ";
- currentFooter.PageNumberFields.Add(new TXTextControl.PageNumberField(1, TXTextControl.NumberFormat.ArabicNumbers));
- currentFooter.Selection.Text = " of " + textControl1.Pages.ToString();
- currentFooter.Selection.ParagraphFormat.Alignment = TXTextControl.HorizontalAlignment.Center;
复制代码 |