VintaSoft Imaging .NET SDK v8.6
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 ClassPdfAnnotationAppearances ClassPdfFileReferenceSpecificationList ClassPdfFileReferenceSpecification ClassPdfBasicObject ClassPdfAnnotationBorderEffect ClassPdfAnnotationBorderStyle ClassPdfDocument ClassPdfFont ClassPdfIndirectReference ClassPdfOptionalContentGroup ClassPdfPage 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
    This example 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: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also