Jumat, 20 Maret 2009

Cara Printing Text ke Printer di Delphi

Cara sederhana untuk mencetak text ke printer sbb:

Delphi Print

1. // send the lines of a multiline editbox (memo) to the printer
2. // the form contains at least three components:
3. // a Button, a MemoBox named TotalCost and a PrintDialog
4. // note that BLANK is just a space character
5. // Delphi 3.0
6.
7. procedure TForm1.PrintTotalButtonClick(Sender: TObject);
8. var
9. POutput: TextFile;
10. k: Integer;
11. begin
12. if PrintDialog1.Execute then
13. begin
14. AssignPrn(POutput);
15. Rewrite(POutput);
16. Printer.Canvas.Font.Name := 'Courier New';
17. Printer.Canvas.Font.Size := 8;
18. Writeln(POutput,BLANK);
19. Writeln(POutput,BLANK);
20. Writeln(POutput,BLANK);
21. for k := 0 to TotalCost.Lines.Count - 1 do
22. Writeln(POutput, ' ' + TotalCost.Lines[k]);
23. CloseFile(POutput);
24. end;
25. end;

Tidak ada komentar:

Posting Komentar