Category / Section
How to rotate a single line of text in pdf?
1 min read
You can rotate a single line of text in Pdf by saving the current graphics state of the page. Then translate the coordinate system to where you want to draw the text, rotate the text by passing an angle. Finally draw the string and restore the graphics state.
C#
//Creates a new pdf document PdfDocument document = new PdfDocument(); //Adds the page PdfPage page = document.Pages.Add(); //save the current graphics states PdfGraphicsState state = page.Graphics.Save(); //Translate the coordinate system’s to where you want draw the text position page.Graphics.TranslateTransform(position.X,position.Y); //Rotate the coordinate system’s page.Graphics.RotateTransform(angle); //Draw the string at the origin page.Graphics.DrawString(text, bigFont, PdfBrushes.DarkBlue, new PointF(0, 0)); //Restore the graphics state page.Graphics.Restore(state); //Save the document and dispose it document.Save("verticalText.pdf"); document.Close();
Sample Link:
http://www.syncfusion.com/downloads/support/directtrac/general/Rotated_text1113120317.zip