iOS
ComPDFKit PDF SDK
Guides

Access Annotations

 

CPDFAnnotation is the base class for all annotations. A CPDFAnnotation object by itself is not useful, only subclasses (like CPDFCircleAnnotation, CPDFTextAnnotation) are interesting. In parsing a PDF however, any unknown or unsupported annotations will be represented as this base class.

 

To access the list of annotation by using the following method:

 

- (NSArray<CPDFAnnotation *>)annotationsWithDocument:(CPDFDocument *)document {
    NSMutableArray *annotations = [NSMutableArray array];
    for (int i=0; i<document.pageCount; i++) {
        CPDFPage *page = [document pageAtIndex:i];
        [annotations addObjectsFromArray:[page annotations]];
    }
}

 

The elements of the array will most likely be typed to subclasses of the CPDFAnnotation class.