Skip to content

Commit 98aa3bf

Browse files
[iOS] Use FDFUpdate directly for importing annotations (#347)
* Use FDFUpdate directly for importing annotations * Updating package version * Add changelog entry. * Updating pubspec.yaml * Updating package version --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 3978449 commit 98aa3bf

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 1.0.1-49 - October 15, 2025
2+
- Performance update for the `importAnnotations()` API on iOS
3+
14
# 1.0.1-48 - September 25, 2025
25
- Update Android to v11.8.0
36

ios/Classes/PdftronFlutterPlugin.m

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,8 +1958,9 @@ - (void)importAnnotations:(NSString *)xfdf resultToken:(FlutterResult)flutterRes
19581958
PTAnnotationManager * const annotationManager = documentController.toolManager.annotationManager;
19591959

19601960
NSError *updateError = nil;
1961-
const BOOL updateSuccess = [annotationManager updateAnnotationsWithXFDFString:xfdf
1962-
error:&updateError];
1961+
const BOOL updateSuccess = [self updateAnnotationsWithXFDFString:xfdf
1962+
error:&updateError
1963+
annotationManager:annotationManager];
19631964
if (!updateSuccess) {
19641965
if (updateError) {
19651966
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
19701971
}
19711972
}
19721973

1974+
- (BOOL)updateAnnotationsWithXFDFString:(NSString *)xfdfString
1975+
error:(NSError * _Nullable __autoreleasing * _Nullable)error
1976+
annotationManager:(PTAnnotationManager *)annotationManager
1977+
{
1978+
PTPDFViewCtrl * const pdfViewCtrl = annotationManager.pdfViewCtrl;
1979+
if (!pdfViewCtrl) {
1980+
return NO;
1981+
}
1982+
1983+
[annotationManager willUpdateAnnotationsWithXFDFString:xfdfString];
1984+
1985+
NSError *writeError = nil;
1986+
const BOOL writeSuccess = [pdfViewCtrl DocLock:YES
1987+
withBlock:^(PTPDFDoc * _Nullable doc) {
1988+
1989+
PTFDFDoc * const fdfDoc = [PTFDFDoc CreateFromXFDF:xfdfString];
1990+
if (!fdfDoc) {
1991+
return;
1992+
}
1993+
1994+
[doc FDFUpdate:fdfDoc];
1995+
1996+
// Allow non-standard annotation rotations.
1997+
PTRefreshOptions * const refreshOptions = [[PTRefreshOptions alloc] init];
1998+
[refreshOptions SetUseNonStandardRotation:YES];
1999+
2000+
[doc RefreshAnnotAppearances:refreshOptions];
2001+
2002+
[pdfViewCtrl Update:YES];
2003+
} error:&writeError];
2004+
if (!writeSuccess) {
2005+
NSLog(@"Error: %@", writeError);
2006+
if (error) {
2007+
*error = writeError;
2008+
}
2009+
return NO;
2010+
}
2011+
2012+
[annotationManager didUpdateAnnotationsWithXFDFString:xfdfString];
2013+
2014+
return YES;
2015+
}
2016+
19732017
- (void)exportAnnotations:(NSString *)annotationList resultToken:(FlutterResult)flutterResult
19742018
{
19752019
PTDocumentController *documentController = [self getDocumentController];

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: pdftron_flutter
22
description: A convenience wrapper to build Flutter apps that use the PDFTron mobile SDK for smooth, flexible, and stand-alone document viewing.
3-
version: 1.0.1-48
3+
version: 1.0.1-49
44
homepage: https://www.apryse.com
55
repository: https://github.com/ApryseSDK/pdftron-flutter
66
issue_tracker: https://github.com/ApryseSDK/pdftron-flutter/issues

0 commit comments

Comments
 (0)