We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Rotating text for PDF printing

Hello,

I have some strings that need to be printed vertically. I saw it could be done with RotateTransform method of PdfGraphics, but I don't know how. I tried to change the coords with trigonometrical functions, but I must be doing something wrong, since I get empty pdf as a result every time.

Could you please guide me in this, and if possible give a small example that I can learn from?

Thanks,
Ljubomir



3 Replies

KC Karthikeyan Chandrasekar Syncfusion Team May 21, 2014 01:23 PM UTC

Hi Ljubomir,

Thank you for your interest in Syncfusion Products.

 

Yes, we can able to print the text vertically using RotateTransform, please use the below code snippet.

            page.Graphics.RotateTransform(-90);

            page.Graphics.DrawString("Syncfusion", font, PdfBrushes.Black, new PointF(-150, 150));

 

Below is the Online sample link for stamping the text with inclined.

http://asp.syncfusion.com/demos/reporting/Pdf/Modify%20Documents/Import%20and%20Stamp/CS/default.aspx

 

Please let us know if you need further assistance.

Thanks,

Karthikeyan.C



EE Eric Eckberg May 26, 2014 06:06 PM UTC

I have seen a few answers like this related to 90 and 45 degree text, but how are the coordinates changes if I'm rotating text 180 degrees?  The Application I am currently developing involves printing a desk stand by folding a letter size sheet in half.  The top half would have the person's name upside down, and the bottom half right side up.  When folded, both sides display right side up.  

I am using RotateTransform(180) after having placed the rightside up content, but the string I draw after the RotateTransform does not display on the generated PDF at all.  How are the coordinates changed?

For instance, your example prints the string Hello World as:

g.DrawString("Hello World", font, brush, new PointF(20, 20));

How can I draw Hello World upside down in the same location instead?


Thanks,
Eric



KC Karthikeyan Chandrasekar Syncfusion Team May 28, 2014 06:44 AM UTC

Hi Eric,

Thank you for your update.

 

Please find the coordinate system after applying RotateTransform below.

 

Rotate Transformation

Coordinate System

Code Snippet

RotateTransform(0)

X= 150; Y=150

            page.Graphics.RotateTransform(0);

            page.Graphics.DrawString("Syncfusion", font, PdfBrushes.Black, new PointF(150, 150));

 

RotateTransform(-90)

X= -150; Y=150

            page.Graphics.RotateTransform(-90);

            page.Graphics.DrawString("Syncfusion", font, PdfBrushes.Black, new PointF(-150, 150));

 

RotateTransform(90)

X= 150; Y= -150

            page.Graphics.RotateTransform(90);

            page.Graphics.DrawString("Syncfusion", font, PdfBrushes.Black, new PointF(150, -150));

 

RotateTransform(180)

X= -150; Y= -150

            page.Graphics.RotateTransform(180);

            page.Graphics.DrawString("Syncfusion", font, PdfBrushes.Black, new PointF(-150, -150));

 

 

Please let us know if you need any further assistance.

Thanks,

Karthikeyan.C


Loader.
Live Chat Icon For mobile
Up arrow icon