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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to draw a rounded corner rectangle?

Platform: WinForms |
Control: PDF |
Published Date: January 19, 2016 |
Last Revised Date: January 19, 2016
Tags: pdf, graphics, shapes

How to draw a rounded corner rectangle in PDF document?

The rounded corner rectangle can be draw in the PDF document using the GraphicsPath class. Please find the code example and sample below for the same.


//Create a new document

PdfDocument doc = new PdfDocument();

doc.PageSettings.Margins.All = 0;

//Add a new page

PdfPage page = doc.Pages.Add();

//create the Rectangle

RectangleF rect = new RectangleF(100, 100, 100, 100);

int dimension = 30;

//Create the graphics path

GraphicsPath graphicsPath = new GraphicsPath();

//Draw the rounded rectangle as separate 4 arcs with same dimensions of width and height

graphicsPath.AddArc(rect.X, rect.Y, dimension, dimension, 180, 90);

graphicsPath.AddArc(rect.X + rect.Width - dimension, rect.Y, dimension, dimension, 270, 90);

graphicsPath.AddArc(rect.X + rect.Width - dimension, rect.Y + rect.Height - dimension, dimension, dimension, 0, 90);

graphicsPath.AddArc(rect.X, rect.Y + rect.Height - dimension, dimension, dimension, 90, 90);

//close path


//Get the path points

PointF[] points = graphicsPath.PathPoints;

//Get the path types

byte[] pathTypes = graphicsPath.PathTypes;

//Drawing the Path in Pdf Document

PdfPath drawPath = new PdfPath(PdfPens.Black, points, pathTypes);

//Draw the pdf path

page.Graphics.DrawPath(PdfPens.Black, drawPath);

//Save the Pdf Document


//Close the document


//Dispose the Graphics Path


Sample link:


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.

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