macob
asked on
How to print with right-to-left aligment
How can I print with right-to-left aligment?
I need to print some senteces with an exact right aligment.
Help me please
I need to print some senteces with an exact right aligment.
Help me please
Print where? On the screen? On a printer? From where? More details required.
The most obvious method assuming that you are not using a label control etc...
...is to set the font/size etc for the target print context, then use the .TextWidth(<yourText>) function against that context to find the actual width of <yourText>.
Then - position the target's print cursor with the .CurrentX = <yourRHlimit> - <the width of the text>
then finally .Print <yourText>
Of course you also have to manage the .CurrentY property, and calc/print any other lines that will be positioned above/below.
...is to set the font/size etc for the target print context, then use the .TextWidth(<yourText>) function against that context to find the actual width of <yourText>.
Then - position the target's print cursor with the .CurrentX = <yourRHlimit> - <the width of the text>
then finally .Print <yourText>
Of course you also have to manage the .CurrentY property, and calc/print any other lines that will be positioned above/below.
If you are using a non-bidirectional windows, mcoop suggestion is good, but if you are using a bidirectional windows (like arabic or hebrew) you can set your printer RightToLeft to True:
Printer.RightToLeft = True
then, the 0,0 point will be in the TopRight of the paper, and your text will be printed with right alignment...
Printer.RightToLeft = True
then, the 0,0 point will be in the TopRight of the paper, and your text will be printed with right alignment...
ASKER
I already try using Printer.RightToLeft = True and .TextWidth() but they didnt work.
Could somebody send me an example that works?
Thanks
Could somebody send me an example that works?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Everything works! what means :
' no semicolon - will use font's line spacing
?
' no semicolon - will use font's line spacing
?
if you put a semicolon (or comma) after the print statement, the next print statement will execute on the same line as that with the semicolon. (see the Print statement help)
In that case, you would have to manage the vertical placement manually (which you may want to do... for oddball line spacing etc.)
Otherwise, making sure that the print statement ends clean (no semi or comma etc), will ensure that the normal 'line feed' will be inserted as usual following your pinted text - thus you only need to manage the horizontal positioning with .currentX
ASKER
thanks for the help