Articles in this section
Category / Section

How to rotate a PdfTemplate?

1 min read

Rotate a Pdf template:

You can rotate a PdfTemplate by applying “rotate transform”. The PdfTemplate class contains the PdfGraphics property that you can use to apply transformations with. The following code example explains how the PdfTemplates can be rotated with respect to a coordinate.

C#

//Create the template
PdfTemplate template = new PdfTemplate(100, 50);
//Draw the rectangle
template.Graphics.DrawRectangle(PdfBrushes.BurlyWood, new System.Drawing.RectangleF(0, 0, 100, 50));
//Draw the string
template.Graphics.DrawString("Woot", new PdfStandardFont(PdfFontFamily.Helvetica, 10), new PdfSolidBrush(System.Drawing.Color.Black), 5, 5);
//Save the state
PdfGraphicsState state = page.Graphics.Save();
//The Translate transform changes the origin of the coordinate system by prepending the specified translation to the transformation matrix of this Graphics.
page.Graphics.TranslateTransform(position.X, position.Y);
//Rotate the page
page.Graphics.RotateTransform(-90);
//Draw the pdf template after applied rotation
page.Graphics.DrawPdfTemplate(template, PointF.Empty);
//Restore the state
page.Graphics.Restore(state);

Sample link:

https://www.syncfusion.com/downloads/support/directtrac/general/PdfTemplateRotate1854324101.zip

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied