Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 386
  • Last Modified:

How Do I Print A string To The System Default Printer?

I need a simple print function. I need to send a simple string to a dot-matrix line printer. I don't need anything fancy. I don't need to format any print parameters. It doesn't get any simpler than this. Thank you.
0
jsmitter
Asked:
jsmitter
2 Solutions
 
FactorBCommented:
For example if you like to print Label1 on current(default) printer it should be something like:

begin
   Printer.BeginDoc;
   Printer.Canvas.Font.Name := Label1.Font.Name;
   Printer.Canvas.Font.Color := Label1.Font.Color;
   Printer.Canvas.Font.Size := Label1.Font.Sizer;
   Printer.Canvas.TextOut(40,  20, Label1.Caption);
   Printer.EndDoc;
end;
0
 
AshokCommented:
uses
  Printers;

procedure PrintString(sText: string);
begin
  Printer.BeginDoc;
  Printer.Canvas.Pen.Color  := 0;
  Printer.Canvas.Font.Name  := 'Times New Roman';
  Printer.Canvas.Font.Size  := 12;
  // Printer.Canvas.Font.Style := [fsBold, fsUnderline]; // Optional
  Printer.Canvas.TextOut(0, 100, sText);
  Printer.EndDoc;
end;

HTH
Ashok

procedure TForm1.Button1Click(Sender: TObject);
begin
  PrintGrid(StringGrid1, 'Print Stringgrid');
end;
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now