BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
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
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