- Offizieller Beitrag
Q: How to append section with individual footer
A: You can use WPRichText1.ActiveParagraph.StartNewSection to add a new section property object to the current paragraph. The return object will be an object of class TWPRTFSectionProps. In property 'Select' you can change which properties should be used for this section.
Using WPRichText1.HeaderFooter.Append you can append a new RTFDataBlock to be used as footer. 'Get' cannot be used, since this will reuse an existing RTFDataBlock.
Code
procedure TForm1.PortraitLandscapeClick(Sender: TObject);
var sect : TWPRTFSectionProps;
footer : TWPRTFDataBlock;
begin
WPRichText1.CPPosition := MaxInt;
Inc(c);
// start a section
sect := WPRichText1.ActiveParagraph.StartNewSection;
sect.Select := [wpsec_PageSize]; // 1. (in this order!)
sect.Landscape := Sender = Landscape; // 2.
// Now new page and some text
WPRichText1.InputString(#12+#32+IntToStr(c)+#13);
// also add special header+footer for this section
footer := WPRichText1.HeaderFooter.Append(wpIsFooter,wpraOnAllPages,'');
footer.UsedForSectionID := sect.SectionID;
WPRichText1.ActiveText := footer;
WPRichText1.InputString('Section ' + IntToStr(c) + #9);
WPRichText1.InputTextFieldName('PAGE');
WPRichText1.ActiveParagraph.TabstopAdd(
sect.PageWidth-sect.LeftMargin-sect.RightMargin,
tkRight,
tkUnderline );
// select body again
WPRichText1.ActiveText := WPRichText1.BodyText;
end;
Alles anzeigen