Text spacing and alignment

  • I have some troubles with text spacing.

    By default, sometimes the spacing between words is way to big. Then I tried the mode wpExactTextPositioning, but now there are uncontrolled spaces in the words (see "Switzerland" in the example).
    Finally I set the mode to wpDontAdjustTextSpacing and the text looks fine.

    The problem I have now is, that with Pdf.Canvas.TextWidth I don't get correct results, so I cannot right align the text correctly (see example the columns with month/year).

    My question is, how can I calculate the exact width of the text, so that right alignment works with mode wpDontAdjustTextSpacing too?

    Examples are at:
    http://www.splash-software.ch/host/TEST_Normal.pdf
    http://www.splash-software.ch/host/TEST_ExactTextPos.pdf
    http://www.splash-software.ch/host/TEST_Dont…TextSpacing.pdf

    cu Christian

    • Offizieller Beitrag

    Hi,

    I recommend to use the SetTextAlign API to right align the text. If you are using a small resolution (such as screen resolution) for the canvas the font width under windows and PDF can be quite a bit different for each single character. You can see that with small fonts.

    Using a higer resolution (SetViewPortAPI!) will produce a better result since the font heights are then larger and windows rounding errors less effective.

    Julian Ziersch

  • Using SetTextAlign doesn't give better results.

    Can you give me an example on how to use the SetViewPortAPI? I use the following code arround your component: