annotations property

Gets a collection of the annotations of the page- Read only.

//Creates a new PDF document
PdfDocument document = PdfDocument();
//Creates a rectangle annotation
PdfRectangleAnnotation rectangleAnnotation = PdfRectangleAnnotation(
    Rect.fromLTWH(0, 30, 80, 80), 'Rectangle Annotation',
    author: 'Syncfusion',
    color: PdfColor(255, 0, 0),
    modifiedDate: DateTime.now());
//Create a new PDF page and Adds the annotation to the PDF page
document.pages.add().annotations.add(rectangleAnnotation);
//Save the document.
List<int> bytes = await document.save();
//Dispose the document.
document.dispose();

Implementation

PdfAnnotationCollection get annotations {
  if (!_helper.isLoadedPage) {
    if (_helper._annotations == null) {
      _helper._annotations = PdfAnnotationCollection(this);
      if (!_helper.dictionary!.containsKey(PdfDictionaryProperties.annots)) {
        _helper.dictionary![PdfDictionaryProperties.annots] =
            PdfAnnotationCollectionHelper.getHelper(_helper._annotations!)
                .internalAnnotations;
      }
      PdfAnnotationCollectionHelper.getHelper(_helper._annotations!)
              .internalAnnotations =
          _helper.dictionary![PdfDictionaryProperties.annots] as PdfArray?;
    }
  } else {
    if (_helper._annotations == null || _helper.importAnnotation) {
      // Create the annotations.
      _helper.createAnnotations(_helper.getWidgetReferences());
    }
    if (_helper._annotations == null ||
        (PdfAnnotationCollectionHelper.getHelper(_helper._annotations!)
                    .internalAnnotations
                    .count ==
                0 &&
            _helper._annotations!.count != 0)) {
      _helper._annotations = PdfAnnotationCollectionHelper.load(this);
    }
  }
  return _helper._annotations!;
}