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

How to rotate text?

Hi,

I tried without success to rotate some text in a PDF on Android platform. I didn’t tested it on other platforms. Here is my code:

 

      void TestPDF(object sender, EventArgs e)
      {
         PdfFont bigFont = new PdfStandardFont(PdfFontFamily.Helvetica, 30f);

         PdfDocument document = new PdfDocument();

         PdfPage page = document.Pages.Add();

         page.Graphics.DrawString("Straight", bigFont, PdfBrushes.Black, new Syncfusion.Drawing.PointF(10, 10));

         DrawRotatedText("Rotated", bigFont, new PointF(50, 200), 180, page);

         page.Graphics.DrawString("Already Straight", bigFont, PdfBrushes.Black, new Syncfusion.Drawing.PointF(10, 300));

         //Saves the document.
         MemoryStream stream = new MemoryStream();
         document.Save(stream);
         document.Close(true);
         Xamarin.Forms.DependencyService.Get<ISave>().Save("verticalText.pdf", stream, true);
      }

       private void DrawRotatedText(String text, PdfFont font, PointF position, float angle, PdfPage page)
      {
         //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((float)position.X, (float)position.Y);

         //Rotate the coordinate system’s
         page.Graphics.RotateTransform(angle);

         //Draw the string at the origin
         page.Graphics.DrawString(text, font, PdfBrushes.DarkBlue, new Syncfusion.Drawing.PointF(0, 0));

         //Restore the graphics state
         page.Graphics.Restore(state);
      }

Does anybody have an idea of my error?

Thanks,

Michael


1 Reply

PH Praveenkumar H Syncfusion Team January 6, 2015 03:46 AM UTC

Hi Michael,

Thank you for using syncfusion products,

Currently we don’t have the implementation for rotate transform in xamarin platforms, we have already logged the feature request in our database, and we will let you know once the feature has been implemented.

Please let us know if you need further assistance.

With Regards,

Praveen



Loader.
Up arrow icon