TWPTextObj.RelY in OnGetSpecialText behaves differently for Header and Footer
1.7k Views
2 links 2 users
1 ♥ read 2 min
Any object is always connected to a TWPTextObj which is handled by the paragraph, the anchor - here txtObj.
The text object controls where the object is placed.
If you set txtObj.PositionMode := wpotPage you can position it on page coordinates.
#2
♥ 1
I'm creating a text box both in the header and footer in the OnGetSpecialText event. I want to move these text boxes using the RelY property so that they are aligned with the page margins:
This works fine for the header. But for the footer it just increases the footer area and the text box stays at the same place:
This is how I move the text boxes:
procedure TForm.WPGetSpecialText(Sender: TObject;
Par: TParagraph; posinpar, pagenr: Integer; Kind: TWPPagePropertyKind;
var IsLastPage, UseThis: Boolean; var SpecialText: TWPRTFDataBlock);
var
txtBox: TWPORTFTextBox;
txtObj: TWPTextObj;
textBoxName: String;
begin
if ( Kind = wpIsFooter ) and ( WP.PageCount > 1 ) then
begin
textBoxName := Format( 'Footer#%d', [ PageNr ] );
SpecialText := WP.HeaderFooter.Get( wpIsFooter, wpraNamed, textBoxName );
end
else if ( Kind = wpIsHeader ) and ( PageNr > 1 ) then
begin
textBoxName := Format( 'Header#%d', [ PageNr ] );
SpecialText := WP.HeaderFooter.Get( wpIsHeader, wpraNamed, textBoxName );
end
else
Exit;
if SpecialText.Empty then
begin
txtObj := WP.TextObjects.InsertTextBox( 2000, 0, SpecialText.FirstPar );
txtBox := TWPORTFTextBox( txtObj.ObjRef );
txtBox.ObjName := textBoxName;
txtBox.AsString := Format( '<p align=right><font size=2>%s</font></p>', [ '579,66' ] );
txtBox.WidthTW := txtObj.Width;
txtBox.HeightTW := txtObj.Height;
txtObj.Frame := [];
txtObj.RelX := WP.Header.PageWidth - WP.Header.LeftMargin - txtObj.Width;
txtObj.RelY := offsetY; // 690
end;
end;
What is the problem here?
#1
♥ 0