[]
A line annotation displays a single straight line on the page. Upon opening, the annotation displays a pop-up window containing the associated note. GcPdf provides LineAnnotation class to enable the users to apply line annotations to the PDF file.
LineAnnotation class provides the following properties to set various options for the line 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. |
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. |
Start | Sets the start point of the line annotation. The coordinates of the point are relative to the upper left corner of the page's media box, with the Y (vertical) coordinates increasing from top to bottom. |
End | Sets the end point of the line. The coordinates of the point are relative to the upper left corner of the page's media box, with the Y (vertical) coordinates increasing from top to bottom. |
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. |
LeaderLinesLength | Sets the length of leader lines in default user space that extend from each endpoint of the line perpendicular to the line itself. A positive value means that the leader lines appear in a direction that is clockwise when traversing the line from its starting point to its ending point. A negative value indicates the opposite direction. |
LeaderLinesExtension | Sets a non-negative number representing the length of leader line extensions that extend from the line proper 180 degrees from the leader lines. |
LeaderLineOffset | Sets a non-negative number representing the length of the leader line offset, which is the amount of empty space between the endpoints of the annotation and the beginning of the leader lines. |
VerticalTextOffset | Sets the vertical offset perpendicular to the annotation line, with a positive value indicating a shift up and a negative value indicating a shift down. |
TextPosition | Sets the annotation's text positioning. |
Refer to the following example code to add a line annotation to a PDF document:
public void CreateLineAnnotation()
{
GcPdfDocument doc = new GcPdfDocument();
Page page = doc.NewPage();
RectangleF rc = new RectangleF(50, 50, 250, 50);
page.Graphics.DrawString
("A line annotation is drawn around this note which illustates the effect of including " +
"leader lines and caption in a line annotation",
new TextFormat() { Font = StandardFonts.Times, FontSize = 11 }, rc);
//Create an instance of LineAnnotation class and set its relevant properties
var lineAnnot = new LineAnnotation()
{
UserName = "Jaime Smith",
Start = new PointF(rc.X, rc.Bottom),
End = new PointF(rc.Right, rc.Bottom),
LineWidth = 3,
Color = Color.Red,
LeaderLinesLength = -15,
LeaderLinesExtension = 5,
LeaderLineOffset = 10,
Contents = "Line annotation",
VerticalTextOffset = -20,
TextPosition = LineAnnotationTextPosition.Inline,
};
page.Annotations.Add(lineAnnot); //Add the square annotation
doc.Save("LineAnnotation.pdf");
}