diff --git a/CHANGELOG.md b/CHANGELOG.md index 1db7e1cf..afc8a113 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 1.0.1-49 - October 15, 2025 +- Performance update for the `importAnnotations()` API on iOS + # 1.0.1-48 - September 25, 2025 - Update Android to v11.8.0 diff --git a/ios/Classes/PdftronFlutterPlugin.m b/ios/Classes/PdftronFlutterPlugin.m index 4c3d04d6..636cdf3b 100644 --- a/ios/Classes/PdftronFlutterPlugin.m +++ b/ios/Classes/PdftronFlutterPlugin.m @@ -1958,8 +1958,9 @@ - (void)importAnnotations:(NSString *)xfdf resultToken:(FlutterResult)flutterRes PTAnnotationManager * const annotationManager = documentController.toolManager.annotationManager; NSError *updateError = nil; - const BOOL updateSuccess = [annotationManager updateAnnotationsWithXFDFString:xfdf - error:&updateError]; + const BOOL updateSuccess = [self updateAnnotationsWithXFDFString:xfdf + error:&updateError + annotationManager:annotationManager]; if (!updateSuccess) { if (updateError) { NSLog(@"Error: There was an error while trying to import annotation command. %@", updateError.localizedDescription); @@ -1970,6 +1971,49 @@ - (void)importAnnotations:(NSString *)xfdf resultToken:(FlutterResult)flutterRes } } +- (BOOL)updateAnnotationsWithXFDFString:(NSString *)xfdfString + error:(NSError * _Nullable __autoreleasing * _Nullable)error + annotationManager:(PTAnnotationManager *)annotationManager +{ + PTPDFViewCtrl * const pdfViewCtrl = annotationManager.pdfViewCtrl; + if (!pdfViewCtrl) { + return NO; + } + + [annotationManager willUpdateAnnotationsWithXFDFString:xfdfString]; + + NSError *writeError = nil; + const BOOL writeSuccess = [pdfViewCtrl DocLock:YES + withBlock:^(PTPDFDoc * _Nullable doc) { + + PTFDFDoc * const fdfDoc = [PTFDFDoc CreateFromXFDF:xfdfString]; + if (!fdfDoc) { + return; + } + + [doc FDFUpdate:fdfDoc]; + + // Allow non-standard annotation rotations. + PTRefreshOptions * const refreshOptions = [[PTRefreshOptions alloc] init]; + [refreshOptions SetUseNonStandardRotation:YES]; + + [doc RefreshAnnotAppearances:refreshOptions]; + + [pdfViewCtrl Update:YES]; + } error:&writeError]; + if (!writeSuccess) { + NSLog(@"Error: %@", writeError); + if (error) { + *error = writeError; + } + return NO; + } + + [annotationManager didUpdateAnnotationsWithXFDFString:xfdfString]; + + return YES; +} + - (void)exportAnnotations:(NSString *)annotationList resultToken:(FlutterResult)flutterResult { PTDocumentController *documentController = [self getDocumentController]; diff --git a/pubspec.yaml b/pubspec.yaml index 866ac706..0a68cabc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pdftron_flutter description: A convenience wrapper to build Flutter apps that use the PDFTron mobile SDK for smooth, flexible, and stand-alone document viewing. -version: 1.0.1-48 +version: 1.0.1-49 homepage: https://www.apryse.com repository: https://github.com/ApryseSDK/pdftron-flutter issue_tracker: https://github.com/ApryseSDK/pdftron-flutter/issues