Link to home
Start Free TrialLog in
Avatar of lizzzard
lizzzardFlag for Netherlands

asked on

Problems printing a simple textfile from Delphi

This is the first time I try to do this. Printing a textfile from a Delphi program. I'm not sure if I'm doing it the right way. I read the textfile line by line and copy the read line in a variable (string) then I call the method printer.canvas.textout(x,y,string) in which x and y are variables updated elsewhere in the program. The debugger shows that the string is filled with lines from the textfile,but the method don't seem to work properly,because all I get after sending the job with printer.enddoc is an empty page. The debugger shows that the canvas is not updated by the method.  I suppose I forgot something. Any body can help me out?
Avatar of icampbe1
icampbe1

Put a PrintDialog on your form and then:

USES Printers;

IF PrintDialog1.Execute THEN BEGIN
   WITH Printer DO BEGIN
      BeginDoc;
      ....
      canvas.TextOut( x, y, str );
      .....
      EndDoc;
      END;  {Of with printer}
   END;

This should work for you.
Cheers,
Ian C.

Avatar of lizzzard

ASKER

What Icambe suggested is already the way I coded it. That's why I can't figure out why my printer doesn't print anything. (And eh.. it's not that I'm out of ink.)
Please send your whole print code.
ASKER CERTIFIED SOLUTION
Avatar of rcastle
rcastle

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok,problem solved. Thx