VintaSoft Imaging .NET SDK 15.1: Documentation for .NET developer
Vintasoft.Imaging.Pdf.Tree.Annotations Namespace / PdfFreeTextAnnotation Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
PdfFreeTextAnnotation Class
In This Topic
Represents a PDF annotation that displays an editable text area and a callout line used to point to the area of PDF page.
Object Model
PdfAnnotationBorderEffect PdfFont PaddingF PdfPopupAnnotation PdfAnnotation PdfFileReferenceSpecificationList PdfAnnotationAppearanceGenerator PdfOptionalContentGroup PdfPage PdfAnnotationBorderStyle AffineMatrix PdfAction PdfAnnotationAppearances PdfAnnotationAdditionalActions PdfDocument PdfIndirectReference PdfBasicObject PdfFreeTextAnnotation
Syntax
'Declaration

Public Class PdfFreeTextAnnotation
   Inherits PdfMarkupAnnotation

public class PdfFreeTextAnnotation : PdfMarkupAnnotation

Example

Here is an example that shows how to create a PDF free text annotation:


''' <summary>
''' Creates the PDF documenet with free text annotation.
''' </summary>
''' <param name="outputPdfFilename">The output PDF filename.</param>
Public Shared Sub CreatePdfFreeTextAnnotation(outputPdfFilename As String)
    Using document As New Vintasoft.Imaging.Pdf.PdfDocument(outputPdfFilename, Vintasoft.Imaging.Pdf.PdfFormat.Pdf_14)
        Dim page As Vintasoft.Imaging.Pdf.Tree.PdfPage

        ' Add new page
        page = document.Pages.Add(Vintasoft.Imaging.PaperSizeKind.A4)
        page.Annotations = New Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationList(document)
        Dim annotationRectangle As System.Drawing.RectangleF = page.MediaBox
        annotationRectangle.Inflate(-200, -300)

        ' Free text annotation (without line)
        Dim freeText As New Vintasoft.Imaging.Pdf.Tree.Annotations.PdfFreeTextAnnotation(page)
        freeText.Rectangle = annotationRectangle
        freeText.BorderWidth = 3
        freeText.Color = System.Drawing.Color.Green
        freeText.TextPadding = New Vintasoft.Imaging.PaddingF(freeText.BorderWidth)
        freeText.SetTextDefaultAppearance(document.FontManager.GetStandardFont(Vintasoft.Imaging.Pdf.Tree.Fonts.PdfStandardFontType.TimesRoman), 20, System.Drawing.Color.Red)
        freeText.Contents = "Free text annotation (without line)"
        page.Annotations.Add(freeText)
        freeText.UpdateAppearance()

        ' Add new page
        page = document.Pages.Add(Vintasoft.Imaging.PaperSizeKind.A4)
        page.Annotations = New Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationList(document)

        ' Free text annotation (with line)
        freeText = New Vintasoft.Imaging.Pdf.Tree.Annotations.PdfFreeTextAnnotation(page)
        freeText.Rectangle = System.Drawing.RectangleF.Inflate(annotationRectangle, 30, 30)
        freeText.BorderWidth = 3
        freeText.Color = System.Drawing.Color.Green
        freeText.TextPadding = New Vintasoft.Imaging.PaddingF(30 + freeText.BorderWidth, 30 + annotationRectangle.Height / 2, 30 + freeText.BorderWidth, 30 + freeText.BorderWidth)
        freeText.SetTextDefaultAppearance(document.FontManager.GetStandardFont(Vintasoft.Imaging.Pdf.Tree.Fonts.PdfStandardFontType.TimesRoman), 20, System.Drawing.Color.Red)
        freeText.LineEndingStyle = Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationLineEndingStyle.OpenArrow
        freeText.CalloutLinePoints = New System.Drawing.PointF() {New System.Drawing.PointF(annotationRectangle.X, annotationRectangle.Y + annotationRectangle.Height), New System.Drawing.PointF(annotationRectangle.X + annotationRectangle.Width / 2, annotationRectangle.Y + annotationRectangle.Height / 3F * 2F), New System.Drawing.PointF(annotationRectangle.X + annotationRectangle.Width / 2, annotationRectangle.Y + annotationRectangle.Height / 2)}
        freeText.Contents = "Free text annotation  (with line)"
        freeText.UpdateAppearance()
        page.Annotations.Add(freeText)

        document.SaveChanges()
    End Using
