officefileapi-devexpress-dot-pdf-f7a9a2a2.md
Contains members used to manage text annotations (sticky notes) without access to their inner structure.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Core.dll
NuGet Package : DevExpress.Pdf.Core
public class PdfTextAnnotationFacade :
PdfMarkupAnnotationFacade
Public Class PdfTextAnnotationFacade
Inherits PdfMarkupAnnotationFacade
The following members return PdfTextAnnotationFacade objects:
The code sample below creates a sticky note at the specified point on the first page:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade page = processor.DocumentFacade.Pages[0];
// Add sticky note at the specified point
PdfTextAnnotationFacade textAnnotation =
page.AddTextAnnotation(new PdfPoint(64, 65), PdfTextAnnotationIconName.Cross);
// Specify annotation parameters
textAnnotation.Author = "Nancy Davolio";
textAnnotation.Color = new PdfRGBColor(0.8, 0.2, 0.1);
textAnnotation.Contents = "Please proofread this document";
}
Using processor As New PdfDocumentProcessor()
' Load a document
processor.LoadDocument("..\..\Document.pdf")
' Access the first page properties
Dim facade As PdfDocumentFacade = processor.DocumentFacade
Dim page As PdfPageFacade = facade.Pages(0)
' Add sticky note at the specified point
Dim textAnnotation As PdfTextAnnotationFacade =
page.AddTextAnnotation(New PdfPoint(64, 65), PdfTextAnnotationIconName.Cross)
' Specify annotation parameters
textAnnotation.Author = "Nancy Davolio"
textAnnotation.Color = New PdfRGBColor(0.8, 0.2, 0.1)
textAnnotation.Contents = "Please proofread this document"
End Using
The PdfPageFacade.Annotations property returns all page annotation properties. You can filter text annotation properties, cast them to the PdfTextAnnotationFacade class, and use class properties to modify annotation parameters.
The code sample below retrieves all sticky notes on the first page and changes their icon, color and opacity:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade page = processor.DocumentFacade.Pages[0];
// Retrieve all sticky notes
var stickyNotes = page.Annotations.Where
(annotation => annotation.Type == PdfAnnotationType.Text);
foreach (PdfTextAnnotationFacade stickyNote in stickyNotes)
{
// Change annotation parameters
stickyNote.IconName = PdfTextAnnotationIconName.Note;
stickyNote.Opacity = 0.7;
stickyNote.Color = new PdfRGBColor(0.10, 0.85, 1.00);
}
// 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 page As PdfPageFacade = processor.DocumentFacade.Pages(0)
' Retrieve all sticky notes
Dim stickyNotes = page.Annotations.Where
(Function(annotation) annotation.Type = PdfAnnotationType.Text)
For Each stickyNote As PdfTextAnnotationFacade In stickyNotes
' Change annotation parameters
stickyNote.IconName = PdfTextAnnotationIconName.Note
stickyNote.Opacity = 0.7
stickyNote.Color = New PdfRGBColor(0.10, 0.85, 1.00)
Next stickyNote
' Save the result
processor.SaveDocument("..\..\Result.pdf")
End Using
Call one of the following methods to flatten an annotation:
| Method | Description |
|---|---|
| PdfDocumentFacade.FlattenAnnotations | Flattens document annotations. |
| PdfPageFacade.FlattenAnnotations | Flattens annotations of a specific page. |
| PdfAnnotationFacade.Flatten() | Flattens a specific annotation. |
The code sample below flattens all text annotations on the first page:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade page = processor.DocumentFacade.Pages[0];
// Flatten all text annotations
page.FlattenAnnotations(PdfAnnotationType.Text);
// 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 page As PdfPageFacade = processor.DocumentFacade.Pages(0)
' Flatten all text annotations
page.FlattenAnnotations(PdfAnnotationType.Text)
' Save the result
processor.SaveDocument("..\..\Result.pdf")
End Using
Call the PdfAnnotationFacade.Remove() method to remove an annotation. The code sample below removes all sticky motes from the first page:
using DevExpress.Pdf;
using System.Linq;
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\..\Document.pdf")
// Access the first page properties
PdfPageFacade page = processor.DocumentFacade.Pages[0];
// Retrieve all sticky notes
var stickyNotes = page.Annotations.Where
(annotation => annotation.Type == PdfAnnotationType.Text).ToList();
foreach (PdfTextAnnotationFacade stickyNote in stickyNotes)
{
// Remove each annotation
stickyNote.Remove();
}
// Save the result
processor.SaveDocument("..\\..\\Result.pdf");
}
Imports DevExpress.Pdf
Imports System.Linq
Using processor As New PdfDocumentProcessor()
'Load a document
processor.LoadDocument("..\..\Document.pdf")
' Access the first page properties
Dim page As PdfPageFacade = processor.DocumentFacade.Pages(0)
' Retrieve all text annotations
Dim stickyNotes = page.Annotations.Where
(Function(annotation) annotation.Type = PdfAnnotationType.Text).ToList()
For Each stickyNote As PdfTextAnnotationFacade In stickyNotes
' Remove each annotation
stickyNote.Remove()
Next stickyNote
' Save the result
processor.SaveDocument("..\\..\\Result.pdf")
End Using
Object PdfAnnotationFacade PdfMarkupAnnotationFacade PdfTextAnnotationFacade
See Also