How can I print text fields at the right coordinates?

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:44 UTC
Read the original article Hit count: 303

Filed under:
|

I don't have any background 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 handwriting is also an important issue. I have 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.

© Stack Overflow or respective owner

Related posts about delphi

Related posts about printing