File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -173,7 +173,13 @@ - (void)flexibleToolbarContainerDidHide:(PSPDFFlexibleToolbarContainer *)contain
173173#pragma mark - Instant JSON
174174
175175- (NSDictionary <NSString *, NSArray<NSDictionary *> *> *)getAnnotations : (PSPDFPageIndex)pageIndex type : (PSPDFAnnotationType)type {
176- NSArray <PSPDFAnnotation *> *annotations = [self .pdfController.document annotationsForPageAtIndex: pageIndex type: type];
176+ PSPDFDocument *document = self.pdfController .document ;
177+ if (!document.isValid ) {
178+ NSLog (@" Document is invalid." );
179+ return nil ;
180+ }
181+
182+ NSArray <PSPDFAnnotation *> *annotations = [document annotationsForPageAtIndex: pageIndex type: type];
177183 NSArray <NSDictionary *> *annotationsJSON = [RCTConvert instantJSONFromAnnotations: annotations];
178184 return @{@" annotations" : annotationsJSON};
179185}
@@ -234,8 +240,14 @@ - (BOOL)removeAnnotationWithUUID:(NSString *)annotationUUID {
234240}
235241
236242- (NSDictionary <NSString *, NSArray<NSDictionary *> *> *)getAllUnsavedAnnotations {
237- PSPDFDocumentProvider *documentProvider = self.pdfController .document .documentProviders .firstObject ;
238- NSData *data = [self .pdfController.document generateInstantJSONFromDocumentProvider: documentProvider error: NULL ];
243+ PSPDFDocument *document = self.pdfController .document ;
244+ if (!document.isValid ) {
245+ NSLog (@" Document is invalid." );
246+ return nil ;
247+ }
248+
249+ PSPDFDocumentProvider *documentProvider = document.documentProviders .firstObject ;
250+ NSData *data = [document generateInstantJSONFromDocumentProvider: documentProvider error: NULL ];
239251 NSDictionary *annotationsJSON = [NSJSONSerialization JSONObjectWithData: data options: kNilOptions error: NULL ];
240252 return annotationsJSON;
241253}
You can’t perform that action at this time.
0 commit comments