Having trouble getting help?
Contact Support
Contact Support
Annotation Collection in .NET MAUI PDF Viewer (SfPdfViewer)
The existing annotations in a PDF document can be accessed using the Annotations property of the SfPdfViewer. This read only property will have the annotation collection information as soon as the document is loaded into the PDF Viewer. The following example explains how to use the property to obtain the information about a square annotation that is the first on a specific document.
public void WireDocumentLoadedEvent()
{
// Wire the document loaded event of the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) to occur when a PDF document is loaded.
PdfViewer.DocumentLoaded += OnDocumentLoaded;
}
private void OnDocumentLoaded(object sender, EventArgs e)
{
if (sender is SfPdfViewer pdfViewer)
{
// Obtain the annotation collection.
ReadOnlyObservableCollection<Annotation> annotations = pdfViewer.Annotations;
if (annotations.Count > 0)
{
// Type cast the annotation to get the annotation specific properties.
if (annotations[0] is SquareAnnotation squareAnnotation)
{
RectF bounds = squareAnnotation.Bounds;
Color color = squareAnnotation.Color;
}
}
}
}