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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to include rotated watermarks in center of the page in PDF document

Platform: WinForms |
Control: PDF
Tags: pdf, watermark

How to include rotated watermarks in center of the page in PDF document:

To achieve including rotated watermarks in the center of the page in PDF document, we need to translate transform the page graphics to center position and calculate the center from size of the watermark text, then render the watermark in X and Y position. The below code illustrates the same.


// Create a new instance of PdfDocument class.
PdfDocument document = new PdfDocument();
// Add a page to the document.
PdfPage page = document.Pages.Add();
// Create Pdf graphics for the page.
PdfGraphics graphics = page.Graphics;
//Create a font
PdfFont font = new PdfTrueTypeFont(new System.Drawing.Font("Arial", 20,FontStyle.Bold), true);
//save the grapics state
PdfGraphicsState state = graphics.Save();
//Translate the page graphics to be in center.
graphics.TranslateTransform(page.GetClientSize().Width / 2, page.GetClientSize().Height / 2);
//Set the transparency
//Set the rotation
string watermarkText = "Imported Using Essential PDF";
// Measure the size of the watermark text
SizeF waterMarkSize= font.MeasureString(watermarkText);
//Draw the watermark text.
graphics.DrawString(watermarkText, font, PdfPens.Red, new PointF(-waterMarkSize.Width/2, -waterMarkSize.Height/2));
//Restore the graphics
// Save the document and dispose it.

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile