officefileapi-devexpress-dot-pdf-dot-pdfpagefacade-dot-addfreetextannotation-x28-devexpress-dot-pdf-dot-pdfrectangle-system-dot-string-x29.md
Creates a free text annotation in the specified page rectangle.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Core.dll
NuGet Package : DevExpress.Pdf.Core
public PdfFreeTextAnnotationFacade AddFreeTextAnnotation(
PdfRectangle rect,
string text
)
Public Function AddFreeTextAnnotation(
rect As PdfRectangle,
text As String
) As PdfFreeTextAnnotationFacade
| Name | Type | Description |
|---|---|---|
| rect | PdfRectangle |
A page area to add the annotation.
| | text | String |
An annotation text.
|
| Type | Description |
|---|---|
| PdfFreeTextAnnotationFacade |
An object that contains free text annotation properties.
|
The code sample below creates a free text annotation:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];
// Define an annotation area
PdfRectangle rectangle = new PdfRectangle(663, 526, 763, 576);
// Create a free text annotation in this area
PdfFreeTextAnnotationFacade freeText =
pageFacade.AddFreeTextAnnotation(rectangle, "Free Text Annotation");
// Specify annotation parameters
freeText.Author = "Nancy Davolio";
freeText.BorderWidth = 2;
// Save the result
processor.SaveDocument("..\\..\\Result.pdf");
}
Using processor As New PdfDocumentProcessor()
' Load a document
processor.LoadDocument("..\..\Document.pdf")
' Access the first page properties
Dim pageFacade As PdfPageFacade = processor.DocumentFacade.Pages(0)
' Define an annotation area
Dim rectangle As New PdfRectangle(663, 526, 763, 576)
' Create a free text annotation in this area
Dim freeText As PdfFreeTextAnnotationFacade =
pageFacade.AddFreeTextAnnotation(rectangle, "Free Text Annotation")
' Specify annotation parameters
freeText.Author = "Nancy Davolio"
freeText.BorderWidth = 2
' Save the result
processor.SaveDocument("..\..\Result.pdf")
End Using
Call a free text annotation’s SetCallout method to add a callout line to the annotation. The method call sets the annotation’s Intent property to FreeTextCallout.
The code sample below creates a callout annotation pointed at a specific phrase:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];
PdfRectangle calloutRectangle;
// Find the target phrase in the document
string calloutText = "Evaluation";
PdfTextSearchResults searchResults = processor.FindText(calloutText);
if (searchResults.Status == PdfTextSearchStatus.Found)
{
// Obtain the target phrase rectangle
calloutRectangle = searchResults.Rectangles[0].BoundingRectangle;
// Define an annotation area
PdfRectangle rectangle = new PdfRectangle(663, 526, 763, 576);
// Create a free text annotation in this area
PdfFreeTextAnnotationFacade freeText =
pageFacade.AddFreeTextAnnotation(rectangle, "Free Text Annotation");
// Specify annotation parameters
freeText.Author = "Nancy Davolio";
// Add a callout line pointed at the center of the target phrase
freeText.SetCallout(PdfAnnotationLineEndingStyle.OpenArrow, calloutRectangle.Center);
}
// Save the result
processor.SaveDocument("..\\..\\Result.pdf");
}
Using processor As New PdfDocumentProcessor()
' Load a document
processor.LoadDocument("..\..\Document.pdf")
' Access the first page properties
Dim pageFacade As PdfPageFacade = processor.DocumentFacade.Pages(0)
Dim calloutRectangle As PdfRectangle
' Find the target phrase in the document
Dim calloutText As String = "Evaluation"
Dim searchResults As PdfTextSearchResults = processor.FindText(calloutText)
If searchResults.Status = PdfTextSearchStatus.Found Then
' Obtain the target phrase rectangle
calloutRectangle = searchResults.Rectangles(0).BoundingRectangle
' Define an annotation area
Dim rectangle As New PdfRectangle(663, 526, 763, 576)
' Create a free text annotation in this area
Dim freeText As PdfFreeTextAnnotationFacade =
pageFacade.AddFreeTextAnnotation(rectangle, "Free Text Annotation")
' Specify annotation parameters
freeText.Author = "Nancy Davolio"
' Add a callout line pointed at the center of the target phrase
freeText.SetCallout(PdfAnnotationLineEndingStyle.OpenArrow, calloutRectangle.Center)
End If
' Save the result
processor.SaveDocument("..\..\Result.pdf")s
End Using
Set a free text annotation’s Intent property to FreeTextTypewriter to convert the annotation to a typewriter (click-to-type) object. This object has no border, callout line, or padding between the text and annotation bounds.
The code sample below creates a typewriter annotation:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];
// Define an annotation area
PdfRectangle rectangle = new PdfRectangle(663, 526, 763, 576);
// Create a free text annotation
PdfFreeTextAnnotationFacade freeText =
pageFacade.AddFreeTextAnnotation(rectangle, "Free Text Annotation");
// Specify annotation parameters
freeText.Author = "Nancy Davolio";
freeText.Intent = PdfFreeTextAnnotationIntent.FreeTextTypewriter;
// Save the result
processor.SaveDocument("..\\..\\Result.pdf");
}
Using processor As New PdfDocumentProcessor()
' Load a document
processor.LoadDocument("..\..\Document.pdf")
' Access the first page properties
Dim pageFacade As PdfPageFacade = processor.DocumentFacade.Pages(0)
' Define an annotation area
Dim rectangle As New PdfRectangle(663, 526, 763, 576)
' Create a free text annotation
Dim freeText As PdfFreeTextAnnotationFacade =
pageFacade.AddFreeTextAnnotation(rectangle, "Free Text Annotation")
' Specify annotation parameters
freeText.Author = "Nancy Davolio"
freeText.Intent = PdfFreeTextAnnotationIntent.FreeTextTypewriter
' Save the result
processor.SaveDocument("..\..\Result.pdf")
End Using
See Also