How to rotate a PdfTemplate?
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 TranslateTransform 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 applying 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
Note:
Starting with v16.2.0.x, if you reference Syncfusion® assemblies from a trial setup or from the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message.
Conclusion
I hope you enjoyed learning about how to rotate a PdfTemplate.
You can refer to our WinForms PDF’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms PDF documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms PDF and other WinForms components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!