### Complete PSPDFKit Flutter Main Application Setup Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/doc/demo_project_main.dart.txt This code provides the complete `main.dart` file for a Flutter application integrating PSPDFKit. It initializes the PSPDFKit library, handles asset extraction for PDF documents, and displays the document using `PspdfkitWidget`. ```Dart /// Copyright © 2021-2025 PSPDFKit GmbH. All rights reserved. /// /// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW /// AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT. /// UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES. /// This notice may not be removed from this file. /// This is the main.dart code that should be copied into the demo project explained in `../README.md`. import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:pspdfkit_flutter/pspdfkit.dart'; const String DOCUMENT_PATH = 'PDFs/Document.pdf'; void main() => runApp(MyApp()); class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State { @override void initState() { super.initState(); initPlatformState(); } void initPlatformState() async { // By default, this example doesn't set a license key, but instead runs in trial mode (which is the default, and which requires no // specific initialization). If you want to use a different license key for evaluation (e.g. a production license), you can uncomment // the next line and set the license key. // // To set the license key for both platforms, use: // await Pspdfkit.setLicenseKeys("YOUR_FLUTTER_ANDROID_LICENSE_KEY_GOES_HERE", "YOUR_FLUTTER_IOS_LICENSE_KEY_GOES_HERE"); // // To set the license key for the currently running platform, use: // await Pspdfkit.setLicenseKey("YOUR_FLUTTER_LICENSE_KEY_GOES_HERE"); } Future extractAsset(BuildContext context, String assetPath) async { if (kIsWeb) { return assetPath; } final bytes = await DefaultAssetBundle.of(context).load(assetPath); final list = bytes.buffer.asUint8List(); final tempDir = await Pspdfkit.getTemporaryDirectory(); final tempDocumentPath = '${tempDir.path}/$assetPath'; final file = File(tempDocumentPath); await file.create(recursive: true); file.writeAsBytesSync(list); return file.path; } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: FutureBuilder( future: extractAsset(context, DOCUMENT_PATH), builder: (context, snapshot) { if (snapshot.hasData) { /// PspdfkitWidget is a widget that displays a PDF document. return PspdfkitWidget( documentPath: snapshot.data!, ); } else { return const Center(child: CircularProgressIndicator()); } })), ); } } ``` -------------------------------- ### Install Flutter Dependencies Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/README.md Runs `flutter pub get` to fetch and install the newly added `pspdfkit_flutter` package and its transitive dependencies. ```bash flutter pub get ``` -------------------------------- ### Clone PSPDFKit Flutter Example Repository Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/example/README.md Clones the PSPDFKit Flutter example project from its GitHub repository to your local machine. ```Shell git clone https://github.com/PSPDFKit/pspdfkit-flutter.git ``` -------------------------------- ### Navigate to PSPDFKit Flutter Example Directory Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/example/README.md Changes the current working directory to the 'example' folder within the cloned PSPDFKit Flutter repository, where the project files are located. ```Shell cd pspdfkit-flutter/example ``` -------------------------------- ### Run PSPDFKit Flutter Example on All Connected Devices Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/example/README.md Deploys and runs the PSPDFKit Flutter example application on all connected devices, including both iOS and Android emulators or physical devices. ```Shell flutter run -d all ``` -------------------------------- ### Quick Start Example for Custom PSPDFKit Flutter Toolbar Items Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/custom-toolbar-items-guide.md Demonstrates how to add multiple custom toolbar items (back, highlight, share) to a PSPDFKitWidget in Flutter, including setting their identifiers, titles, icons (with platform-specific variations), positions, and handling their tap events using a switch statement. ```Dart import 'package:pspdfkit_flutter/pspdfkit.dart'; import 'dart:io' show Platform; PSPDFKitWidget( documentPath: 'path/to/document.pdf', customToolbarItems: [ // Back button (left side on iOS) CustomToolbarItem( identifier: 'action_back', title: 'Back', iconName: Platform.isIOS ? 'chevron.left' : 'arrow_back', position: ToolbarPosition.iosLeft, ), // Highlight button (main toolbar) CustomToolbarItem( identifier: 'action_highlight', title: 'Highlight', iconName: Platform.isIOS ? 'highlighter' : 'highlight_icon', iconColor: '#FFCC00', position: ToolbarPosition.primary, ), // Share button (may be in overflow menu on Android) CustomToolbarItem( identifier: 'action_share', title: 'Share', iconName: Platform.isIOS ? 'square.and.arrow.up' : 'share', position: ToolbarPosition.secondary, ), ], onCustomToolbarItemTapped: (identifier) { switch (identifier) { case 'action_back': Navigator.of(context).pop(); break; case 'action_highlight': // Show highlight options or activate highlighting mode _pspdfkitWidgetController?.enterAnnotationCreationMode( AnnotationType.highlight ); break; case 'action_share': // Share document _shareDocument(); break; } }, ) ``` -------------------------------- ### Launch Flutter Emulator Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/example/README.md Launches a specified Android emulator for testing the Flutter application. Replace '' with the actual ID of the emulator you wish to use. ```Shell flutter emulators --launch ``` -------------------------------- ### PSPDFKit Flutter UI Configuration Options Reference Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/configuration-options.md A reference guide to the configurable options for the PSPDFKit Flutter user interface, detailing each option's data type, accepted values, and platform-specific behavior or requirements. ```APIDOC User Interface Configuration Options: inlineSearch: Type: Boolean Possible Values: true, false iOS Support: ✅ Android Support: ✅ Description: Sets the type of search bar to be inline or modular. toolbarTitle: Type: String Possible Values: - iOS Support: ✅ Android Support: ✅ Description: Sets the title of the toolbar. Note: For iOS, you need to set `documentLabelEnabled`, `iOSUseParentNavigationBar`, and `iOSAllowToolbarTitleChange` to `false` in your configuration before setting the custom title. showActionNavigationButtons: Type: Boolean Possible Values: true, false iOS Support: ✅ Android Support: ✅ Description: Show action navigation buttons. userInterfaceViewMode: Type: String Possible Values: automatic, automaticBorderPages, automaticNoFirstLastPage, always, alwaysVisible, alwaysHidden, never iOS Support: ✅ Android Support: ✅ Description: Configures the user interface visibility. immersiveMode: Type: Boolean Possible Values: true, false iOS Support: ✅ Android Support: ✅ Description: Hides the user interface if set to `true`. appearanceMode: Type: String Possible Values: default, night, sepia iOS Support: ✅ Android Support: ✅ Description: Sets the appearance mode for the document. ``` -------------------------------- ### Configure PSPDFKit License Keys in Flutter Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/doc/demo_project_main.dart.txt This snippet demonstrates how to set PSPDFKit license keys for Android and iOS platforms, or for the currently running platform. By default, PSPDFKit runs in trial mode without explicit license key initialization. ```Dart // To set the license key for both platforms, use: // await Pspdfkit.setLicenseKeys("YOUR_FLUTTER_ANDROID_LICENSE_KEY_GOES_HERE", "YOUR_FLUTTER_IOS_LICENSE_KEY_GOES_HERE"); // // To set the license key for the currently running platform, use: // await Pspdfkit.setLicenseKey("YOUR_FLUTTER_LICENSE_KEY_GOES_HERE"); ``` -------------------------------- ### Implementing a Custom Back Button in PSPDFKit Flutter Toolbar Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/custom-toolbar-items-guide.md Provides an example of adding a custom back button to the PSPDFKit Flutter toolbar. It shows how to define the `CustomToolbarItem` with a platform-specific icon and position, and how to handle its tap event within the `onCustomToolbarItemTapped` callback to navigate back. ```Dart // Add back button to the customToolbarItems list CustomToolbarItem( identifier: 'action_back', title: 'Back', iconName: Platform.isIOS ? 'chevron.left' : 'arrow_back', position: ToolbarPosition.iosLeft, // Position on the left for iOS ), // Handle back button tap in the `onCustomToolbarItemTapped` callback onCustomToolbarItemTapped: (identifier) { if (identifier == 'action_back') { Navigator.of(context).pop(); // Or your preferred navigation logic } // ... handle other identifiers }, ``` -------------------------------- ### Display PDF Documents with PspdfkitWidget in Flutter Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/doc/demo_project_main.dart.txt This snippet shows how to integrate `PspdfkitWidget` into a Flutter application to display a PDF document. It uses a `FutureBuilder` to wait for the asset extraction to complete before rendering the widget. ```Dart /// PspdfkitWidget is a widget that displays a PDF document. return PspdfkitWidget( documentPath: snapshot.data!, ); ``` -------------------------------- ### PSPDFKit Flutter CustomToolbarItem Position Parameter Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/custom-toolbar-items-guide.md Describes the `position` parameter of the `CustomToolbarItem` class, detailing its possible values (`ToolbarPosition.primary`, `ToolbarPosition.secondary`, `ToolbarPosition.iosLeft`) and their respective behaviors on Android and iOS platforms. ```APIDOC | Position | Value | Behavior | |-------------|----------------------------|------------------------------------------------| | `primary` | `ToolbarPosition.primary` | Main toolbar (Android) / Right side (iOS) | | `secondary` | `ToolbarPosition.secondary`| Overflow menu (Android) / Right side (iOS) | | `iosLeft` | `ToolbarPosition.iosLeft` | Left side of navigation bar (iOS) | ``` -------------------------------- ### Install or Update CocoaPods Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/ios/README.md This command installs or updates the CocoaPods dependency manager using RubyGems. CocoaPods is essential for managing iOS dependencies in Flutter projects that integrate native iOS components. ```Shell gem install cocoapods ``` -------------------------------- ### Extract PDF Assets for PSPDFKit in Flutter Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/doc/demo_project_main.dart.txt This utility function demonstrates how to extract a PDF document from the Flutter application's assets and save it to a temporary directory, making it accessible for PSPDFKit. It handles both web and native platforms. ```Dart Future extractAsset(BuildContext context, String assetPath) async { if (kIsWeb) { return assetPath; } final bytes = await DefaultAssetBundle.of(context).load(assetPath); final list = bytes.buffer.asUint8List(); final tempDir = await Pspdfkit.getTemporaryDirectory(); final tempDocumentPath = '${tempDir.path}/$assetPath'; final file = File(tempDocumentPath); await file.create(recursive: true); file.writeAsBytesSync(list); return file.path; } ``` -------------------------------- ### Cross-Platform Custom Toolbar Item Icon Handling in PSPDFKit Flutter Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/custom-toolbar-items-guide.md Demonstrates how to use `Platform.isIOS` to conditionally set the `iconName` for a `CustomToolbarItem`, allowing different icons for iOS (SF Symbols) and Android (custom drawables) while maintaining a consistent blue color. ```Dart import 'dart:io' show Platform; CustomToolbarItem( identifier: 'bookmark_action', title: 'Bookmark', iconName: Platform.isIOS ? 'bookmark.fill' : 'bookmark_icon', iconColor: '#0066CC', // Blue color (hex format) position: ToolbarPosition.primary, ) ``` -------------------------------- ### Referencing Custom Icons in PSPDFKit Flutter (Android) Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/custom-toolbar-items-guide.md Illustrates how to reference a custom icon for Android toolbar items in Flutter. Requires adding icon files (Vector Drawables or bitmaps) to `android/app/src/main/res/drawable/` and then referencing them by filename without extension in `iconName`. ```Dart iconName: 'my_icon' ``` -------------------------------- ### Handle Custom Toolbar Item Taps in Flutter Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/custom-toolbar-items-guide.md Implement the `onCustomToolbarItemTapped` callback to respond to user taps on custom toolbar items. The `identifier` parameter helps determine which item was tapped, allowing for conditional execution of actions such as activating annotation modes, sharing documents, or displaying the search UI. ```Dart onCustomToolbarItemTapped: (identifier) { switch (identifier) { case 'action_highlight': // Example: Activate highlighting annotation mode _pspdfkitWidgetController?.enterAnnotationCreationMode( AnnotationType.highlight ); break; case 'action_share': // Example: Implement a function to share the document _shareDocument(); break; case 'action_search': // Example: Show the built-in search UI _pspdfkitWidgetController?.showSearchUI(); break; // Handle other identifiers... } }, ``` -------------------------------- ### Create PDFs Directory Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/README.md Creates a `PDFs` directory in the project root to store sample PDF documents. ```bash mkdir PDFs ``` -------------------------------- ### Initialize Flutter Web Application Entrypoint Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/example/web/index.html This JavaScript snippet handles the loading and initialization of a Flutter web application. It waits for the 'load' event, then uses `_flutter.loader.loadEntrypoint` to manage the service worker and load the main application. The `onEntrypointLoaded` callback ensures the Flutter engine is initialized and the application is run. ```JavaScript const serviceWorkerVersion = null; window.addEventListener('load', function(ev) { // Download main.dart.js _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, }, onEntrypointLoaded: function(engineInitializer) { engineInitializer.initializeEngine().then(function(appRunner) { appRunner.runApp(); }); } }); }); ``` -------------------------------- ### Initialize and Display PDF with PSPDFKit Flutter Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/README.md Demonstrates the core usage of the PSPDFKit Flutter SDK. It initializes the SDK with license keys, extracts a PDF asset to a temporary location (handling web and non-web platforms), and displays it using the `PspdfkitWidget`. ```dart import 'package:flutter/material.dart'; import 'package:pspdfkit_flutter/pspdfkit_flutter.dart'; import 'dart:io'; import 'package:flutter/foundation.dart'; const String documentPath = 'PDFs/Document.pdf'; void main() async { WidgetsFlutterBinding.ensureInitialized(); // Initialize the Nutrient SDK with your license key await Pspdfkit.initialize( androidLicenseKey: 'YOUR_ANDROID_LICENSE_KEY', iosLicenseKey: 'YOUR_IOS_LICENSE_KEY', webLicenseKey: 'YOUR_WEB_LICENSE_KEY', ); runApp(const MaterialApp( home: MyApp(), )); } class MyApp extends StatelessWidget { const MyApp({super.key}); Future extractAsset(BuildContext context, String assetPath) async { if (kIsWeb) { return assetPath; } final bytes = await DefaultAssetBundle.of(context).load(assetPath); final list = bytes.buffer.asUint8List(); final tempDir = await Pspdfkit.getTemporaryDirectory(); final tempDocumentPath = '${tempDir.path}/$assetPath'; final file = File(tempDocumentPath); await file.create(recursive: true); file.writeAsBytesSync(list); return file.path; } @override Widget build(BuildContext context) { return Scaffold( body: FutureBuilder( future: extractAsset(context, documentPath), builder: (context, snapshot) { if (snapshot.hasData) { /// PspdfkitWidget is a widget that displays a PDF document. return PspdfkitWidget( documentPath: snapshot.data!, ); } else if (snapshot.hasError) { return Center( child: Text('${snapshot.error}'), ); } else { return const Center( child: CircularProgressIndicator(), ); } }), ); } } ``` -------------------------------- ### PSPDFKit Flutter: Document Presentation Configuration Options Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/configuration-options.md API documentation for configuration options that control the visual presentation of documents in PSPDFKit Flutter, including page mode, fitting, labels, and color inversion. ```APIDOC Document Presentation Options: - pageMode: DataType: String PossibleValues: single, double, automatic iOS: Supported Android: Supported Documentation: Configure the page mode. - spreadFitting: DataType: String PossibleValues: fit, fill, \`adaptive\` iOS: Supported Android: Supported Documentation: Controls the page fitting mode. \`adaptive\` mode only works on iOS and has no effect on Android. - showPageLabels: DataType: Boolean PossibleValues: true / false iOS: Supported Android: Supported Documentation: Displays the current page number. - startPage: DataType: Integer PossibleValues: - iOS: Supported Android: Supported Documentation: Configures the starting page number. - documentLabelEnabled: DataType: Bool PossibleValues: true / false iOS: Supported Android: Supported Documentation: Shows an overlay displaying the document name. - firstPageAlwaysSingle: DataType: Boolean PossibleValues: true / false iOS: Supported Android: Supported Documentation: Option to show the first page separately. - invertColors: DataType: Boolean PossibleValues: true / false iOS: Supported Android: Supported Documentation: Inverts the document color if \`true\`. - password: DataType: String PossibleValues: - iOS: Supported Android: Supported Documentation: The password needed to unlock the document. - androidGrayScale: DataType: Boolean PossibleValues: true / false iOS: Not Supported Android: Supported Documentation: Converts the document colors to grayscale. ``` -------------------------------- ### Platform-Specific Annotation Configuration Details (APIDOC) Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/annotation-preset-configuration-guide.md This section details platform-specific considerations for signature configuration and additional properties available on iOS and Android. It highlights the different implementations required for signature storage and unique customization options per platform. ```APIDOC Signature Configuration: iOS: Uses: SignatureHelper class Details: PSPDFKit sets up PSPDFKeychainSignatureStore automatically when a signature saving strategy is specified. Android: Implementation: Implement DatabaseSignatureStorage in your FlutterPdfActivity where PdfFragment is used. Platform-Specific Properties: iOS: Properties: blendMode, borderStyle Android: Properties: availableColors, min/maxThickness, min/maxAlpha, enableColorPicker, etc. ``` -------------------------------- ### PSPDFKit Flutter: Configure Settings Menu Items Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/configuration-options.md Options that will be presented in the settings menu. The options prefixed with iOS or Android only work on the respective platform. Options without any prefix work on both platforms. ```APIDOC Property: settingsMenuItems Type: Array of String Description: Options that will be presented in the settings menu. The options prefixed with iOS or Android only work on the respective platform. Options without any prefix work on both platforms. Possible Values: - pageTransition - scrollDirection - androidTheme - iOSAppearance - androidPageLayout - iOSPageMode - iOSSpreadFitting - androidScreenAwake - iOSBrightness Platform Support: iOS: Yes Android: Yes ``` -------------------------------- ### Set iOS Deployment Target in Podfile Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/README.md Configures the `ios/Podfile` to set the minimum iOS deployment target to `16.0`, a requirement for the PSPDFKit SDK. ```ruby platform :ios, '16.0' ``` -------------------------------- ### Available Annotation Configuration Types (APIDOC) Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/annotation-preset-configuration-guide.md This section lists the various configuration classes available in PSPDFKit Flutter for customizing annotation properties. Each configuration type is associated with specific annotation tools, allowing developers to fine-tune their appearance and behavior. ```APIDOC InkAnnotationConfiguration: Applies to: Pen, Highlighter, Magic Ink, Eraser, Signature LineAnnotationConfiguration: Applies to: Line, Arrow, Polyline, Distance Measurement FreeTextAnnotationConfiguration: Applies to: Free Text, Callout ShapeAnnotationConfiguration: Applies to: Square, Circle, Polygon, Area Measurement MarkupAnnotationConfiguration: Applies to: Highlight, Underline, Strikeout, Squiggly StampAnnotationConfiguration: Applies to: Stamp, Image annotations ReductionAnnotationConfigurations: Applies to: Redaction tools NoteAnnotationConfiguration: Applies to: Note annotations ``` -------------------------------- ### Configure AI Assistant in Flutter PDF Configuration Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/ai-assistant.md This Dart code snippet demonstrates how to initialize AIAssistantConfiguration with server details, JWT, and session identifiers. It then integrates this configuration into PdfConfiguration, enabling AI Assistant features for both Android and iOS platforms within a Flutter application. ```dart // Create AI Assistant configuration final aiConfig = AIAssistantConfiguration( serverUrl: 'https://your-ai-assistant-server.com', jwt: 'your-jwt-token', // Generate this from your server sessionId: 'unique-session-id', userId: 'optional-user-id', ); // Add to PDF configuration final pdfConfig = PdfConfiguration( aiAssistantConfiguration: aiConfig, androidEnableAiAssistant: true, iOSLeftBarButtonItems: ['aiAssistantButtonItem'], ); ``` -------------------------------- ### Add PSPDFKit Flutter SDK Dependency Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/README.md Adds the `pspdfkit_flutter` package to your project's `pubspec.yaml` file, making it available for use. ```yaml dependencies: pspdfkit_flutter: any ``` -------------------------------- ### PSPDFKit Flutter: Document Interaction Configuration Options Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/configuration-options.md API documentation for configuration options that control how users interact with documents in PSPDFKit Flutter, such as scrolling direction, page transitions, and text selection. ```APIDOC Document Interaction Options: - scrollDirection: DataType: String PossibleValues: horizontal, vertical iOS: Supported Android: Supported Documentation: Configures the direction of page scrolling in the document view. - pageTransition: DataType: String PossibleValues: scrollPerSpread, scrollContinuous, \`curl\` iOS: Supported Android: Supported Documentation: Configures the page scrolling mode. Note that \`curl\` mode is only available for iOS and will be ignored on Android. - enableTextSelection: DataType: Boolean PossibleValues: true / false iOS: Supported Android: Supported Documentation: Allow / disallow text selection. ``` -------------------------------- ### Include PSPDFKit Web Library in index.html Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/README.md Adds a ` ``` -------------------------------- ### Configure local.properties for Android and Flutter SDK Paths Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/android/README.md This snippet demonstrates how to configure the `local.properties` file in an Android Studio Flutter project. It includes essential paths for the Android SDK, Android NDK, and the Flutter SDK, which are crucial for the project's build process. The `flutter.sdk` property often needs to be added manually after Android Studio creates the file. ```Properties sdk.dir=/path/to/your/android/sdk ndk.dir=/path/to/your/android/sdk/ndk-bundle flutter.sdk=/path/to/your/flutter/sdk ``` -------------------------------- ### Opening Xcode Project for Launch Screen Asset Management Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md To customize launch screen assets for a Flutter iOS project, open the Xcode workspace. This command allows access to manage images via the Assets.xcassets catalog. ```Shell open ios/Runner.xcworkspace ``` -------------------------------- ### PSPDFKit Flutter Annotation and Form Configuration Options Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/configuration-options.md Details various configuration options for PSPDFKit Flutter, including settings for annotation editing and displaying annotation lists across iOS and Android platforms, along with their data types and documentation. ```APIDOC PSPDFKit Flutter Configuration Options: enableAnnotationEditing: Type: Boolean Possible Values: true, false Platforms: iOS: Supported Android: Supported Description: Configuration to enable / disable editing all annotations. androidShowAnnotationListAction: Type: Boolean Possible Values: true, false Platforms: iOS: Not Supported Android: Supported Description: Enables the list of annotations. For iOS, add `outlineButtonItem` to `iOSLeftBarButtonItems` or `iOSRightBarButtonItems` to achieve the same functionality. ``` -------------------------------- ### PSPDFKit Flutter General UI Configuration Options Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/configuration-options.md Defines various general UI configuration options for PSPDFKit in Flutter, including theme resources for Android and bar button items for iOS. These options allow customization of the viewer's appearance and available actions. ```APIDOC androidDarkThemeResource: Type: String Possible Values: Any string Platforms: Android Description: The resource string for the dark theme. androidDefaultThemeResource: Type: String Possible Values: Any string Platforms: Android Description: The resource string for the default theme. iOSLeftBarButtonItems: Type: Array of String Possible Values: closeButtonItem, outlineButtonItem, searchButtonItem, thumbnailsButtonItem, documentEditorButtonItem, printButtonItem, openInButtonItem, emailButtonItem, messageButtonItem, annotationButtonItem, bookmarkButtonItem, brightnessButtonItem, activityButtonItem, settingsButtonItem, readerViewButtonItem Platforms: iOS Description: Set the left bar button items. For Android, set individual options such as \"androidShowOutlineAction\", \"androidShowSearchAction\", etc. to achieve the same functionality. iOSRightBarButtonItems: Type: Array of String Possible Values: closeButtonItem, outlineButtonItem, searchButtonItem, thumbnailsButtonItem, documentEditorButtonItem, printButtonItem, openInButtonItem, emailButtonItem, messageButtonItem, annotationButtonItem, bookmarkButtonItem, brightnessButtonItem, activityButtonItem, settingsButtonItem, readerViewButtonItem Platforms: iOS Description: Set the right bar button items. For Android, set individual options such as \"androidShowOutlineAction\", \"androidShowSearchAction\", etc. to achieve the same functionality. iOSAllowToolbarTitleChange: Type: Boolean Possible Values: true / false Platforms: iOS Description: Allow PSPDFKit to change the title of this view controller. ``` -------------------------------- ### Configure Android build.gradle for PSPDFKit Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/README.md Updates the `android/app/build.gradle` file to set `compileSdkVersion`, `minSdkVersion`, `compileOptions` for Java 17, and `kotlinOptions` for JVM target 17, along with adding `appcompat` dependency, which are necessary for PSPDFKit compatibility. ```gradle android { compileSdkVersion 35 defaultConfig { minSdkVersion 21 } compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { jvmTarget = '17' } } dependencies { implementation 'androidx.appcompat:appcompat:' } ``` -------------------------------- ### Responsive CSS Styles for HTML Invoice Template Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/example/android/app/src/main/assets/html-conversion/invoice.html Defines the core styling for a responsive HTML invoice template, covering layout, table presentation, font styles, and responsive adjustments for various screen sizes. It also includes specific styles for Right-to-Left (RTL) text direction. ```CSS .invoice-box { max-width: 800px; margin: auto; padding: 30px; border: 1px solid #eee; box-shadow: 0 0 10px rgba(0, 0, 0, .15); font-size: 16px; line-height: 24px; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; color: #555; } .invoice-box table { width: 100%; line-height: inherit; text-align: left; } .invoice-box table td { padding: 5px; vertical-align: top; } .invoice-box table tr td:nth-child(2) { text-align: right; } .invoice-box table tr.top table td { padding-bottom: 20px; } .invoice-box table tr.top table td.title { font-size: 45px; line-height: 45px; color: #333; } .invoice-box table tr.information table td { padding-bottom: 40px; } .invoice-box table tr.heading td { background: #eee; border-bottom: 1px solid #ddd; font-weight: bold; } .invoice-box table tr.details td { padding-bottom: 20px; } .invoice-box table tr.item td{ border-bottom: 1px solid #eee; } .invoice-box table tr.item.last td { border-bottom: none; } .invoice-box table tr.total td:nth-child(2) { border-top: 2px solid #eee; font-weight: bold; } @media only screen and (max-width: 600px) { .invoice-box table tr.top table td { width: 100%; display: block; text-align: center; } .invoice-box table tr.information table td { width: 100%; display: block; text-align: center; } } /** RTL **/ .rtl { direction: rtl; font-family: Tahoma, 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; } .rtl table { text-align: right; } .rtl table tr td:nth-child(2) { text-align: left; } ``` -------------------------------- ### PSPDFKit Flutter Thumbnail Display Configuration Options Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/configuration-options.md Specifies configuration options related to the display and behavior of page thumbnails within the PSPDFKit viewer in Flutter. This includes controlling the thumbnail bar mode and actions for displaying thumbnail grids. ```APIDOC showThumbnailBar: Type: String Possible Values: none, default, floating, pinned, scrubberBar, scrollable Platforms: iOS, Android Description: Thumbnail bar mode controls the display of page thumbnails viewing a document. androidShowThumbnailGridAction: Type: Boolean Possible Values: true / false Platforms: Android Description: Displays an action bar icon to show a grid of thumbnail pages. For iOS, add \"thumbnailsButtonItem\" to \"iOSLeftBarButtonItems\" or \"iOSRightBarButtonItems\" to achieve the same functionality. ``` -------------------------------- ### Configure Annotation Presets in Flutter (Dart) Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/annotation-preset-configuration-guide.md This snippet demonstrates how to customize the default properties for various annotation tools, such as ink pens and highlights, using `setAnnotationConfigurations` on the `PspdfkitWidgetController`. It requires the controller to be initialized and should be called within the `onPdfDocumentLoaded` callback. Inputs include a map where keys are `AnnotationTool` enums and values are specific configuration objects like `InkAnnotationConfiguration` or `MarkupAnnotationConfiguration`. The output is the modification of default annotation behavior. ```Dart // Call within onPdfDocumentLoaded _controller?.setAnnotationConfigurations({ AnnotationTool.inkPen: InkAnnotationConfiguration( color: Colors.purple, thickness: 2.0, ), AnnotationTool.highlight: MarkupAnnotationConfiguration( color: Colors.yellow.withOpacity(0.4), ), }); ``` -------------------------------- ### Add PDF Assets to pubspec.yaml Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/README.md Registers the `PDFs/` directory as an asset folder in `pubspec.yaml`, making its contents accessible within the Flutter application. ```yaml flutter: assets: - PDFs/ ``` -------------------------------- ### Update Android MainActivity to FlutterAppCompatActivity Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/README.md Changes the base class of `MainActivity` in `android/app/src/main/kotlin/.../MainActivity.kt` to `FlutterAppCompatActivity`, which is required for PSPDFKit integration on Android. ```kotlin import io.flutter.embedding.android.FlutterAppCompatActivity class MainActivity: FlutterAppCompatActivity() { } ``` -------------------------------- ### Add AI Assistant Button to Flutter Web Toolbar Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/documentation/ai-assistant.md This Dart code snippet illustrates how to customize the toolbar for the Flutter Web platform to include the AI Assistant button. By adding PspdfkitWebToolbarItemType.aiAssistant to toolbarItems within PdfWebConfiguration, users can access the AI chat feature directly from the web viewer. ```dart webConfiguration: PdfWebConfiguration( toolbarItems: [ PspdfkitWebToolbarItem(type: PspdfkitWebToolbarItemType.aiAssistant), ...Pspdfkit.defaultWebToolbarItems, ], ), ``` -------------------------------- ### Update Android Theme for PSPDFKit Source: https://github.com/pspdfkit/pspdfkit-flutter/blob/master/README.md Modifies `android/app/src/main/res/values/styles.xml` to change the parent theme from `Theme.AppCompat.Light.NoActionBar` to `PSPDFKit.Theme.Default`, ensuring proper styling for the SDK. ```diff -