begin
PrinterPreview.begin
Doc;
i := 1;
PrinterPreview.Canvas.Font.Name := 'Arial';
PrinterPreview.Canvas.Font.Size := 20;
PrinterPreview.Canvas.TextOut(100,100,'Page ' + IntToStr(i));
for i := 2 to 10do
begin
PrinterPreview.NewPage;
PrinterPreview.Canvas.Font.Name := 'Arial';
PrinterPreview.Canvas.Font.Size := 20;
// Lets user to cancel print by pressing stop button in preview form
Application.ProcessMessages;
PrinterPreview.Canvas.TextOut(100,100,'Page ' + IntToStr(i));//显示页码
// Check that user pressed stop button in preview form
if PrinterPreview.Aborted then
Exit;
end;
PrinterPreview.EndDoc;
end