File tree Expand file tree Collapse file tree 5 files changed +22
-10
lines changed
Expand file tree Collapse file tree 5 files changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -2580,7 +2580,7 @@ Parameters:
25802580Name | Type | Description
25812581--- | --- | ---
25822582xfdf | string | annotation string in XFDF format for import
2583- replace | boolean | whether to replace existing form and annotation data with those imported from the XFDF string (Android only)
2583+ replace | boolean | whether to replace existing form and annotation data with those imported from the XFDF string
25842584
25852585Returns a Promise.
25862586Promise Parameters:
Original file line number Diff line number Diff line change @@ -572,7 +572,7 @@ static NSString * const PTSignaturesManager_signatureDirectory = @"PTSignaturesM
572572
573573- (nullable NSString *)exportAnnotationsWithOptions : (NSDictionary *)options ;
574574
575- - (nullable NSArray <NSDictionary *> *)importAnnotations : (NSString *)xfdfString ;
575+ - (nullable NSArray <NSDictionary *> *)importAnnotations : (NSString *)xfdfString replace : ( BOOL ) replace ;
576576
577577- (void )flattenAnnotations : (BOOL )formsOnly ;
578578
Original file line number Diff line number Diff line change @@ -1353,7 +1353,7 @@ - (NSString *)exportAnnotationsWithOptions:(NSDictionary *)options
13531353 return nil ;
13541354}
13551355
1356- - (nullable NSArray <NSDictionary *> *)importAnnotations : (NSString *)xfdfString
1356+ - (nullable NSArray <NSDictionary *> *)importAnnotations : (NSString *)xfdfString replace : ( BOOL ) replace
13571357{
13581358 PTDocumentBaseViewController *documentViewController = self.currentDocumentViewController ;
13591359 PTPDFViewCtrl *pdfViewCtrl = documentViewController.pdfViewCtrl ;
@@ -1369,12 +1369,24 @@ - (NSString *)exportAnnotationsWithOptions:(NSDictionary *)options
13691369 return nil ;
13701370 }
13711371
1372- PTAnnotationManager * const annotationManager = documentViewController.toolManager .annotationManager ;
1372+ if (self.collaborationManager != nil ) {
1373+ [self .collaborationManager importAnnotationsWithXFDFString: xfdfString];
1374+ return [self getAnnotationFromXFDF: xfdfString];
1375+ }
13731376
1374- const BOOL updateSuccess = [annotationManager updateAnnotationsWithXFDFString: xfdfString
1375- error: &error];
1376- if (!updateSuccess || error) {
1377- @throw [NSException exceptionWithName: NSGenericException reason: error.localizedFailureReason userInfo: error.userInfo];
1377+ [pdfViewCtrl DocLock: YES withBlock: ^(PTPDFDoc * _Nullable doc) {
1378+ PTFDFDoc *fdfDoc = [PTFDFDoc CreateFromXFDF: xfdfString];
1379+ if (replace) {
1380+ [doc FDFUpdate: fdfDoc];
1381+ } else {
1382+ [doc FDFMerge: fdfDoc];
1383+ }
1384+ [pdfViewCtrl Update: YES ];
1385+ } error: &error];
1386+
1387+ if (error) {
1388+ NSLog (@" Error: There was an error while trying to import annotations. %@ " , error.localizedDescription );
1389+ return nil ;
13781390 }
13791391
13801392 return [self getAnnotationFromXFDF: xfdfString];
Original file line number Diff line number Diff line change @@ -1130,7 +1130,7 @@ - (void)importAnnotationCommandForDocumentViewTag:(NSNumber *)tag xfdfCommand:(N
11301130{
11311131 RNTPTDocumentView *documentView = self.documentViews [tag];
11321132 if (documentView) {
1133- return [documentView importAnnotations: xfdfString];
1133+ return [documentView importAnnotations: xfdfString replace: replace ];
11341134 } else {
11351135 @throw [NSException exceptionWithName: NSInvalidArgumentException reason: @" Unable to find DocumentView for tag" userInfo: nil ];
11361136 }
Original file line number Diff line number Diff line change 11{
22 "name" : " react-native-pdftron" ,
33 "title" : " React Native Pdftron" ,
4- "version" : " 3.0.3-36 " ,
4+ "version" : " 3.0.3-37 " ,
55 "description" : " React Native Pdftron" ,
66 "main" : " ./lib/index.js" ,
77 "typings" : " index.ts" ,
You can’t perform that action at this time.
0 commit comments