Header and Footer
Posted: Mon Nov 24, 2014 6:34 pm
I have researched this for 2 days now. Went over all the demos, read tones of posts, still cannot get to display a header or footer.
Can someone please explain to me how this works.
1. What do I have to do to display a simple text header?
2. What do I have to do to display a simple footer (i.e. "Page x of y")?
// Tried these but have no effect/makes no difference...
MySRichViewEdit.PageProperty.FacingPages := False;
MySRichViewEdit.PageProperty.HeaderVisible := True;
MySRichViewEdit.PageProperty.FooterVisible := True;
MySRichViewEdit.ViewProperty.HeaderTitle := 'Test Header';
MySRichViewEdit.ViewProperty.FooterTitle := 'Test Footer';
MySRichViewEdit.ViewProperty.SRichViewEdit.RVHeader.Visible := True;
MySRichViewEdit.ViewProperty.SRichViewEdit.RVHeader.InsertText( 'Test' );
This component is so confusing, what is the difference between using:
A) MySRichViewEdit.RVHeader.InsertText( 'Test' );
B) MySRichViewEdit.ViewProperty.SRichViewEdit.RVHeader.InsertText('Test')
Why would I choose one method over the other??
BTW, never got neither to work.
I even tried a suggested onPaint event (didn't work either):
Can someone please explain to me how this works.
1. What do I have to do to display a simple text header?
2. What do I have to do to display a simple footer (i.e. "Page x of y")?
// Tried these but have no effect/makes no difference...
MySRichViewEdit.PageProperty.FacingPages := False;
MySRichViewEdit.PageProperty.HeaderVisible := True;
MySRichViewEdit.PageProperty.FooterVisible := True;
MySRichViewEdit.ViewProperty.HeaderTitle := 'Test Header';
MySRichViewEdit.ViewProperty.FooterTitle := 'Test Footer';
MySRichViewEdit.ViewProperty.SRichViewEdit.RVHeader.Visible := True;
MySRichViewEdit.ViewProperty.SRichViewEdit.RVHeader.InsertText( 'Test' );
This component is so confusing, what is the difference between using:
A) MySRichViewEdit.RVHeader.InsertText( 'Test' );
B) MySRichViewEdit.ViewProperty.SRichViewEdit.RVHeader.InsertText('Test')
Why would I choose one method over the other??
BTW, never got neither to work.
I even tried a suggested onPaint event (didn't work either):
Code: Select all
procedure TRvViewer.srvOutputPaintPage(Sender: TObject; PageNo: Integer;
PageRect, R: TRect; Canvas: TCanvas; Prepaint, Printing: Boolean);
var
H : Integer;
Text: String;
begin
inherited;
if Prepaint then
Exit; // *** EXIT RIGHT HERE ****
Canvas.Brush.Style := bsSolid;
Canvas.Brush.Color := clRed;
Canvas.Font.Assign( srvOutput.RichViewEdit.Style.TextStyles[0]) ;
// Drawing header
H := srvOutput.TopMargin100Pix;
Text := 'Page ' + IntToStr(PageNo);
Canvas.FillRect( Rect( PageRect.Left, PageRect.Top, PageRect.Right, PageRect.Top + H ) );
Canvas.TextOut( ((PageRect.Left + PageRect.Right - Canvas.TextWidth(Text)) div 2),
PageRect.Top+H div 2, Text );
// Drawing footer
H := srvOutput.BottomMargin100Pix;
Text := 'Sample Footer';
Canvas.FillRect( Rect(PageRect.Left, PageRect.Bottom - H, PageRect.Right, PageRect.Bottom ) );
Canvas.TextOut( ((PageRect.Left + PageRect.Right - Canvas.TextWidth(Text)) div 2),
PageRect.Bottom - H div 2, Text);
end;
[code]
I also need to have a footer (i.e. "Page x of y"), how can I archive that?
I will do whatever is recommended, please just let me know of one way to do it.
Thanks in advance,
Richard