[]
Polyline annotations display closed or open shapes with multiple edges on the page. When clicked, it displays a pop-up window containing the text of the associated note. GcPdf provides PolyLineAnnotation class to enable users to apply polyline annotations to the PDF file.
PolyLineAnnotation class provides the following properties to set various options for the polyline 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 interior color with which to fill the annotation's elements. |
LineEndingsFillColor | Sets the interior color with which to fill the annotation’s line endings. |
LineStartStyle | Sets the style of line start. |
LineEndStyle | Sets the style of line end. |
LineWidth | Sets the line width in points. |
LineDashPattern | Sets the line dash pattern. Null means a solid line. |
Color | Sets the annotation color, popup window color, line color, etc. |
Points | Adds 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 polyline annotation to a PDF document:
public void CreatePolyLineAnnotation()
{
GcPdfDocument doc = new GcPdfDocument();
Page page = doc.NewPage();
RectangleF rc = new RectangleF(50, 50, 400, 40);
page.Graphics.DrawString("This sample demonstrates how you can create a polyline annotation.",
new TextFormat() { Font = StandardFonts.Times, FontSize = 14 }, rc);
//define the points of the polyline
var points = new List<PointF>();
float x = rc.Left,y=rc.Bottom;
for (int i=0 ;i<10 ;i++,x+=10)
{
points.Add(new PointF(x,y));
y = i % 2 == 0 ? y - 10 : y+10;
}
//Create an instance of PolyLineAnnotation class and set its relevant properties
var polyLineAnnot = new PolyLineAnnotation()
{
Points = points,
UserName = "Jaime Smith",
LineWidth = 2,
Color = Color.Green,
Contents = "This is a polyline annotation",
};
page.Annotations.Add(polyLineAnnot); //Add the polyline annotation to the page
doc.Save("PolyLineAnnotation.pdf");
}