<< Click to Display Table of Contents >> Navigation: Commands > Printing (on device) > PrintHDC on TPrinter |
This example prints on TPrinter VCL Object.
var dia : TPrintDialog;
i : Integer;
b : Boolean;
begin
dia := TPrintDialog.Create(Self);
try
dia.MaxPage := pdf.PageCount;
dia.ToPage := pdf.PageCount;
dia.FromPage:= 1;
dia.Options := dia.Options - [poSelection] + [poPageNums];
if dia.Execute then
begin
b := false;
Printer.BeginDoc;
try
for I := dia.FromPage to dia.ToPage do
begin
if b then Printer.NewPage;
Printer.Canvas.Lock;
try
SetViewportOrgEx(
Printer.Canvas.Handle,
- GetDeviceCaps(Printer.Handle,PHYSICALOFFSETX ),
- GetDeviceCaps(Printer.Handle,PHYSICALOFFSETY), nil );
pdf.PrintHDC(I-1, Printer.Canvas.Handle,
- GetDeviceCaps( Printer.Canvas.Handle, PHYSICALWIDTH ),
- GetDeviceCaps( Printer.Canvas.Handle, PHYSICALHEIGHT ) )
finally
Printer.Canvas.Unlock;
end;
b := true;
end;
finally
Printer.EndDoc;
end;
end;
finally
dia.Free;
end;
end;