[]
        
(Showing Draft Content)

Line Annotation

A line annotation displays a single straight line on the page. Upon opening, the annotation displays a pop-up window containing the associated note. DsPdf provides LineAnnotation class to enable the users to apply line annotations to the PDF file.

DsPdf demonstrating how to add line annotation in a PDF document

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