No Description

yangliuhua 77cf8f7a34 ComPDFKit(flutter) - 1. readme.md的iOS的修改 1 year ago
android 9ea911ac30 ComPDFKit(flutter) - 1.使用工程中的示例pdf文档 1 year ago
example 77cf8f7a34 ComPDFKit(flutter) - 1. readme.md的iOS的修改 1 year ago
ios 77cf8f7a34 ComPDFKit(flutter) - 1. readme.md的iOS的修改 1 year ago
lib f2db11aa9a ComPDFKit(flutter) - 1.新增注释 1 year ago
screenshots 77cf8f7a34 ComPDFKit(flutter) - 1. readme.md的iOS的修改 1 year ago
.gitignore 318d483b0b ComPDFKit(flutter) - 插件化工程创建 1 year ago
.metadata 318d483b0b ComPDFKit(flutter) - 插件化工程创建 1 year ago
CHANGELOG.md f2db11aa9a ComPDFKit(flutter) - 1.新增注释 1 year ago
LICENSE b7134163e1 ComPDFKit(flutter) - 完成CPDFReaderView显示 1 year ago
README.md 77cf8f7a34 ComPDFKit(flutter) - 1. readme.md的iOS的修改 1 year ago
analysis_options.yaml 318d483b0b ComPDFKit(flutter) - 插件化工程创建 1 year ago
pubspec.lock e04e12fb0a ComPDFKit(flutter) - 1.优化部分代码内容 1 year ago
pubspec.yaml f2db11aa9a ComPDFKit(flutter) - 1.新增注释 1 year ago

README.md

ComPDFKit SDK for Flutter Guides

1 Overview

ComPDFKit PDF SDK for Flutter is a robust PDF library for developers who need to develop applications on iOS& Android,This library requires a valid license of ComPDFKit. Licenses are per platform.

More information can be found at https://www.compdf.com/

1.1 Key Features

Viewer component offers:

  • Standard page display modes, including Scrolling, Double Page, Crop Mode, and Cover Mode.
  • Navigation with thumbnails, outlines, and bookmarks.
  • Text search & selection.
  • Zoom in and out & Fit-page.
  • Switch between different themes, including Dark Mode, Sepia Mode, Reseda Mode, and Custom Color Mode.
  • Text reflow.

Annotations component offers:

  • Create, edit, and remove annotations, including Note, Link, Free Text, Line, Square, Circle, Highlight, Underline, Squiggly, Strikeout, Stamp, Ink, and Sound.
  • Support for annotation appearances.
  • Import and export annotations to/from XFDF.
  • Support for annotation flattening.
  • Predefine annotations.

Forms component offers:

  • Create, edit and remove form fields, including Push Button, Check Box, Radio Button, Text Field, Combo Box, List Box, and Signature.
  • Fill PDF Forms.
  • Support for PDF form flattening.

Document Editor component offers:

  • PDF manipulation, including Split pages, Extract pages, and Merge pages.
  • Page edit, including Delete pages, Insert pages, Crop pages, Move pages, Rotate pages, Replace pages, and Exchange pages.
  • Document information setting.
  • Extract images.

Content Editor component offers:

  • Programmatically add and remove text in PDFs and make it possible to edit PDFs like Word. Allow selecting text to copy, resize, change colors, text alignment, and the position of text boxes.
  • Undo or redo any change.

1.2 License

ComPDFKit PDF SDK is a commercial SDK, which requires a license to grant developer permission to release their apps. Each license is only valid for one bundle ID or applicationId in development mode. Other flexible licensing options are also supported, please contact our marketing team to know more. However, any documents, sample code, or source code distribution from the released package of ComPDFKit to any third party is prohibited.

2 Get Started

It's easy to embed ComPDFKit into React Native applications with a few lines of code. Let's take a few minutes to get started.

The following sections describe the optimal systems and environments to support, as well as quick integration steps

2.1 Requirements

  • Android

    • A minSdkVersion of 19 or higher.

    • A compileSdkVersion of 30 or higher.

    • A targetSdkVersion of 30 or higher.

    • Android ABI(s): x86, x86_64, armeabi-v7a, arm64-v8a.

  • IOS

    • The iOS 10.0 or higher.

    • The Xcode 12.0 or newer for Objective-C or Swift.

2.2 Integration into a New Flutter App

2.2.1 Android

  1. Create a Flutter project called example with the flutter CLI:
flutter create --org com.compdfkit.flutter example
  1. In the terminal app, change the location of the current working directory to your project:
cd example
  1. open example/android/app/src/main/AndroidManifest.xml , addComPDFKit License and Storage Permission
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.compdfkit.flutter.example">
    
    <!-- Required to read and write documents from device storage -->
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

    <application
        ...>
        ...
        <!-- Please replace with the ComPDFKit SDK license provided to you -->
+        <meta-data
+            android:name="compdfkit_key"
+            android:value="{your ComPDFKit key}" />
+        <meta-data
+            android:name="compdfkit_secret"
+            android:value="{your ComPDFKit secret}" />
				...
    </application>
</manifest>
  1. Open the app’s Gradle build file, android/app/build.gradle:
open android/app/build.gradle
  1. Modify the minimum SDK version, All this is done inside the android section:
 android {
     defaultConfig {
-        minSdkVersion flutter.minSdkVersion
+        minSdkVersion 21
         ...
     }
 }
  1. Add the ComPDFKit dependency in pubspec.yaml
 dependencies:
   flutter:
     sdk: flutter
+  compdfkit_flutter: ^1.0.0
  1. From the terminal app, run the following command to get all the packages:
