[]
        
(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. GcPdf provides PolygonAnnotation class to enable users to apply polygon annotations to the PDF file.

image

PolygonAnnotation class provides the following properties to set various options for the polygon annotation:

Property

Description

UserName

Adds the user name to the text label in the title bar of the annotation’s pop-up window when the annotation is open and active.

Subject

Adds the text representing the subject of the annotation.

Contents

Adds the text to the annotation for display.

RichText

Adds the text to the annotation for display in the pop-up window when opened. You can format this text using HTML tags.

Opacity

Sets the opacity of the annotation.

FillColor

Sets the fill color.

LineWidth

Sets the line width in points.

LineDashPattern

Sets the border line pattern to a dash pattern. Null means a solid line.

Color

Sets the annotation color, popup window color, line color, etc.

Points

Sets the points of a polygon or polyline. The coordinates of points are relative to the upper left corner of the page's media box, with the Y (vertical) coordinates increasing from top to bottom.

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");
}