|
Printing with TPrintJob
To print the print job just call the Print method of TPrintJob component. You don't need to use BeginDoc, NextPage and EndDoc methods of TPrinter object, just let TPrintJob to print your graphics.
procedure TForm1.PrintButtonClick(Sender: TObject);
begin
PrintJob1.Print;
end;
If the MultiDoc property is True, each page will be printed as a separate document. This feature can be useful for printing the multipage jobs with large graphic files on each page, because some printer can fail such jobs due to internal memory limitations.
If you want to allow user to choose or setup the printer before printing, just use the PrintDialog method instead.
procedure TForm1.PrintButtonClick(Sender: TObject);
begin
PrintJob1.PrintDialog;
end;
If you want to print only range of the page, use the PrintEx method of the TPrintJob component.
procedure PrintEx(
StartPage,EndPage: Integer; // start and end page of printed range
PrintMode: TPrintModes); // set of print modes, see below
type
TPrintMode = (
pmReverse, // print pages in reverse order
pmMultiDoc); // multidocumental mode, see MultiDoc ahead
TPrintModes = set of TPrintMode;
...
procedure TForm1.PrintButtonClick(Sender: TObject);
begin
PrintJob1.PrintEx(2,4,[]);
end;
|