[]
        
(Showing Draft Content)

Polygon Annotation

A polygon annotation displays a polygon on a page. On opening the annotation, it displays a pop-up window containing the text of the associated note. DsPdf provides PolygonAnnotation class to enable users to apply polygon annotations to the PDF file.

DsPdf demonstrating how to add polygon annotation in a PDF document

Refer to the following example code to add a polygon annotation to a PDF document:

public void CreatePolygonAnnotation()
{
    GcPdfDocument doc = new GcPdfDocument();
    Page page = doc.NewPage();
    RectangleF rc = new RectangleF(140, 30, 160, 70);
    page.Graphics.DrawString("A polygon annotation drawn with a 3pt wide purple line around this note",
        new TextFormat() { Font = StandardFonts.Times, FontSize = 11 }, rc);

    //Create an instance of PolygonAnnotation class and set its relevant properties
    var polygonAnnot = new PolygonAnnotation()
    {
        Points = new List<PointF>()
        {
            new PointF(rc.X-5, rc.Y),
            new PointF(rc.X+75, rc.Y-10),
            new PointF(rc.X+rc.Width-5, rc.Y),
            new PointF(rc.X+rc.Width-5, rc.Y+rc.Height),
            new PointF(rc.X-5, rc.Y+rc.Height),
        },
        UserName = "Jaime Smith",
        LineWidth = 3,
        LineDashPattern = new float[] { 5, 2, 15, 4 },
        Color = Color.Purple,
        Contents = "This is a polygon annotation",
    };

    page.Annotations.Add(polygonAnnot); //Add the polygon annotation
    doc.Save("PolygonAnnotation.pdf");
}