{"id":19756858,"url":"https://github.com/compdfkit/compdfkit-pdf-sdk-flutter","last_synced_at":"2025-09-08T18:37:39.124Z","repository":{"id":218628889,"uuid":"732848556","full_name":"ComPDFKit/compdfkit-pdf-sdk-flutter","owner":"ComPDFKit","description":"ComPDFKit for Flutter is a comprehensive SDK that allows you to quickly add PDF functionality to Android and iOS Flutter applications.","archived":false,"fork":false,"pushed_at":"2024-10-17T07:09:24.000Z","size":9907,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-10-19T09:47:59.177Z","etag":null,"topics":["android","compdfkit","cross-platform","flutter","flutter-plugin","ios","pdf","pdf-document","pdf-editor","pdf-viewer"],"latest_commit_sha":null,"homepage":"https://www.compdf.com/flutter","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ComPDFKit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-18T01:56:30.000Z","updated_at":"2024-10-17T07:09:28.000Z","dependencies_parsed_at":"2024-01-23T03:14:20.117Z","dependency_job_id":"4aa6f999-5c3f-4816-b73d-e8eb0833208e","html_url":"https://github.com/ComPDFKit/compdfkit-pdf-sdk-flutter","commit_stats":null,"previous_names":["compdfkit/compdfkit-pdf-sdk-flutter"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ComPDFKit%2Fcompdfkit-pdf-sdk-flutter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ComPDFKit%2Fcompdfkit-pdf-sdk-flutter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ComPDFKit%2Fcompdfkit-pdf-sdk-flutter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ComPDFKit%2Fcompdfkit-pdf-sdk-flutter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ComPDFKit","download_url":"https://codeload.github.com/ComPDFKit/compdfkit-pdf-sdk-flutter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224207933,"owners_count":17273679,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","compdfkit","cross-platform","flutter","flutter-plugin","ios","pdf","pdf-document","pdf-editor","pdf-viewer"],"created_at":"2024-11-12T03:17:13.647Z","updated_at":"2025-09-08T18:37:39.104Z","avatar_url":"https://github.com/ComPDFKit.png","language":"Dart","readme":"# ComPDFKit Flutter PDF Library\n\n## About\n\n[ComPDFKit for Flutter](https://www.compdf.com/guides/pdf-sdk/flutter/overview), developed and managed by [ComPDF](https://www.compdf.com/), is a powerful PDF library that enables developers to seamlessly integrate PDF viewing, a nnotation, editing, form filling, redaction, and signing into any iOS or Android application. It is available at [pub.dev](https://pub.dev/packages/compdfkit_flutter) and [GitHub.](https://github.com/ComPDFKit/compdfkit-pdf-sdk-flutter)\n\nFor more information, please check our [developer guides](https://www.compdf.com/guides/pdf-sdk/flutter/overview).\n\n## Contents\n\n* [Requirements](#requirements)\n* [Steps to Build the Flutter PDF Editor by Integrating ComPDFKit PDF SDK](#steps-to-build-the-flutter-pdf-editor-by-integrating-compdfkit-pdf-sdk)\n* [Example App](#example-app)\n* [Support](#support)\n\n## Requirements\n\nBefore starting, please make sure that you have already met the following prerequisites:\n\n### Get ComPDFKit License Key\n\nComPDF offers two types of license keys: a free 30-day trial license and a commercial license.\n\n- **Trial License** – You can request a [30-day free trial](https://www.compdf.com/pricing) online.  \n- **Commercial License** – For advanced features, custom requirements, or quote inquiries, feel free to [contact our sales](https://www.compdf.com/contact-sales).  \n\nFor the Flutter PDF SDK, the commercial license must be bound to your application’s ApplicationId and iOS BundleId.\n\n\n### System Requirements\n\n**Android**\n\nPlease install the following required packages:\n\n* The [latest stable version of Flutter](https://docs.flutter.dev/get-started/install)\n* The [latest stable version of Android Studio](https://developer.android.com/studio)\n* The [Android NDK](https://developer.android.com/studio/projects/install-ndk)\n* An [Android Virtual Device](https://developer.android.com/studio/run/managing-avds.html)\n\nOperating Environment Requirements:\n\n* A minSdkVersion of `21` or higher.\n* A `compileSdkVersion` of `34` or higher.\n* A `targetSdkVersion` of `34` or higher.\n* Android ABI(s): x86, x86_64, armeabi-v7a, arm64-v8a.\n\n**iOS**\n\nPlease install the following required packages:\n\n* The [latest stable version of Flutter](https://docs.flutter.dev/get-started/install)\n* The [latest stable version of Xcode](https://apps.apple.com/us/app/xcode/id497799835?mt=12)\n* The [latest stable version of CocoaPods](https://github.com/CocoaPods/CocoaPods/releases). Follow the [CocoaPods installation guide](https://guides.cocoapods.org/using/getting-started.html#installation) to install it.\n\nOperating Environment Requirements:\n\n* The iOS 12.0 or higher.\n* The Xcode 12.0 or newer for Objective-C or Swift.\n\n## How to Build the Flutter PDF Editor by Integrating ComPDFKit PDF SDK \n\n[![image](https://img.youtube.com/vi/I0Rz11iVAbE/maxresdefault.jpg)](https://youtu.be/I0Rz11iVAbE)\n\n### Create a new project\n\n#### Android\n\n1. Create a Flutter project called `example` with the `flutter` CLI:\n\n```bash\nflutter create --org com.compdfkit.flutter example\n```\n\n2. In the terminal app, change the location of the current working directory to your project:\n\n```bash\ncd example\n```\n\n3. open  `example/android/app/src/main/AndroidManifest.xml` , add `Internet Permission` and `Storage Permission`:\n\n```diff\n\u003cmanifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.compdfkit.flutter.example\"\u003e\n\n+    \u003cuses-permission android:name=\"android.permission.INTERNET\"/\u003e\n  \n    \u003c!-- Required to read and write documents from device storage --\u003e\n+    \u003cuses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/\u003e\n+    \u003cuses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/\u003e\n  \n    \u003c!-- Optional settings --\u003e\n+    \u003cuses-permission android:name=\"android.permission.MANAGE_EXTERNAL_STORAGE\"/\u003e\n\n\n    \u003capplication\n+      android:requestLegacyExternalStorage=\"true\"\u003e\n  \n    \u003c/application\u003e   \n\u003c/manifest\u003e\n```\n\n4. Open the app's Gradle build file, `android/app/build.gradle`:\n\n```bash\nopen android/app/build.gradle\n```\n\n5. Modify the minimum SDK version, All this is done inside the `android` section:\n\n```diff\n android {\n     defaultConfig {\n-        minSdkVersion flutter.minSdkVersion\n+        minSdkVersion 21\n         ...\n     }\n }\n```\n\n6. Open the project’s main activity class, `android/app/src/main/java/com/example/compdfkit/flutter/example/MainActivity.java`, Change the base `Activity` to extend `FlutterFragmentActivity`:\n\n```diff\n- import io.flutter.embedding.android.FlutterActivity;\n+ import io.flutter.embedding.android.FlutterFragmentActivity;\n\n- public class MainActivity extends FlutterActivity {\n+ public class MainActivity extends FlutterFragmentActivity {\n}\n```\n\nAlternatively you can update the `AndroidManifest.xml` file to use `FlutterFragmentActivity` as the launcher activity:\n\n```diff\n\u003cactivity\n-     android:name=\".MainActivity\" \n+     android:name=\"io.flutter.embedding.android.FlutterFragmentActivity\"\n      android:exported=\"true\"\n      android:hardwareAccelerated=\"true\"\n      android:launchMode=\"singleTop\"\n      android:theme=\"@style/LaunchTheme\"\n      android:windowSoftInputMode=\"adjustPan\"\u003e\n```\n\n\u003e **Note:** `FlutterFragmentActivity` is not an official part of the Flutter SDK. If you need to use `CPDFReaderWidget` in ComPDFKit for Flutter, you need to use this part of the code. You can skip this step if you don't need to use.\n\n7. Add the ComPDFKit dependency in `pubspec.yaml`\n\n```diff\n dependencies:\n   flutter:\n     sdk: flutter\n+  compdfkit_flutter: ^2.4.6\n```\n\n8. Add the PDF documents you want to display in the project\n\n* create a `pdf` directory\n\n  ```bash\n  mkdir pdfs\n  ```\n* Copy your example document into the newly created `pdfs` directory and name it `PDF_Document.pdf`\n\n9. Specify the `assets` directory in `pubspec.yaml`\n\n```diff\n flutter:\n+  assets:\n+    - pdfs/\n```\n\n10. From the terminal app, run the following command to get all the packages:\n\n```bash\nflutter pub get\n```\n\n#### iOS\n\n1. Create a Flutter project called `example` with the `flutter` CLI:\n\n```bash\nflutter create --org com.compdfkit.flutter example\n```\n\n2. In the terminal app, change the location of the current working directory to your project:\n\n```bash\ncd example\n```\n\n3. Add the ComPDFKit dependency in `pubspec.yaml`\n\n```diff\n dependencies:\n   flutter:\n     sdk: flutter\n+  compdfkit_flutter: ^2.4.6\n```\n\n4. Open your project's Podfile in a text editor:\n\n```bash\nopen ios/Podfile\n```\n\n**Note:** If SSL network requests fail to download the `ComPDFKit` library when you run `pod install`, you can see the processing method in [Troubleshooting](#Troubleshooting)).\n\n6. Update the platform to iOS 12 and add the ComPDFKit Podspec:\n\n```diff\n\n- platform :ios, '9.0'\n+ platform :ios, '12.0' \n ...\n target 'Runner' do\n   use_frameworks!\n   use_modular_headers!`\n\n   flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))\n+  pod \"ComPDFKit\", podspec:'https://file.compdf.com/cocoapods/ios/compdfkit_pdf_sdk/2.4.6/ComPDFKit.podspec'\n+  pod \"ComPDFKit_Tools\", podspec:'https://file.compdf.com/cocoapods/ios/compdfkit_pdf_sdk/2.4.6/ComPDFKit_Tools.podspec'\n end\n```\n\n7. Go to the `example/ios` folder and run the `pod install` command:\n\n```bash\npod install\n```\n\n8. Add the PDF documents you want to display in the project\n\n* create a `pdf` directory\n\n  ```bash\n  mkdir pdfs\n  ```\n* Copy your example document into the newly created `pdfs` directory and name it `PDF_Document.pdf`\n\n9. Specify the `assets` directory in `pubspec.yaml`\n\n```diff\n flutter:\n+  assets:\n+    - pdfs/\n```\n\n10. To protect user privacy, before accessing the sensitive privacy data, you need to find the \"***Info\\***\" configuration in your iOS 10.0 or higher iOS project and configure the relevant privacy terms as shown in the following picture.\n\n![](./screenshots/1-8.png)\n\n```objective-c\n\u003ckey\u003eNSCameraUsageDescription\u003c/key\u003e\n\u003cstring\u003eYour consent is required before you could access the function.\u003c/string\u003e\n\n\u003ckey\u003eNSMicrophoneUsageDescription\u003c/key\u003e\n\u003cstring\u003eYour consent is required before you could access the function.\u003c/string\u003e\n\n\u003ckey\u003eNSPhotoLibraryAddUsageDescription\u003c/key\u003e\n\u003cstring\u003eYour consent is required before you could access the function.\u003c/string\u003e\n\n\u003ckey\u003eNSPhotoLibraryUsageDescription\u003c/key\u003e\n\u003cstring\u003eYour consent is required before you could access the function.\u003c/string\u003e\n  \n\u003ckey\u003eNSAppTransportSecurity\u003c/key\u003e\n\t\u003cdict\u003e\n\t\t\u003ckey\u003eNSAllowsArbitraryLoads\u003c/key\u003e\n\t\t\u003ctrue/\u003e\n\t\u003c/dict\u003e\n```\n\n11. From the terminal app, run the following command to get all the packages:\n\n```bash\nflutter pub get\n```\n\n\n\n### Apply the License Key\n\nComPDFKit PDF SDK currently supports two authentication methods to verify license keys: online authentication and offline authentication.\n\nLearn about:\n\n* [What is the authentication mechanism of ComPDFKit's license?](https://www.compdf.com/faq/authentication-mechanism-of-compdfkit-license)\n\n* [What are the differences between Online Authentication and Offline Authentication?](https://www.compdf.com/faq/the-differences-between-online-authentication-and-offline-authentication)\n\nAccurately obtaining the license key is crucial for the application of the license.\n\n1. In the email you received, locate the `XML` file containing the license key.\n2. Copy the License.xml file into the **assets directory** of your Flutter project.\n\n\u003cimg src=\"./screenshots/guides_flutter_2.3_1.png\" alt=\"guides_flutter_2.3_1\" style=\"zoom: 50%;\" /\u003e\n\n3. Open the pubspec.yaml file of your project and configure the flutter: section to enable the assets directory.\n\n\u003cimg src=\"./screenshots/guides_flutter_2.3_2.png\" alt=\"guides_flutter_2.3_2\" style=\"zoom: 50%;\" /\u003e\n\n4. Initialize the SDK:\n\n```dart\n// Include the license in Flutter assets and copy to device storage\n// Add `license_key_flutter.xml` to your Flutter project’s assets directory;\nFile licenseFile = await CPDFFileUtil.extractAsset(context, 'assets/license_key_flutter.xml');\nComPDFKit.initWithPath(licenseFile.path);\n```\n\n**Alternative methods (optional)**\n\n```dart\n// Android\n// Copy the license_key_flutter.xml file into the `android/app/src/main/assets` directory of your Android project:\nComPDFKit.initWithPath('assets://license_key_flutter.xml');\n\n// iOS\n// Copy the license_key_flutter.xml file into your iOS project directory (or a readable location):\nComPDFKit.initWithPath('license_key_flutter.xml');\n```\n\n\n\n### Run Project\n\nThere are 2 different ways to use ComPDFKit Flutter API:\n\n* Present a document via a plugin.\n* Show a ComPDFKit document view via a Widget.\n\n#### Usage Plugin\n\nOpen `lib/main.dart`,replace the entire file with the following:\n\n```dart\nimport 'dart:io';\n\nimport 'package:compdfkit_flutter/compdfkit.dart';\nimport 'package:compdfkit_flutter/configuration/cpdf_configuration.dart';\nimport 'package:compdfkit_flutter/util/cpdf_file_util.dart';\nimport 'package:flutter/material.dart';\n\nconst String _documentPath = 'pdfs/PDF_Document.pdf';\n\nvoid main() {\n  runApp(const MyApp());\n}\n\nclass MyApp extends StatefulWidget {\n  const MyApp({super.key});\n\n  @override\n  State\u003cMyApp\u003e createState() =\u003e _MyAppState();\n}\n\nclass _MyAppState extends State\u003cMyApp\u003e {\n  @override\n  void initState() {\n    super.initState();\n    _init();\n  }\n\n  void _init() async {\n    File licenseFile = await CPDFFileUtil.extractAsset(context, 'assets/license_key_flutter.xml');\n    ComPDFKit.initWithPath(licenseFile.path);\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    return MaterialApp(\n      home: Scaffold(\n        body: SafeArea(\n          child: Center(\n            child: ElevatedButton(\n              onPressed: () async {\n                showDocument(context);\n              },\n              child: const Text(\n                'Open Document',\n              )),\n          ))),\n    );\n  }\n\n  void showDocument(BuildContext context) async {\n    var pdfFile = await CPDFFileUtil.extractAsset(_documentPath);\n    var configuration = CPDFConfiguration();\n    // Present a document via a plugin.\n    ComPDFKit.openDocument(pdfFile.path,\n                           password: '', configuration: configuration);\n  }\n}\n```\n\n#### Usage Widget\n\nOpen `lib/main.dart`,replace the entire file with the following:\n\n```dart\nimport 'dart:io';\n\nimport 'package:compdfkit_flutter/compdfkit.dart';\nimport 'package:compdfkit_flutter/configuration/cpdf_configuration.dart';\nimport 'package:compdfkit_flutter/widgets/cpdf_reader_widget.dart';\nimport 'package:compdfkit_flutter/util/cpdf_file_util.dart';\nimport 'package:flutter/material.dart';\n\nconst String _documentPath = 'pdfs/PDF_Document.pdf';\n\nvoid main() {\n  runApp(const MyApp());\n}\n\nclass MyApp extends StatefulWidget {\n  const MyApp({super.key});\n\n  @override\n  State\u003cMyApp\u003e createState() =\u003e _MyAppState();\n}\n\nclass _MyAppState extends State\u003cMyApp\u003e {\n  String? _document;\n\n  @override\n  void initState() {\n    super.initState();\n    _init();\n    _getDocumentPath().then((value) {\n      setState(() {\n        _document = value;\n      });\n    });\n  }\n\n  void _init() async {\n    /// Please replace it with your ComPDFKit license\n    File licenseFile = await CPDFFileUtil.extractAsset(context, 'assets/license_key_flutter.xml');\n    ComPDFKit.initWithPath(licenseFile.path);\n  }\n\n  Future\u003cString\u003e _getDocumentPath() async {\n    var file = await CPDFFileUtil.extractAsset('pdfs/PDF_Document.pdf');\n    return file.path;\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    return MaterialApp(\n      home: Scaffold(\n        resizeToAvoidBottomInset: false,\n        appBar: AppBar(\n          title: const Text('CPDFReaderWidget Example'),\n        ),\n        body: _document == null\n        ? Container()\n        : CPDFReaderWidget(\n          document: _document!,\n          configuration: CPDFConfiguration(),\n          onCreated: (_create) =\u003e {})));\n  }\n}\n```\n\nStart your Android emulator, or connect a device, Run the app with:\n\n```bash\nflutter run\n```\n\n### Example APP\n\nTo see [ComPDFKit for Flutter](https://www.compdf.com/contact-sales) in action, check out our [Flutter example app](example/) and [API reference](https://pub.dev/documentation/compdfkit_flutter/latest/compdfkit/compdfkit-library.html)\n\nShowing a PDF document inside your Flutter app is as simple as this:\n\n```dart\n/// First. Please replace it with your ComPDFKit license\n\n// Include the license in Flutter assets and copy to device storage\n// Add `license_key_flutter.xml` to your Flutter project’s assets directory;\nFile licenseFile = await CPDFFileUtil.extractAsset('assets/license_key_flutter.xml');\nComPDFKit.initWithPath(licenseFile.path);\n\n/// open pdf document\nComPDFKit.openDocument(tempDocumentPath, password: '', configuration:  CPDFConfiguration());\n\n/// Here’s how you can open a PDF document using CPDFReaderWidget:\nScaffold(\n  resizeToAvoidBottomInset: false,\n  appBar: AppBar(title: const Text('CPDFReaderWidget Example'),),\n  body: CPDFReaderWidget(\n    document: widget.documentPath,\n    configuration: CPDFConfiguration()\n  ));\n```\n\n## Support\n\n[ComPDF](https://www.compdf.com/) has a professional R\u0026D team that produces comprehensive technical documentation and guides to help developers. Also, you can get an immediate response when reporting your problems to our support team.\n\n- For detailed information, please visit our [Guides](https://www.compdf.com/guides/pdf-sdk/flutter/overview) page.\n- Stay updated with the latest improvements through our [Changelog](https://www.compdf.com/pdf-sdk/changelog-flutter).\n- For technical assistance, please reach out to our [Technical Support](https://www.compdf.com/support).\n- To get more details and an accurate quote, please [contact our Sales Team](https://compdf.com/contact-us).\n\nThanks for reading,\nThe [ComPDF](https://www.compdf.com/) Team\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompdfkit%2Fcompdfkit-pdf-sdk-flutter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcompdfkit%2Fcompdfkit-pdf-sdk-flutter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompdfkit%2Fcompdfkit-pdf-sdk-flutter/lists"}