The wiki article you are referring to is meant for printing out of a Lazarus GUI application. You are testing printing, however, in a console application. The difference is that a console application by-passes the Lazarus widgetset architecture and does not know about the LCL. The elemental step to make the LCL available in a consolue application is to add the unit "Interfaces" to the uses clause. But then you need another unit: "OSPrinters" to make the printer units of your operating system available.
So, in total, modify your uses clause as follows, and your application will work (tested on Windows):
program PrintUtil;
uses
Interfaces, // <--- ADDED
SysUtils, printers,
osprinters; // <--- ADDED
//, printer4lazarus; // <--- Not needed in "uses", but only in "required packages" of project
const
LEFTMARGIN = 100;
HEADLINE = 'I Printed My Very First Text On ';
var
YPos, LineHeight, VerticalMargin: integer;
SuccessString: string;
begin
with Printer do
try
BeginDoc;
Canvas.Font.Name := 'Courier New';
Canvas.Font.Size := 10;
Canvas.Font.Color := $0;
LineHeight := Round(1.2 * Abs(Canvas.TextHeight('I')));
VerticalMargin := 4 * LineHeight;
// There we go
YPos := VerticalMargin;
SuccessString := HEADLINE + DateTimeToStr(Now);
Canvas.TextOut(LEFTMARGIN, YPos, SuccessString);
finally
EndDoc;
end;
end.