Suppose you have the following code:
procedure TForm1.Button1Click(Sender: TObject);
begin
Printer.BeginDoc;
PrintStuff;
Printer.EndDoc;
end;
procedure TForm1.PrintStuff;
begin
Printer.Canvas.Font.Name := 'Arial';
Printer.Canvas.Font.Size := 12;
Printer.Canvas.Font.Style := fsBold;
Printer.Canvas.TextOut( 0, 0, 'Welcome' );
end;
// If you must print a perfect copy of some document, than:
// 1. how do you output some text exactly at 10mm X 10mm ?
// 2. what font size do you use if the measured height of the text "Ag" is 8mm?
// 3. how do you clip the output at exactly 25mm from the right side of the printable area?
// 4. what if you need to insert 3 additional white pixels between characters
// 5. if the text is big, how much code do you have to write if you want to draw the text inside a rectangle, full justified?
//
// see how EZ_Print handles these issues below.
Using EZ_Print, your code will probably look like this:
procedure TForm1.PrintStuffEZ(Sender: TObject; CurPage: Integer);
begin
with TEZ_Printer(Sender).Procs do
begin
MapMode := tMM_HIMETRIC; // any coordinate or font size we pass will be measured in 0.01 mm units
SpoolText(
1000, 1000, // 1. x, y, coordinates 10mm X 10mm
800, // 2. font size is 8 mm
2500, // 3. text can not go past right margin of page less 25mm
3, // 4. additional 3 white pixels between chars
'Welcome', 'Arial', [fsBold], taLeftJustified );
// to answer question #5 above, you only need one line of code with EZ_Print
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
with TEZ_Printer.Create( nil ) do
try
OnPrintPage := PrintStuffEZ; // the same method will be called when previewing or printing
//Execute; // this will print
ExecutePreview( FALSE ); // this will show EZPrint preview form
finally
Free;
end;
end;