Header and Footer

Public forum for discussing TScaleRichView (shareware addon to TRichView providing WYSIWYG editing)
Post Reply
Posts: 4
Joined: Mon Nov 24, 2014 4:22 pm

Header and Footer

Post by RichardDufour » 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):

Code: Select all

procedure TRvViewer.srvOutputPaintPage(Sender: TObject; PageNo: Integer;
  PageRect, R: TRect; Canvas: TCanvas; Prepaint, Printing: Boolean);
  H : Integer;
  Text: String;


  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);



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,

Sergey Tkachenko
Site Admin
Posts: 14228
Joined: Sat Aug 27, 2005 10:28 am

Post by Sergey Tkachenko » Mon Nov 24, 2014 9:27 pm

As I can see from the post http://www.trichview.com/forums/viewtopic.php?t=6706, you need quite a complicated header, with multiple document sections and page numbers restarted in each sections. Sections are not supported, so the only way to add such headers is drawing them in OnPaintPage. Drawn headers are visible in TSRichViewEdit and can be printed, however, they cannot be saved in a file.
(even MS Word does not support such headers completely; it can have section with restarted page number, but it can display only a total number of pages).

I can still explain how to insert a plain text footer in ScaleRichView 6 (please update your version of components).
Make sure that srv.PageProperty.HeaderVisible = FooterVisible = True.
When generating document, you can add text in Subdocuments

Code: Select all

srv.Subdocuments[srvhftNormalHeader].AddNL('Sample header', 0, 0);
Like in older versions, you can use RVHeader and RVFooter for editing headers/footers, but:
- you need to activate editing header/footer
- you need to use editing methods, or call RVHeader.Change / RVFooter.Change, to inform the component that header/footer was changed

Code: Select all

srv.RVHeader.SelectAll; // to replace existing content
srv.RVHeader.InsertText('Sample text');
srv.StartEditing(srvrveMain); // back to the main document

Post Reply