#1 2012-07-05 16:46:22

reiser
Member
Registered: 2012-07-05
Posts: 5

Header line goes over header text

Hi, I'm using this code to create simple PDF:

    gdip := TGDIPages.Create(self);
    try
      gdip.BeginDoc;
      gdip.Caption := 'HBSS Log Parser Document';
      gdip.Font.Size := 10;
      gdip.Font.Name := 'Calibri';
      gdip.SaveLayout;

      gdip.Font.Style := [fsItalic];
      gdip.TextAlign := taLeft;
      gdip.AddTextToHeaderAt('HBSS Log Parser', gdip.LeftMargin);
      gdip.TextAlign := taRight;
      gdip.AddTextToHeaderAt('HIPS', gdip.RightMarginPos);
      gdip.AddLineToHeader(false);
      gdip.AddLineToFooter(false);
      gdip.TextAlign := taLeft;
      gdip.AddTextToFooterAt(DateTimeToStr(Now), gdip.LeftMargin);
      gdip.TextAlign := taRight;
      gdip.AddPagesToFooterAt('Page %d/%d', gdip.RightMarginPos);
      gdip.RestoreSavedLayout;

      gdip.TextAlign := taCenter;
      gdip.Font.Style := [fsBold];
      gdip.AddColumns([20, 40, 20, 40]);
      gdip.AddColumnHeaders(['Date/Time', 'Computer Name', 'Signature ID', 'Signature Name']);
      gdip.Font.Style := [];
      gdip.DrawTextAcrossCols(['1', '2', '3', '4']);
      gdip.NewLine;
      gdip.DrawTextAcrossCols(['5', '6', '7', '8']);
      gdip.EndDoc;
      gdip.ExportPDF(ReportSaveDialog.FileName, TRUE, TRUE);
    finally
      gdip.Free;
    end;

As a result, I get this: http://i47.tinypic.com/2vt4gnk.png

Can anyone give me hint what am I doing wrong, and how to fix header? Footer looks fine.

Thanks!

Offline

#2 2012-07-05 20:28:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Header line goes over header text

Try

gdip.Font.Style := [fsItalic];
gdip.TextAlign := taRight;
gdip.AddTextToHeaderAt('HIPS', gdip.RightMarginPos);
gdip.TextAlign := taLeft;
gdip.AddTextToHeader('HBSS Log Parser');
gdip.AddLineToHeader(false);

As stated by its documentation, AddTextToHeaderAt() does not change the Y position to the next line.
So using AddTextToHeader() will move the cursor to the next line, so AddLineToHeader() should be drawn at the expected position.

Offline

#3 2012-07-05 22:19:12

reiser
Member
Registered: 2012-07-05
Posts: 5

Re: Header line goes over header text

Thanks, will try.

Offline

Board footer

Powered by FluxBB