#1 2026-02-02 04:15:49

Sapiem
Member
Registered: 2017-12-08
Posts: 76

How set LineSpacing inside Header and Footer

Setting LineSpacing doesn't change the line spacing within the header or footer. In a header using Tahoma 18, the spacing is too much for the style we want. I need the lines to be perfectly continuous with minimal spacing.

      // Encabezado
      Reporte.Font.Size := 18;
      Reporte.Font.Style := [TFontStyle.fsBold];
      Reporte.AddTextToHeader('Header line 1');
      Reporte.AddTextToHeader('Header line 2');
      Reporte.Font.Size := 0;
      Reporte.AddLineToHeader(false);

Is there any way to design a header more specifically, for example, adding vertical text, text and graphics in specific positions, etc.?

Last edited by Sapiem (2026-02-02 04:26:57)

Offline

#2 2026-02-02 09:33:46

rvk
Member
Registered: 2022-04-14
Posts: 154

Re: How set LineSpacing inside Header and Footer

As far as I could see the Header/Footer in mormot.ui.report is just printed as is, separate lines with no special layout. You can't even position text.

I had some specific requirements of other parts of the "report" mechanisme... so I took the whole TGdiPages and stripped out everything I didn't need (which was a lot). Ended up with just under 700 lines of code. So that might be the way to go if you need something special from Header and Footer. Or try to inherit TGdiPages and change the things you need (but I'm not sure how far you can go with that). You could also just generate the headers and footers yourself.

Offline

#3 2026-02-02 20:15:49

Sapiem
Member
Registered: 2017-12-08
Posts: 76

Re: How set LineSpacing inside Header and Footer

Before modifying the code, I checked whether there were non‑public variants available. For example, OnStartPageHeader might serve as a way to customize the Header. However, I cannot find any public documentation describing how to handle the Header group from that event

Offline

#4 2026-02-02 20:20:09

rvk
Member
Registered: 2022-04-14
Posts: 154

Re: How set LineSpacing inside Header and Footer

ab wrote:

See the OnStartPageHeader and OnEndPageHeader event handlers.
The Sender is the current TGDIPages instance.

You can easily add a bitmap to every header using one of those events.

https://synopse.info/forum/viewtopic.php?id=598

Offline

#5 2026-02-02 20:33:01

Sapiem
Member
Registered: 2017-12-08
Posts: 76

Re: How set LineSpacing inside Header and Footer

Where can I found any example o documentation? In mormot.ui.report only we can find:

/// Event triggered when each new header is about to be drawn
    property OnStartPageHeader: TNotifyEvent
      read fStartPageHeader write fStartPageHeader;

//
//
//

procedure TGdiPages.DoHeader;
begin
  fHeaderDone := true;
  if (fHeaderLines.Count = 0) then
    exit;
  SaveLayout;
  fInHeaderOrFooter := true;
  try
    if Assigned(fStartPageHeader) then
      fStartPageHeader(self);
    Font.Color := clBlack;
    DoHeaderFooterInternal(fHeaderLines);
    if Assigned(fEndPageHeader) then
      fEndPageHeader(self);
    GetLineHeight;
    inc(fCurrentYPos, fLineHeight shr 2); // add a small header gap
    fHeaderHeight := fCurrentYPos - fPageMarginsPx.Top;
  finally
    fInHeaderOrFooter := false;
    RestoreSavedLayout;
  end;
end;

Offline

#6 2026-02-02 20:38:58

rvk
Member
Registered: 2022-04-14
Posts: 154

Re: How set LineSpacing inside Header and Footer

I can't find any documentation or complete example. So you just have to use it.
Like this:

ab wrote:

You have to set OnStartPageHeader and OnEndPageHeader event handlers of the TGDIPages instance with your own methods.

procedure MyReportHeader(Sender: TObject);
var Report: TGdiPages;
begin
  Report := Sender as TGdiPages;
  Report.DrawBMP(....);
end;

......
   with TGdiPages.Create(self) do
   try
     OnStartPageHeader := MyReportHeader;
....

 
Hope it helps.

Offline

#7 2026-02-02 20:59:06

Sapiem
Member
Registered: 2017-12-08
Posts: 76

Re: How set LineSpacing inside Header and Footer

Doesn't trigger the Notification, doesn't call MyReportHeader

Edit: Yes, it trigger the event after draw anything to header

Last edited by Sapiem (2026-02-02 21:30:36)

Offline

#8 2026-02-02 21:22:17

rvk
Member
Registered: 2022-04-14
Posts: 154

Re: How set LineSpacing inside Header and Footer

Did you set OnStartPageHeader := MyReportHeader ??
It should trigger when doing the header.

I do see the line
  if (fHeaderLines.Count = 0) then exit;
So it will only trigger if you have at least added one line the usual way (it may be just a line with one space).

(This might be considered a 'bug' because it should also trigger when you didn't add a line via add header.)

Offline

#9 2026-02-02 21:32:16

Sapiem
Member
Registered: 2017-12-08
Posts: 76

Re: How set LineSpacing inside Header and Footer

rvk wrote:

Did you set OnStartPageHeader := MyReportHeader ??
It should trigger when doing the header.

I do see the line
  if (fHeaderLines.Count = 0) then exit;
So it will only trigger if you have at least added one line the usual way (it may be just a line with one space).

(This might be considered a 'bug' because it should also trigger when you didn't add a line via add header.)

Exactly that's it

Offline

Board footer

Powered by FluxBB