End Sub


/// <summary>
/// Creates the PDF documenet with free text annotation.
/// </summary>
/// <param name="outputPdfFilename">The output PDF filename.</param>
public static void CreatePdfFreeTextAnnotation(string outputPdfFilename)
{
    using (Vintasoft.Imaging.Pdf.PdfDocument document = new Vintasoft.Imaging.Pdf.PdfDocument(
        outputPdfFilename, Vintasoft.Imaging.Pdf.PdfFormat.Pdf_14))
    {
        Vintasoft.Imaging.Pdf.Tree.PdfPage page;

        // Add new page
        page = document.Pages.Add(Vintasoft.Imaging.PaperSizeKind.A4);
        page.Annotations = new Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationList(document);
        System.Drawing.RectangleF annotationRectangle = page.MediaBox;
        annotationRectangle.Inflate(-200, -300);

        // Free text annotation (without line)
        Vintasoft.Imaging.Pdf.Tree.Annotations.PdfFreeTextAnnotation freeText = 
            new Vintasoft.Imaging.Pdf.Tree.Annotations.PdfFreeTextAnnotation(page);
        freeText.Rectangle = annotationRectangle;
        freeText.BorderWidth = 3;
        freeText.Color = System.Drawing.Color.Green;
        freeText.TextPadding = new Vintasoft.Imaging.PaddingF(freeText.BorderWidth);
        freeText.SetTextDefaultAppearance(
            document.FontManager.GetStandardFont(Vintasoft.Imaging.Pdf.Tree.Fonts.PdfStandardFontType.TimesRoman),
            20,
            System.Drawing.Color.Red);
        freeText.Contents = "Free text annotation (without line)";
        page.Annotations.Add(freeText);
        freeText.UpdateAppearance();

        // Add new page
        page = document.Pages.Add(Vintasoft.Imaging.PaperSizeKind.A4);
        page.Annotations = new Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationList(document);

        // Free text annotation (with line)
        freeText = new Vintasoft.Imaging.Pdf.Tree.Annotations.PdfFreeTextAnnotation(page);
        freeText.Rectangle = System.Drawing.RectangleF.Inflate(annotationRectangle, 30, 30);
        freeText.BorderWidth = 3;
        freeText.Color = System.Drawing.Color.Green;
        freeText.TextPadding = new Vintasoft.Imaging.PaddingF(
            30 + freeText.BorderWidth,
            30 + annotationRectangle.Height / 2,
            30 + freeText.BorderWidth,
            30 + freeText.BorderWidth);
        freeText.SetTextDefaultAppearance(
            document.FontManager.GetStandardFont(Vintasoft.Imaging.Pdf.Tree.Fonts.PdfStandardFontType.TimesRoman),
            20,
            System.Drawing.Color.Red);
        freeText.LineEndingStyle = Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationLineEndingStyle.OpenArrow;
        freeText.CalloutLinePoints = new System.Drawing.PointF[] { 
            new System.Drawing.PointF(
                annotationRectangle.X, 
                annotationRectangle.Y+annotationRectangle.Height),
            new System.Drawing.PointF(
                annotationRectangle.X+annotationRectangle.Width / 2, 
                annotationRectangle.Y+annotationRectangle.Height / 3f * 2f),
            new System.Drawing.PointF(
                annotationRectangle.X+annotationRectangle.Width / 2, 
                annotationRectangle.Y+annotationRectangle.Height / 2),
        };
        freeText.Contents = "Free text annotation  (with line)";
        freeText.UpdateAppearance();
        page.Annotations.Add(freeText);

        document.SaveChanges();
    }
}

Inheritance Hierarchy

System.Object
   Vintasoft.Imaging.Pdf.Tree.PdfTreeNodeBase
      Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotation
         Vintasoft.Imaging.Pdf.Tree.Annotations.PdfMarkupAnnotation
            Vintasoft.Imaging.Pdf.Tree.Annotations.PdfFreeTextAnnotation

Requirements

Target Platforms: .NET 10; .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

See Also