PDA

View Full Version : Printing...



Voltrox
10-03-2007, 12:53 PM
Hello.

When I go to print text in Delphi, and I have to say Printer.Canvas.Textout(100, 100, 'text'), do I have to set the X and Y properties?

Is there any way in which I can just do standard printing line after line without having to set the X and Y properties?

Thank you.

AthenaOfDelphi
10-03-2007, 02:10 PM
I'm going to repeat what has been said several times before... whilst PGD exists to provide help when you need it, please try and find the answers yourself first, using google for example, or the search facility on the forums, instead of simply dropping a message here and waiting for someone to do the digging for you.

I ran a search on google for +"plain text" +"printing" +"delphi" and ended up with LOTS of hits, plus a link to search in google groups for the answer. The whole process took less than 30 seconds and hey presto I have an answer AND more importantly I've actually learned something I didn't know. Trust me when I say, by going off and hunting down answers to your questions yourself you will (a) become very profficient at google... a very useful skill in its own right and (b) learn more stuff as you root around the web looking for answers.

Heres an answer, it may not be exactly what you want as it prints using the printers default font, but it does allow plain text printing.


uses
Printers;

procedure TForm1.Button1Click(Sender: TObject);
var
MyFile: TextFile;
begin
AssignPrn(MyFile);
Rewrite(MyFile);
Writeln(MyFile, 'Print this text');
System.CloseFile(MyFile);
end;

Voltrox
13-03-2007, 03:33 PM
Thank you, it works. :)