Rectangles with rounded corners

Using Aspose.PDF


I can draw rectangles with square corners, but I need to render them with rounded corners , where I can specify the corner radius. Is there a way to do this, if not on the Rectangle class itself, maybe I can use operators somehow?

Ideas anyone?

Hi Albert,


Thanks for your inquiry. You can use RoundedCornerRadius property to set rounder corner radius of Rectangle object as following. Hopefully it will help you to accomplish the task.

Document doc = new
Document();<o:p></o:p>

Aspose.Pdf.Page page = doc.Pages.Add();

Aspose.Pdf.Drawing.Graph canvas = new Aspose.Pdf.Drawing.Graph(100, 400);

Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(10, 100, 200, 100);

rect.GraphInfo.Color = Aspose.Pdf.Color.Red;

//rect.GraphInfo.DashArray = new int[] { 3 };

//rect.GraphInfo.DashPhase = 1;

rect.RoundedCornerRadius = 10;

canvas.Shapes.Add(rect);

page.Paragraphs.Add(canvas);

doc.Save(myDir+"Rectanlge_roundedcorners.pdf");


Please feel free to contact us for any further assistance.

Best Regards,