Millimeter to pixels doesn't work for me

Hello,

I would like to print on different sized envelopes on the fly.
The user would set everything in the database as :
- envelope width and height
- sender name, sender name left, top coordinates
- sender address, sender address left, top coordinates
- and so on with every printed field

My problem is that the user will set the values in mm (millimeters) and I need to make the memo components on the fly transforming the values.
I tried this but it doesn't work correctly:

Function FR_MM_to_Pixel(mm:integer):extended;
const fr1mm=0.77953;
Begin
result:= mm*fr1mm;
End;

......
.....
Memo := TfrxMemoView.Create(Page);
Memo.CreateUniqueName;
Memo.Text := InputRecord.UserText;
Memo.SetBounds(FR_MM_to_Pixel(InputRecord.UserLeft),FR_MM_to_Pixel(InputRecord.UserTop),100,20);

In the example above the InputRecord.UserLeft=20mm and InputRecord.UserTop=50 so it should be 2 cm from the left and 5cm from the top but it is much less.

Can you help me in this?

Thank you very much in advance



Comments

  • gordkgordk St.Catherines On. Canada.
    edited 2:04PM
    use frs own conversion constants.
    Memo.SetBounds(0, 0, 100, 20);// these values are in pixels.

    Objects??? coordinates and sizes are set in pixels.
    Since the ?«Left,?» ?«Top,?» ?«Width,?» and ?«Height?» properties of all objects
    have the ?«Extended?» type, you can point out non-integer values.
    The following constants are defined for converting pixels into centimeters and inches:

    fr01cm = 3.77953;
    fr1cm = 37.7953;
    fr01in = 9.6;
    fr1in = 96;

    For example, a band???s height equal to 5 mm can be set as follows:

    Band.Height := fr01cm * 5;
    Band.Height := fr1cm * 0.5;
    the usual mistake that is made is when you store the value initially
    unless you have converted prior to storing it is just a numeric value and has no relation to mm,
    cm, inches. pxls.
  • edited 2:04PM
    Thank you very much!

    You helped me a lot!
  • edited 2:04PM
    Objects??? coordinates and sizes are set in pixels.
    Since the ?«Left,?» ?«Top,?» ?«Width,?» and ?«Height?» properties of all objects
    have the ?«Extended?» type, you can point out non-integer values. ????

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.