Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
1.44/5 (3 votes)
See more:
I want to print string with certain angle like 45,90 as per user select.
It should start from x and y provided by user in millimeter.

I have already tried with translate transform and rotate transform but position of string printing is not same for different angle. e.g. if x=5mm and y=10mm with angle =0 then if I change only angle in this then position of string changed even I had not changed x and y co-ordinates.

Thank you for your time.
Posted
Comments
Sergey Alexandrovich Kryukov 28-Jul-14 13:36pm    
This is quite possible. You can rotate or skew any image. But you should tag the library you want to use. The answers will be very different for Forms, WPF and so on...
—SA

1 solution

Try this:
C#
e.Graphics.Clear(SystemColors.Control);
e.Graphics.DrawString("Normal text", this.Font, SystemBrushes.ControlText, 10, 10);
e.Graphics.RotateTransform(90);
e.Graphics.DrawString("Tilted text", this.Font, SystemBrushes.ControlText, 10, -40);


By default the coordinate system has its origo in the top left corner of the surface, so that is the axis around which RotateTransform will rotate the surface.
 
Share this answer
 
v2
Comments
nilesh sawardekar 28-Jul-14 8:05am    
its still changing position as per your code suggested, T should print with N...but its not..
Sergey Alexandrovich Kryukov 28-Jul-14 13:35pm    
Take care about this trivial issue by yourself. You did not specify what is "position" (relative to center, some corner, or anything else).
—SA
Sergey Alexandrovich Kryukov 28-Jul-14 13:37pm    
I voted 4, just because it would be good to mention the applicability of the code. It won't be for WPF, for example, where you can transform everything, not only graphics...
Note that OP did not specify what should be used, application type.
—SA
Leo Chapiro 29-Jul-14 1:33am    
Thank you, Sergey! :)
nilesh sawardekar 30-Jul-14 10:22am    
I already mentioned x, y position which will be enter by user in window form ...dear friend Sergey..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900