flutter pub get
  1. Open lib/main.dart and replace the entire content with the following code. And fill in the license provided to you in the ComPDFKit.init method, this simple example will load a PDF document from the local device file system.
import 'dart:io';

import 'package:compdfkit_flutter/compdfkit.dart';

import 'package:flutter/material.dart';

const String DOCUMENT_PATH = 'pdfs/PDF_Document.pdf';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    _init();
  }

  void _init() async {
    // Please replace with the ComPDFKit SDK license provided to you
    ComPDFKit.init('your ComPDFKit key', 'your ComPDFKit secret');
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SafeArea(
          child: Center(
            child: ElevatedButton(
              onPressed: () async {
                showDocument(context);
              },
              child: const Text(
                'Open Document',
                style: TextStyle(color: Colors.white),
              )),
          ))),
    );
  }

  void showDocument(BuildContext context) async {
    final bytes = await DefaultAssetBundle.of(context).load(DOCUMENT_PATH);
    final list = bytes.buffer.asUint8List();

    final tempDir = await ComPDFKit.getTemporaryDirectory();
    final tempDocumentPath = '${tempDir.path}/$DOCUMENT_PATH';

    final file = await File(tempDocumentPath).create(recursive: true);
    file.writeAsBytesSync(list);
    ComPDFKit.openDocument(tempDocumentPath);
  }
}
  1. Add the PDF documents you want to display in the project
  • create a pdf directory
  mkdir pdfs
  • Copy your example document into the newly created pdfs directory and name it PDF_Document.pdf
  1. Specify the assets directory in pubspec.yaml
 flutter:
+  assets:
+    - pdfs/
  1. Start your Android emulator, or connect a device.

  2. Run the app with:

flutter run

2.2.2 iOS

  1. Create a Flutter project called example with the flutter CLI:
flutter create --org com.compdfkit.flutter example
  1. In the terminal app, change the location of the current working directory to your project:
cd example
  1. Add the ComPDFKit dependency in pubspec.yaml
 dependencies:
   flutter:
     sdk: flutter
+  compdfkit_flutter: ^1.0.0
  1. From the terminal app, run the following command to get all the packages:
flutter pub get
  1. Open your project’s Podfile in a text editor:
open ios/Podfile
  1. Update the platform to iOS 10 and add the PSPDFKit Podspec:
- platform :ios, '9.0'
+ platform :ios, '10.0' 
 ...
 target 'Runner' do
   use_frameworks!
   use_modular_headers!`

   flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
+  pod 'ComPDFKit', podspec:'http://test-pdf-pro.kdan.cn:3026/download/compdfkit_flutter.podspec'
 end
  1. Open lib/main.dart and replace the entire content with the following code. And fill in the license provided to you in the ComPDFKit.init method, this simple example will load a PDF document from the local device file system.
import 'dart:io';

import 'package:compdfkit_flutter/compdfkit.dart';

import 'package:flutter/material.dart';

const String DOCUMENT_PATH = 'pdfs/PDF_Document.pdf';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    _init();
  }

  void _init() async {
		// Please replace with the ComPDFKit SDK license provided to you
    ComPDFKit.init('your ComPDFKit key', 'your ComPDFKit secret');
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SafeArea(
          child: Center(
            child: ElevatedButton(
              onPressed: () async {
                showDocument(context);
              },
              child: const Text(
                'Open Document',
                style: TextStyle(color: Colors.white),
              )),
          ))),
    );
  }

  void showDocument(BuildContext context) async {
    final bytes = await DefaultAssetBundle.of(context).load(DOCUMENT_PATH);
    final list = bytes.buffer.asUint8List();

    final tempDir = await ComPDFKit.getTemporaryDirectory();
    final tempDocumentPath = '${tempDir.path}/$DOCUMENT_PATH';

    final file = await File(tempDocumentPath).create(recursive: true);
    file.writeAsBytesSync(list);
    ComPDFKit.openDocument(tempDocumentPath);
  }
}
  1. Add the PDF documents you want to display in the project
  • create a pdf directory
  mkdir pdfs
  • Copy your example document into the newly created pdfs directory and name it PDF_Document.pdf
  1. Specify the assets directory in pubspec.yaml
 flutter:
+  assets:
+    - pdfs/
  1. To protect user privacy,

    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.

    <key>NSCameraUsageDescription</key>
    <string>Your consent is required before you could access the function.</string>
        
    <key>NSMicrophoneUsageDescription</key>
    <string>Your consent is required before you could access the function.</string>
        
    <key>NSPhotoLibraryAddUsageDescription</key>
    <string>Your consent is required before you could access the function.</string>
        
    <key>NSPhotoLibraryUsageDescription</key>
    <string>Your consent is required before you could access the function.</string>
    
  2. Start your Android emulator, or connect a device.

flutter emulators --launch apple_ios_simulator
  1. Run the app with:
flutter run

4 Support

4.1 Reporting Problems

Thank you for your interest in ComPDFKit PDF SDK, the only easy-to-use but powerful development solution to integrate high quality PDF rendering capabilities to your applications. If you encounter any technical questions or bug issues when using ComPDFKit PDF SDK for Android, please submit the problem report to the ComPDFKit team. More information as follows would help us to solve your problem:

  • ComPDFKit PDF SDK product and version.
  • Your operating system and IDE version.
  • Detailed descriptions of the problem.
  • Any other related information, such as an error screenshot.

4.2 Contact Information

Home Link:

https://www.compdf.com

Support & General Contact:

Email: support@compdf.com

Thanks, The ComPDFKit Team