[]
        
(Showing Draft Content)

Free Text Annotation

A free text annotation displays text directly on the page. Unlike text annotations, free text annotations do not have an open or closed state. Instead of appearing in a pop-up window, the text stays visible. DsPdf provides FreeTextAnnotation class to enable users to apply free text annotations to the PDF file.

DsPdf demonstrating how to add free text annotation in a PDF document

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

public void CreateFreeTextAnnotation()
{
    GcPdfDocument doc = new GcPdfDocument();
    Page page = doc.NewPage();
    RectangleF rc = new RectangleF(50, 50, 200, 50);
    page.Graphics.DrawString
        ("A blue free text annotation is placed below and to the right, " +
        "with a callout going from it to this note",
        new TextFormat() { Font = StandardFonts.Times, FontSize = 11 }, rc);

    //Create an instance of FreeTextAnnotation class and set its relevant properties
    var freeAnnot = new FreeTextAnnotation()
    {
        PdfRect = new RectangleF(rc.Right + 18, rc.Bottom + 9, 72 * 2, 72),
        CalloutLine = new PointF[]
       {
           new PointF(rc.Left + rc.Width / 2, rc.Bottom),
           new PointF(rc.Left + rc.Width / 2, rc.Bottom + 9 + 36),
           new PointF(rc.Right + 18, rc.Bottom + 9 + 36),
       },
        LineWidth = 1,
        LineEndStyle = LineEndingStyle.OpenArrow,
        LineDashPattern = new float[] { 8, 4 },
        Contents = "This is a free text annotation with a callout line going to the note on the left.",
        Color = Color.LightSkyBlue,
    };

    page.Annotations.Add(freeAnnot); //Add the free text annotation
    doc.Save("FreeTextAnnotation.pdf");
}