[]
        
(Showing Draft Content)

Square Annotation

A square annotation displays a rectangle or square on the page. When opened, the annotation displays a pop-up window with the text of the associated note. DsPdf provides SquareAnnotation class to enable users to apply square annotations to the PDF file.

Note that a square annotation does not always imply that the annotation is square in shape. The height and width of the annotation may vary. The image given below depicts a rectangle-shaped square annotation.

DsPdf demonstrating how to add square annotation in a PDF document

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

public void CreateSquareAnnotation()
{
    GcPdfDocument doc = new GcPdfDocument();
    Page page = doc.NewPage();
    RectangleF rc = new RectangleF(50, 50, 250, 50);
    page.Graphics.DrawString
        ("A square annotation drawn with a 3pt wide orange line around this note has a rich text " +
        "associated with it.",
        new TextFormat() { Font = StandardFonts.Times, FontSize = 11 }, rc); rc.Inflate(10, 10);

    //Create an instance of SquareAnnotation class and set its relevant properties
    var squareAnnot = new SquareAnnotation()
    {
        UserName = "Jaime Smith",
        PdfRect = rc,
        LineWidth = 3,
        Color = Color.Orange,
        RichText =
  "<body><p>This <b><i>rich text</i></b> is associated with the square annotation around a text note.</p></body>"
    };
    page.Annotations.Add(squareAnnot); //Add the square annotation
    doc.Save("SquareAnnotation.pdf");
}