For each Windows application developer, the implementation of printing functions is extremely tricky because it should be involved in considerable code, and often quite complicated, but the print function of the text and the image in Delphi is very Easy. The print function of the text print function Delphi is as easy as in DOS, just acquires print parameters, open the printer, and then send each line of text. A Printers program unit is provided in Delphi, which illustrates a TPrinter object that encapsulates the interface between Windows print jobs and output printers, and provides common properties and methods. Among them, it is a very useful attribute that represents the surface of the current print file. It is working in a graphical way. The entire printout work is only output to the printed content to TPrinter's attribute Canvas, when all output works In the future, the print object (TPRINTER) is sent to the printer attribute value. The following example shows how to implement printing of text content through Delphi. Provides PrintDialog in Delphi, printersetupDialog two controls allow us to conduct printers and other options that affect printouts, and the most important thing is to implement printing features to add Printers to Interface or IMPL Ementation before compiler. UESE statement Among them, because the Printer unit includes the process of assignprise and other control printers. First add MEMO, PrintDialog, PrinterSetupDialog, and two Button controls among the FROM, and the two Button's CAPTION is "Print Settings" and "Print". Then write the Button event driver. This example is relatively simple, and you can output file 0s2.txt on the printer when you click the Print button. Code is as follows: implementation uses printers; {$ R * .DFM} procedure TForm1.BitBtn1Click (Sender: TObject); begin printersetupdialog1.execute; // selects the output of the printer, and the print control options other end; procedure TForm1.BitBtn2Click (Sender: TObject VAR lines: integer; prnText: system.Text; // Storing Prntext as a text file based on the text file defined in the System program unit (PrnText); // Assign PRNTEST to the printer ReWrite (PRNText) ); // call the REWRITE function, open the allocated file printer.canvas.font: = MEMO1.FONT; // Specify the current MEMO1 font to the canvas of the print object for lines: = 0 to Memo1. Lines.count-1 Do Writeln (PrnText, Memo1.Lines [Lines]); // Write MEMO's content to the printer object system.close (prnText); // Close the print file end; Procedure TFORM1.FormCreate (Sender: TOBJECT Begin memo1.lines.LoadFromfile ('c: /dos/os2.txt'); // read into c: /dos/s2.txt file end during Form; End. Graphic print function Simple graphic print The function is as easy as printing text, just telling the printer object to start printing, copy the graphic to the printer, and finally tell the printer to end the print job.