|
@@ -549,6 +549,41 @@ CGFloat DEFAULT_SNAPSHOT_HEIGHT = 200.0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+- (void)removeAllAnnotation {
|
|
|
+ NSAlert* alert = [[NSAlert alloc] init];
|
|
|
+ [alert setAlertStyle:NSAlertStyleCritical];
|
|
|
+ [alert setMessageText:NSLocalizedString(@"This will permanently remove all annotations. Are you sure to continue?", nil)];
|
|
|
+ [alert addButtonWithTitle:NSLocalizedString(@"Yes", nil)];
|
|
|
+ [alert addButtonWithTitle:NSLocalizedString(@"No", nil)];
|
|
|
+
|
|
|
+ NSModalResponse response = [alert runModal];
|
|
|
+ if (response == NSAlertFirstButtonReturn) {
|
|
|
+ NSMutableArray *annotations = [NSMutableArray array];
|
|
|
+
|
|
|
+ for (NSUInteger i = 0; i < self.document.pageCount; i++) {
|
|
|
+ CPDFPage *page = [[self document] pageAtIndex:i];
|
|
|
+ for (CPDFAnnotation *annotation in [page annotations]) {
|
|
|
+ if ([annotation isKindOfClass:[CPDFTextWidgetAnnotation class]] ||
|
|
|
+ [annotation isKindOfClass:[CPDFButtonWidgetAnnotation class]] ||
|
|
|
+ [annotation isKindOfClass:[CPDFChoiceWidgetAnnotation class]] ||
|
|
|
+ [annotation isKindOfClass:[CPDFInkAnnotation class]]) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+// if (@available(macOS 10.13, *)) {
|
|
|
+// if ([annotation.widgetFieldType isEqualToString:PDFAnnotationWidgetSubtypeSignature]) {
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// }
|
|
|
+ [annotations addObject:annotation];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (CPDFAnnotation *annotation in annotations) {
|
|
|
+ [self removeAnnotation:annotation];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@implementation CPDFView (KMExtension)
|