Mega Code Archive

 
Categories / Delphi / VCL
 

Using an instance of tprinter

Question: When I create an instance of TPrinter using TPrinter.Create, I get an exception. How can I get around this? Answer: There is no need to create an instance of TPrinter using TPrinter.Create, as an instance of TPrinter (called Printer) is automatically created when you use the Printers unit. Example: uses Printers; procedure TForm1.Button1Click(Sender: TObject); begin Printer.BeginDoc; Printer.Canvas.TextOut(100, 100, 'Hello World!'); Printer.EndDoc; end;