# Type TPagePrinted

## Declaration

TPagePrinted = procedure(Sender: TObject; Canvas : TCanvas ;

NumPage, W, H: Integer ;

var StopPrinting : Boolean) of Object;

## Description

The TPagePrinted type is the type for the OnPrintHeader and OnPrintFooter events. These events occur as each page is printed allowing the user to add a header and/or footer to the page.

Canvas is the drawing canvas on which to draw the header or footer having its origin at the upper left corner of the header or footer area with a width, W, and height, H. The actual size of the header/footer areas is determined by the PrintMarginTop and PrintMarginBottom property settings.

NumPage is the current page number. StopPrinting may be set to True to stop printing.

Example:

This code prints the document title and filename in the header area.

procedure TForm1.PrintHeader(Sender: TObject; const Canvas: TCanvas;

NumPage, W, H: Integer; var StopPrinting: Boolean);

var

AFont: TFont;

begin

AFont := TFont.Create;

AFont.Name := 'Arial';

AFont.Size := 8;

with Canvas do

begin

Font.Assign(AFont);

SetTextAlign(Handle, TA_Top or TA_Left);

TextOut(50, 40, Viewer.DocumentTitle);

SetTextAlign(Handle, TA_Top or TA_Right);

TextOut(W-50, 40, Viewer.CurrentFile);

end;

AFont.Free;

end;

See also:

OnPrintHTMLHeader

OnPrintHTMLFooter