From 67fde3c83200e602186142f65dbc4759dd50e721 Mon Sep 17 00:00:00 2001 From: Sebastien Arbogast Date: Mon, 30 Sep 2024 17:41:40 +0200 Subject: [PATCH] Added customizations on top of 3.12.1 --- android/build.gradle | 7 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../pspdfkit/ConfigurationAdapter.java | 10 ++ .../pspdfkit/FlutterPdfUiFragmentCallbacks.kt | 22 +++- .../pspdfkit/flutter/pspdfkit/PSPDFKitView.kt | 20 ++++ ios/Classes/PspdfPlatformView.m | 10 +- ios/Classes/PspdfkitFlutterHelper.m | 36 +++++- lib/src/pdf_configuration.dart | 108 ++++++++++-------- lib/src/widgets/pspdfkit_widget.dart | 11 +- .../widgets/pspdfkit_widget_controller.dart | 12 ++ .../pspdfkit_widget_controller_native.dart | 28 +++++ .../pspdfkit_widget_controller_web.dart | 16 +++ lib/src/widgets/pspdfkit_widget_web.dart | 8 +- 13 files changed, 228 insertions(+), 62 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 7bff0f83..55fe4247 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -9,6 +9,10 @@ buildscript { apply from: 'config.gradle' + ext { + kotlinVersion = "1.5.20" + } + repositories { google() mavenCentral() @@ -16,6 +20,7 @@ buildscript { dependencies { classpath "com.android.tools.build:gradle:$androidGradlePluginVersion" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" } } @@ -39,7 +44,7 @@ android { namespace "com.pspdfkit.flutter.pspdfkit" compileSdk androidCompileSdkVersion - + compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index af7be50b..8049c684 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/android/src/main/java/com/pspdfkit/flutter/pspdfkit/ConfigurationAdapter.java b/android/src/main/java/com/pspdfkit/flutter/pspdfkit/ConfigurationAdapter.java index eb45a39a..876ef4ab 100644 --- a/android/src/main/java/com/pspdfkit/flutter/pspdfkit/ConfigurationAdapter.java +++ b/android/src/main/java/com/pspdfkit/flutter/pspdfkit/ConfigurationAdapter.java @@ -77,6 +77,7 @@ class ConfigurationAdapter { private static final String ENABLE_DOCUMENT_EDITOR = "enableDocumentEditor"; private static final String DARK_THEME_RESOURCE = "darkThemeResource"; private static final String DEFAULT_THEME_RESOURCE = "defaultThemeResource"; + private static final String RESTORE_LAST_VIEWED_PAGE = "restoreLastViewedPage"; // Thumbnail Options private static final String SHOW_THUMBNAIL_BAR = "showThumbnailBar"; @@ -400,6 +401,11 @@ class ConfigurationAdapter { double value = (double) configurationMap.get(key); configuration.startZoomScale((float) value); } + + key = getKeyOfType(configurationMap, RESTORE_LAST_VIEWED_PAGE, Boolean.class); + if (key != null) { + configureRestoreLastViewedPage((Boolean) configurationMap.get(key)); + } } } @@ -761,6 +767,10 @@ private void configureMeasurementToolSnappingEnabled(Context context,Boolean aBo PSPDFKitPreferences.get(context).setMeasurementSnappingEnabled(aBoolean); } + private void configureRestoreLastViewedPage(boolean restoreLastViewedPage) { + configuration.restoreLastViewedPage(restoreLastViewedPage); + } + private boolean containsKeyOfType(@NonNull HashMap configurationMap, @NonNull String key, @NonNull Class clazz) { diff --git a/android/src/main/java/com/pspdfkit/flutter/pspdfkit/FlutterPdfUiFragmentCallbacks.kt b/android/src/main/java/com/pspdfkit/flutter/pspdfkit/FlutterPdfUiFragmentCallbacks.kt index ab8a8157..a6513ae8 100644 --- a/android/src/main/java/com/pspdfkit/flutter/pspdfkit/FlutterPdfUiFragmentCallbacks.kt +++ b/android/src/main/java/com/pspdfkit/flutter/pspdfkit/FlutterPdfUiFragmentCallbacks.kt @@ -3,11 +3,15 @@ package com.pspdfkit.flutter.pspdfkit import android.content.Context import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager +import com.pspdfkit.annotations.AnnotationProvider import com.pspdfkit.document.PdfDocument -import com.pspdfkit.flutter.pspdfkit.document.FlutterPdfDocument import com.pspdfkit.flutter.pspdfkit.util.MeasurementHelper import com.pspdfkit.listeners.DocumentListener import com.pspdfkit.ui.PdfFragment +import com.pspdfkit.annotations.Annotation +import com.pspdfkit.flutter.pspdfkit.document.FlutterPdfDocument +import com.pspdfkit.ui.special_mode.controller.AnnotationCreationController +import com.pspdfkit.ui.special_mode.manager.AnnotationManager import io.flutter.plugin.common.BinaryMessenger import io.flutter.plugin.common.MethodChannel @@ -15,7 +19,8 @@ class FlutterPdfUiFragmentCallbacks( private val methodChannel: MethodChannel, private val measurementConfigurations: List>?, private val binaryMessenger: BinaryMessenger -) : FragmentManager.FragmentLifecycleCallbacks(), DocumentListener { +) : FragmentManager.FragmentLifecycleCallbacks(), DocumentListener, + AnnotationManager.OnAnnotationCreationModeChangeListener { private var pdfFragment: PdfFragment? = null private var flutterPdfDocument: FlutterPdfDocument? = null @@ -35,6 +40,7 @@ class FlutterPdfUiFragmentCallbacks( } pdfFragment = f as PdfFragment pdfFragment?.addDocumentListener(this) + pdfFragment?.addOnAnnotationCreationModeChangeListener(this) } } @@ -85,4 +91,16 @@ class FlutterPdfUiFragmentCallbacks( } } } + + override fun onEnterAnnotationCreationMode(annotationCreationController: AnnotationCreationController) { + + } + + override fun onChangeAnnotationCreationMode(annotationCreationController: AnnotationCreationController) { + + } + + override fun onExitAnnotationCreationMode(annotationCreationController: AnnotationCreationController) { + methodChannel.invokeMethod("onExitAnnotationCreationMode", null) + } } \ No newline at end of file diff --git a/android/src/main/java/com/pspdfkit/flutter/pspdfkit/PSPDFKitView.kt b/android/src/main/java/com/pspdfkit/flutter/pspdfkit/PSPDFKitView.kt index 9588256b..7e93ee18 100644 --- a/android/src/main/java/com/pspdfkit/flutter/pspdfkit/PSPDFKitView.kt +++ b/android/src/main/java/com/pspdfkit/flutter/pspdfkit/PSPDFKitView.kt @@ -47,6 +47,9 @@ import io.reactivex.rxjava3.subscribers.DisposableSubscriber import org.json.JSONObject import java.io.ByteArrayOutputStream import java.io.File +import com.pspdfkit.preferences.PSPDFKitPreferences +import com.pspdfkit.ui.special_mode.controller.AnnotationTool +import com.pspdfkit.ui.special_mode.controller.AnnotationToolVariant internal class PSPDFKitView( val context: Context, @@ -597,6 +600,23 @@ internal class PSPDFKitView( } }) } + "jumpToPage" -> { + val pageIndex: Int = requireNotNull(call.argument("pageIndex")) + pdfUiFragment.pageIndex = pageIndex + result.success(true) + } + + "isShowingTwoPages" -> { + val pageIndex = pdfUiFragment.pdfFragment?.pageIndex ?: -1 + result.success(pdfUiFragment.pdfFragment?.getSiblingPageIndex(pageIndex) != -1) + } + + "enterAnnotationCreationMode" -> { + val authorName: String = requireNotNull(call.argument("authorName")) + PSPDFKitPreferences.get(context).setAnnotationCreator(authorName) + pdfUiFragment.pdfFragment?.enterAnnotationCreationMode(AnnotationTool.INK, AnnotationToolVariant.fromPreset(AnnotationToolVariant.Preset.PEN)) + result.success(true) + } else -> result.notImplemented() } } diff --git a/ios/Classes/PspdfPlatformView.m b/ios/Classes/PspdfPlatformView.m index 6f0bec7b..4a8fb18f 100644 --- a/ios/Classes/PspdfPlatformView.m +++ b/ios/Classes/PspdfPlatformView.m @@ -15,7 +15,7 @@ @import PSPDFKit; @import PSPDFKitUI; -@interface PspdfPlatformView() +@interface PspdfPlatformView() @property int64_t platformViewId; @property (nonatomic) FlutterMethodChannel *channel; @property (nonatomic) FlutterMethodChannel *broadcastChannel; @@ -70,6 +70,7 @@ - (instancetype)initWithFrame:(CGRect)frame viewIdentifier:(int64_t)viewId argum _pdfViewController.appearanceModeManager.appearanceMode = [PspdfkitFlutterConverter appearanceMode:configurationDictionary]; _pdfViewController.pageIndex = [PspdfkitFlutterConverter pageIndex:configurationDictionary]; _pdfViewController.delegate = self; + _pdfViewController.annotationToolbarController.toolbar.toolbarDelegate = self; [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(documentDidFinishRendering) name:PSPDFDocumentViewControllerDidConfigureSpreadViewNotification object:nil]; @@ -169,4 +170,11 @@ - (void)pdfViewControllerDidDismiss:(PSPDFViewController *)pdfController { [self cleanup]; } +# pragma mark - PSPDFFlexibleToolbarDelegate + +- (void)flexibleToolbarDidHide:(PSPDFFlexibleToolbar *)toolbar { + // Handle annotation toolbar being hidden. + [_channel invokeMethod:@"onExitAnnotationCreationMode" arguments: nil]; +} + @end diff --git a/ios/Classes/PspdfkitFlutterHelper.m b/ios/Classes/PspdfkitFlutterHelper.m index 67cb1e61..d602ab1a 100644 --- a/ios/Classes/PspdfkitFlutterHelper.m +++ b/ios/Classes/PspdfkitFlutterHelper.m @@ -208,7 +208,41 @@ + (void)processMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result result(nil); } else if ([@"getZoomScale" isEqualToString:call.method]) { result(FlutterMethodNotImplemented); - }else { + } else if ([@"jumpToPage" isEqualToString:call.method]) { + @try { + PSPDFPageIndex pageIndex = [call.arguments[@"pageIndex"] longLongValue]; + [pdfViewController setPageIndex:pageIndex animated:YES]; + result(@(YES)); + } @catch (NSException *exception) { + result([FlutterError errorWithCode:@"" message:exception.reason details:nil]); + } + } else if ([@"isShowingTwoPages" isEqualToString:call.method]) { + BOOL showingTwoPages = pdfViewController.documentViewController.layout.spreadMode != PSPDFDocumentViewLayoutSpreadModeSingle; + result(@(showingTwoPages)); + } else if([@"enterAnnotationCreationMode" isEqualToString:call.method]){ + @try { + NSString *authorName = call.arguments[@"authorName"]; + PSPDFUsernameHelper.defaultAnnotationUsername = authorName; + + PSPDFDocument *document = pdfViewController.document; + if (!document || !document.isValid) { + result([FlutterError errorWithCode:@"" message:@"PDF document not found or is invalid." details:nil]); + return; + } + document.defaultAnnotationUsername = authorName; + + [pdfViewController.annotationToolbarController updateHostView:nil container:nil viewController:pdfViewController]; + + [pdfViewController.annotationToolbarController showToolbarAnimated:YES completion:^(BOOL finished) { + if (finished) { + [pdfViewController.annotationStateManager setState:PSPDFAnnotationStringInk variant:PSPDFAnnotationVariantStringInkPen]; + } + }]; + result(@(YES)); + } @catch (NSException *exception) { + result([FlutterError errorWithCode:@"" message:exception.reason details:nil]); + } + } else { result(FlutterMethodNotImplemented); } } diff --git a/lib/src/pdf_configuration.dart b/lib/src/pdf_configuration.dart index 4a4cb99b..4fe4f29e 100644 --- a/lib/src/pdf_configuration.dart +++ b/lib/src/pdf_configuration.dart @@ -174,55 +174,62 @@ class PdfConfiguration { /// Sets the minimum zoom scale. Defaults to null. final double? minimumZoomScale; - PdfConfiguration( - {this.scrollDirection, - this.pageTransition, - this.enableTextSelection, - this.disableAutosave, - this.pageLayoutMode, - this.spreadFitting, - this.showPageLabels, - this.startPage, - this.documentLabelEnabled, - this.firstPageAlwaysSingle, - this.invertColors, - this.password, - this.androidGrayScale, - this.inlineSearch, - this.toolbarTitle, - this.showActionNavigationButtons, - this.userInterfaceViewMode, - this.immersiveMode, - this.appearanceMode, - this.settingsMenuItems, - this.androidShowSearchAction, - this.androidShowOutlineAction, - this.androidShowBookmarksAction, - this.androidEnableDocumentEditor, - this.androidShowShareAction, - this.androidShowPrintAction, - this.androidShowDocumentInfoView, - this.androidShowAnnotationListAction, - this.androidDarkThemeResource, - this.androidDefaultThemeResource, - this.iOSLeftBarButtonItems, - this.iOSRightBarButtonItems, - this.iOSAllowToolbarTitleChange, - this.showThumbnailBar, - this.androidShowThumbnailGridAction, - this.enableAnnotationEditing, - this.enableInstantComments, - this.webConfiguration, - this.editableAnnotationTypes, - this.toolbarMenuItems, - this.enableMeasurementTools, - this.measurementSnappingEnabled, - this.enableMagnifier, - this.measurementValueConfigurations, - this.annotationToolsGrouping, - this.defaultZoomScale, - this.maximumZoomScale, - this.minimumZoomScale}); + /// Enables or disables restoration of the last viewed page when reopening a document. + /// If true, the last viewed page will be restored when opening the document a second time. + /// If false, the document will be opened at page index 0. Defaults to true. + final bool restoreLastViewedPage; + + PdfConfiguration({ + this.scrollDirection, + this.pageTransition, + this.enableTextSelection, + this.disableAutosave, + this.pageLayoutMode, + this.spreadFitting, + this.showPageLabels, + this.startPage, + this.documentLabelEnabled, + this.firstPageAlwaysSingle, + this.invertColors, + this.password, + this.androidGrayScale, + this.inlineSearch, + this.toolbarTitle, + this.showActionNavigationButtons, + this.userInterfaceViewMode, + this.immersiveMode, + this.appearanceMode, + this.settingsMenuItems, + this.androidShowSearchAction, + this.androidShowOutlineAction, + this.androidShowBookmarksAction, + this.androidEnableDocumentEditor, + this.androidShowShareAction, + this.androidShowPrintAction, + this.androidShowDocumentInfoView, + this.androidShowAnnotationListAction, + this.androidDarkThemeResource, + this.androidDefaultThemeResource, + this.iOSLeftBarButtonItems, + this.iOSRightBarButtonItems, + this.iOSAllowToolbarTitleChange, + this.showThumbnailBar, + this.androidShowThumbnailGridAction, + this.enableAnnotationEditing, + this.enableInstantComments, + this.webConfiguration, + this.editableAnnotationTypes, + this.toolbarMenuItems, + this.enableMeasurementTools, + this.measurementSnappingEnabled, + this.enableMagnifier, + this.measurementValueConfigurations, + this.annotationToolsGrouping, + this.defaultZoomScale, + this.maximumZoomScale, + this.minimumZoomScale, + this.restoreLastViewedPage = true, + }); /// Returns a [Map] representation of the [PdfConfiguration] object. /// This is used to pass the configuration to the platform side. @@ -273,7 +280,8 @@ class PdfConfiguration { 'toolbarItemGrouping': convertAnnotationToolsGrouping(), 'defaultZoomScale': defaultZoomScale, 'maximumZoomScale': maximumZoomScale, - 'minimumZoomScale': minimumZoomScale + 'minimumZoomScale': minimumZoomScale, + 'restoreLastViewedPage': restoreLastViewedPage, }..removeWhere((key, value) => value == null); } diff --git a/lib/src/widgets/pspdfkit_widget.dart b/lib/src/widgets/pspdfkit_widget.dart index 5e88f29f..7c042c9f 100644 --- a/lib/src/widgets/pspdfkit_widget.dart +++ b/lib/src/widgets/pspdfkit_widget.dart @@ -9,13 +9,15 @@ library pspdfkit_widget; import 'dart:async'; -import 'package:flutter/services.dart'; + +import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; -import 'package:flutter/rendering.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter/services.dart'; import 'package:pspdfkit_flutter/pspdfkit.dart'; + import 'pspdfkit_widget_controller_native.dart'; class PspdfkitWidget extends StatefulWidget { @@ -25,6 +27,7 @@ class PspdfkitWidget extends StatefulWidget { final PdfDocumentLoadedCallback? onPdfDocumentLoaded; final PdfDocumentLoadFailedCallback? onPdfDocumentError; final PageChangedCallback? onPageChanged; + final VoidCallback? onExitAnnotationCreationMode; const PspdfkitWidget({ Key? key, @@ -34,6 +37,7 @@ class PspdfkitWidget extends StatefulWidget { this.onPdfDocumentLoaded, this.onPdfDocumentError, this.onPageChanged, + this.onExitAnnotationCreationMode, }) : super(key: key); @override @@ -118,6 +122,7 @@ class _PspdfkitWidgetState extends State { onPageChanged: widget.onPageChanged, onPdfDocumentLoadFailed: widget.onPdfDocumentError, onPdfDocumentLoaded: widget.onPdfDocumentLoaded, + onExitAnnotationCreationMode: widget.onExitAnnotationCreationMode, ); widget.onPspdfkitWidgetCreated?.call(controller); } diff --git a/lib/src/widgets/pspdfkit_widget_controller.dart b/lib/src/widgets/pspdfkit_widget_controller.dart index 79efaf0a..8a1da665 100644 --- a/lib/src/widgets/pspdfkit_widget_controller.dart +++ b/lib/src/widgets/pspdfkit_widget_controller.dart @@ -84,4 +84,16 @@ abstract class PspdfkitWidgetController { /// pageIndex The index of the page. This is a zero-based index. /// Returns a [Future] that completes with the zoom scale of the given page. Future getZoomScale(int pageIndex); + + /// Programmatically jump to a specific page. + /// @param pageIndex The index of the page to jump to. + Future jumpToPage(int pageIndex); + + /// Returns true if the document is showing two pages. + /// This is especially useful when the page layout mode is automatic + Future isShowingTwoPages(); + + /// Programmatically enters annotation creation mode. + /// @param authorName The name of the author for the annotation. + Future enterAnnotationCreationMode(String authorName); } diff --git a/lib/src/widgets/pspdfkit_widget_controller_native.dart b/lib/src/widgets/pspdfkit_widget_controller_native.dart index 2e9af31c..8800e116 100644 --- a/lib/src/widgets/pspdfkit_widget_controller_native.dart +++ b/lib/src/widgets/pspdfkit_widget_controller_native.dart @@ -8,6 +8,7 @@ /// import 'package:flutter/services.dart'; + import '../../pspdfkit.dart'; import '../document/pdf_document_native.dart'; @@ -20,6 +21,7 @@ class PspdfkitWidgetControllerNative extends PspdfkitWidgetController { PdfDocumentLoadedCallback? onPdfDocumentLoaded, PdfDocumentLoadFailedCallback? onPdfDocumentLoadFailed, PageChangedCallback? onPageChanged, + VoidCallback? onExitAnnotationCreationMode, }) : _channel = MethodChannel('com.pspdfkit.widget.$id') { _channel.setMethodCallHandler((call) async { switch (call.method) { @@ -35,6 +37,9 @@ class PspdfkitWidgetControllerNative extends PspdfkitWidgetController { var pageIndex = call.arguments['pageIndex']; onPageChanged?.call(pageIndex); break; + case 'onExitAnnotationCreationMode': + onExitAnnotationCreationMode?.call(); + break; } }); } @@ -169,4 +174,27 @@ class PspdfkitWidgetControllerNative extends PspdfkitWidgetController { throw Exception('Error getting zoom scale: $error'); }); } + + @override + Future jumpToPage(int pageIndex) async { + final result = await _channel.invokeMethod('jumpToPage', { + 'pageIndex': pageIndex, + }); + return result; + } + + @override + Future isShowingTwoPages() async { + final result = await _channel.invokeMethod('isShowingTwoPages'); + return result; + } + + @override + Future enterAnnotationCreationMode(String authorName) async { + final result = await _channel + .invokeMethod('enterAnnotationCreationMode', { + 'authorName': authorName, + }); + return result; + } } diff --git a/lib/src/widgets/pspdfkit_widget_controller_web.dart b/lib/src/widgets/pspdfkit_widget_controller_web.dart index 275aabe0..7b8fc4b3 100644 --- a/lib/src/widgets/pspdfkit_widget_controller_web.dart +++ b/lib/src/widgets/pspdfkit_widget_controller_web.dart @@ -10,6 +10,7 @@ import 'dart:ui'; import 'package:pspdfkit_flutter/src/web/pspdfkit_web_instance.dart'; + import '../../pspdfkit.dart'; import '../web/pspdfkit_web.dart'; @@ -121,4 +122,19 @@ class PspdfkitWidgetControllerWeb extends PspdfkitWidgetController { Future getZoomScale(int pageIndex) { return pspdfkitInstance.getZoomScale(pageIndex); } + + @override + Future jumpToPage(int pageIndex) async { + throw UnimplementedError('This method id not supported on the web!'); + } + + @override + Future isShowingTwoPages() async { + throw UnimplementedError('This method id not supported on the web!'); + } + + @override + Future enterAnnotationCreationMode(String authorName) async { + throw UnimplementedError('This method id not supported on the web!'); + } } diff --git a/lib/src/widgets/pspdfkit_widget_web.dart b/lib/src/widgets/pspdfkit_widget_web.dart index ff095d94..74d0b7d4 100644 --- a/lib/src/widgets/pspdfkit_widget_web.dart +++ b/lib/src/widgets/pspdfkit_widget_web.dart @@ -11,10 +11,12 @@ library pspdfkit_widget_web; import 'dart:async'; import 'dart:html' as html; import 'dart:ui_web' as ui; + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:pspdfkit_flutter/pspdfkit.dart'; import 'package:pspdfkit_flutter/src/web/pspdfkit_web_instance.dart'; + import '../document/pdf_document_web.dart'; import '../web/pspdfkit_web.dart'; import 'pspdfkit_widget_controller_web.dart'; @@ -24,7 +26,7 @@ class PspdfkitWidget extends StatefulWidget { final dynamic configuration; final PspdfkitWidgetCreatedCallback? onPspdfkitWidgetCreated; final PdfDocumentLoadedCallback? onPdfDocumentLoaded; - final PdfDocumentLoadFailedCallback? onPdfDocumentLoadFailure; + final PdfDocumentLoadFailedCallback? onPdfDocumentError; final PageChangedCallback? onPageChanged; const PspdfkitWidget({ @@ -33,7 +35,7 @@ class PspdfkitWidget extends StatefulWidget { this.configuration, this.onPspdfkitWidgetCreated, this.onPdfDocumentLoaded, - this.onPdfDocumentLoadFailure, + this.onPdfDocumentError, this.onPageChanged, }) : super(key: key); @@ -93,7 +95,7 @@ class _PspdfkitWidgetState extends State { widget.onPdfDocumentLoaded ?.call(PdfDocumentWeb(documentId: '', instance: value)); }).catchError((error) { - widget.onPdfDocumentLoadFailure?.call(error.toString()); + widget.onPdfDocumentError?.call(error.toString()); throw Exception('Failed to load: $error'); }); });