VintaSoft Imaging .NET SDK 11.0
Vintasoft.Imaging.Pdf.Tree.Annotations Namespace / PdfFreeTextAnnotation Class
Members Example



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
    PdfFreeTextAnnotation ClassPdfAction ClassPdfAnnotationAdditionalActions ClassPdfAnnotationAppearanceGenerator ClassAffineMatrix ClassPdfAnnotationAppearances ClassPdfFileReferenceSpecificationList ClassPdfFileReferenceSpecification ClassPdfBasicObject ClassPdfAnnotationBorderEffect ClassPdfAnnotationBorderStyle ClassPdfDocument ClassPdfFont ClassPdfIndirectReference ClassPdfOptionalContentGroup ClassPdfPage ClassPdfPopupAnnotation ClassPdfAnnotation ClassPaddingF Structure
    Syntax
    'Declaration
     
    Public Class PdfFreeTextAnnotation 
       Inherits PdfMarkupAnnotation
    public class PdfFreeTextAnnotation : PdfMarkupAnnotation 
    public __gc class PdfFreeTextAnnotation : public PdfMarkupAnnotation 
    public ref class PdfFreeTextAnnotation : public 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 6; .NET 5; .NET Core 3.1; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also