Using TPrinter in Delphi

Posted by Milad on Stack Overflow See other posts from Stack Overflow or by Milad
Published on 2010-05-11T21:23:30Z Indexed on 2010/05/11 21:24 UTC
Read the original article Hit count: 353

Filed under:
|

Hello Experts I don't have any backgrounds in programming and this is my first shot. I wrote a Delphi program that is supposed to print on a result sheet. I work in an institute and we have to establish hundreds of result sheets every 2 months. It's really difficult to do that and different handwritings is also an important issue. My problem is that when i write this code :

if PrintDialog.Execute() then
    begin
      with MyPrinter do
      begin
          MyPrinter.BeginDoc();//Start Printing

          //Prints First Name
          MyPrinter.Canvas.TextOut(FirstNameX,FirstNameY,EditFirstName.Text);

          //Prints Last Name
          MyPrinter.Canvas.TextOut(LastNameX,LastNameY,EditLastName.Text);

          //Prints Level
          MyPrinter.Canvas.TextOut(LevelX,LevelY,EditLevel.Text);

          //Prints Date
          MyPrinter.Canvas.TextOut(DateX,DateY,MEditDate.Text);

          //Prints Student Number
          MyPrinter.Canvas.TextOut(StdNumX,StdNumY,EditStdnumber.Text);
          ....
          MyPrinter.EndDoc();//End Printing
        end;
      end;

I can't get the right coordinates to print properly. Am I missing something? How can I set the right coordinates? You know TPrinter uses pixels to get the coordinates but papers are measured in inches or centimeters. I'm really confused.I appreciate any help. Thanks in advance.

© Stack Overflow or respective owner

Related posts about delphi

Related posts about printing