|
Areas coordinates
TPrintJob passes the coordinates of each print area (header, footer and page area) into the OnDraw event by the TheRect parameter. The coordinates always in pixels and by default point the real area coordinates in the page, so the left and top corner can be offset from the (0,0) point , but TPrintJob component has the RelativeCoords property that allow to emulate the drawing from the (0,0) point. If this property is True, the drawing areas always starts from the (0,0) point, but the code that use the left top point coordinates will work properly independently from the RelativeCoords property. The following code will out the text at the left top corner of the page area properly only in the RelativeCoords property is True.
procedure TfrmMain.psjAreasDraw(Sender: TObject; TheCanvas: TCanvas;
PageIndex: Integer; Rect: TRect; Area: TDrawArea;
Target: TDrawTarget);
begin
with TheCanvas do
if Area=daPage then
TextOut(0,0,'Some text here...');
end;
The code below will always work properly.
procedure TForm1.PrintJob1Draw(Sender: TObject; TheCanvas: TCanvas;
PageIndex: Integer; TheRect: TRect; Area: TDrawArea;
Target: TDrawTarget);
begin
with TheCanvas,TheRect do
if Area=daPage then
TextOut(Left,Top,'Some text here...');
end;
|