Back to Devexpress

PdfFreeTextAnnotationFacade.TextRectangle Property

officefileapi-devexpress-dot-pdf-dot-pdffreetextannotationfacade-1997a242.md

latest3.0 KB
Original Source

PdfFreeTextAnnotationFacade.TextRectangle Property

Gets or sets the text box rectangle.

Namespace : DevExpress.Pdf

Assembly : DevExpress.Pdf.v25.2.Core.dll

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public PdfRectangle TextRectangle { get; set; }
vb
Public Property TextRectangle As PdfRectangle

Property Value

TypeDescription
PdfRectangle

The annotation text rectangle.

|

Remarks

Use this property to specify the rectangle the text box occupies. The PdfAnnotationFacade.Rectangle property returns the annotation rectangle, which includes the text box and a callout (if specified).

The code sample below resizes the text box rectangle:

csharp
using DevExpress.Pdf;
using System.Linq;

using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
    // Load a document
    processor.LoadDocument("..\\..\\Document.pdf");

    // Access page properties
    PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];

    // Retrieve all free text annotations
    var freeTextAnnotations = pageFacade.Annotations.Where
            (annotation => annotation.Type == PdfAnnotationType.FreeText);
    foreach (PdfFreeTextAnnotationFacade freeText in freeTextAnnotations)
    {
        // Resize the text box:
        PdfPoint center = freeText.Rectangle.Center;
        freeText.TextRectangle = new PdfRectangle(center.X-15, center.Y-15, center.X+15, center.Y+15);
    }
    // Save the result
    processor.SaveDocument("..\\..\\Result.pdf");
}
vb
Imports DevExpress.Pdf
Imports System.Linq

Using processor As New PdfDocumentProcessor()
  ' Load a document
  processor.LoadDocument("..\..\Document.pdf")

  ' Access page properties
  Dim pageFacade As PdfPageFacade = processor.DocumentFacade.Pages(0)

  ' Retrieve all free text annotations
  Dim freeTextAnnotations = pageFacade.Annotations.Where(Function(annotation) annotation.Type = PdfAnnotationType.FreeText)
  For Each freeText As PdfFreeTextAnnotationFacade In freeTextAnnotations
    ' Resize the text box:
    Dim center As PdfPoint = freeText.Rectangle.Center
    freeText.TextRectangle = New PdfRectangle(center.X-15, center.Y-15, center.X+15, center.Y+15)
  Next freeText
  ' Save the result
  processor.SaveDocument("..\..\Result.pdf")
End Using

See Also

PdfFreeTextAnnotationFacade Class

PdfFreeTextAnnotationFacade Members

DevExpress.Pdf Namespace