|
@@ -122,7 +122,7 @@ flutter create --org com.compdfkit.flutter example
|
|
|
cd example
|
|
|
```
|
|
|
|
|
|
-3. open `example/android/app/src/main/AndroidManifest.xml` , add`ComPDFKit License` and `Storage Permission`:
|
|
|
+3. open `example/android/app/src/main/AndroidManifest.xml` , add `Storage Permission`:
|
|
|
|
|
|
```diff
|
|
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
@@ -132,17 +132,6 @@ cd example
|
|
|
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
|
|
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
|
|
|
|
|
- <application
|
|
|
- ...>
|
|
|
- ...
|
|
|
- <!-- Please replace it with your ComPDFKit license -->
|
|
|
-+ <meta-data
|
|
|
-+ android:name="compdfkit_key"
|
|
|
-+ android:value="{your license key}" />
|
|
|
-+ <meta-data
|
|
|
-+ android:name="compdfkit_secret"
|
|
|
-+ android:value="{your license secret}" />
|
|
|
- ...
|
|
|
</application>
|
|
|
</manifest>
|
|
|
```
|
|
@@ -171,7 +160,7 @@ open android/app/build.gradle
|
|
|
dependencies:
|
|
|
flutter:
|
|
|
sdk: flutter
|
|
|
-+ compdfkit_flutter: ^1.0.0
|
|
|
++ compdfkit_flutter: ^1.11.0
|
|
|
```
|
|
|
|
|
|
7. From the terminal app, run the following command to get all the packages:
|
|
@@ -186,6 +175,7 @@ flutter pub get
|
|
|
import 'dart:io';
|
|
|
|
|
|
import 'package:compdfkit_flutter/compdfkit.dart';
|
|
|
+import 'package:compdfkit_flutter/cpdf_configuration.dart';
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
@@ -210,38 +200,67 @@ class _MyAppState extends State<MyApp> {
|
|
|
}
|
|
|
|
|
|
void _init() async {
|
|
|
- // Please replace it with your ComPDFKit license
|
|
|
- ComPDFKit.init('your license key', 'your license secret');
|
|
|
+ ComPDFKit.init('your compdfkit key');
|
|
|
}
|
|
|
|
|
|
@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),
|
|
|
- )),
|
|
|
- ))),
|
|
|
+ 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';
|
|
|
+ var pdfsDir = Directory('${tempDir.path}/pdfs');
|
|
|
+ pdfsDir.createSync(recursive: true);
|
|
|
|
|
|
- final file = await File(tempDocumentPath).create(recursive: true);
|
|
|
- file.writeAsBytesSync(list);
|
|
|
- ComPDFKit.openDocument(tempDocumentPath);
|
|
|
+ final tempDocumentPath = '${tempDir.path}/$DOCUMENT_PATH';
|
|
|
+ final file = File(tempDocumentPath);
|
|
|
+ if (!file.existsSync()) {
|
|
|
+ file.create(recursive: true);
|
|
|
+ file.writeAsBytesSync(list);
|
|
|
+ }
|
|
|
+ var configuration = CPDFConfiguration();
|
|
|
+ // How to disable functionality:
|
|
|
+ // setting the default display mode when opening
|
|
|
+ // configuration.modeConfig = const ModeConfig(initialViewMode: CPreviewMode.annotations);
|
|
|
+ // top toolbar configuration:
|
|
|
+ // android:
|
|
|
+ // configuration.toolbarConfig = const ToolbarConfig(androidAvailableActions: [
|
|
|
+ // ToolbarAction.thumbnail, ToolbarAction.bota,
|
|
|
+ // ToolbarAction.search, ToolbarAction.menu
|
|
|
+ // ],
|
|
|
+ // availableMenus: [
|
|
|
+ // ToolbarMenuAction.viewSettings, ToolbarMenuAction.documentInfo, ToolbarMenuAction.security,
|
|
|
+ // ]);
|
|
|
+ // iOS:
|
|
|
+ // configuration.toolbarConfig = const ToolbarConfig(iosLeftBarAvailableActions: [
|
|
|
+ // ToolbarAction.back, ToolbarAction.thumbnail
|
|
|
+ // ],
|
|
|
+ // iosRightBarAvailableActions: [
|
|
|
+ // ToolbarAction.bota, ToolbarAction.search, ToolbarAction.menu
|
|
|
+ // ],
|
|
|
+ // availableMenus: [
|
|
|
+ // ToolbarMenuAction.viewSettings, ToolbarMenuAction.documentInfo, ToolbarMenuAction.security,
|
|
|
+ // ]);
|
|
|
+ // readerview configuration
|
|
|
+ // configuration.readerViewConfig = const ReaderViewConfig(linkHighlight: true, formFieldHighlight: true);
|
|
|
+ ComPDFKit.openDocument(tempDocumentPath,
|
|
|
+ password: '', configuration: configuration);
|
|
|
}
|
|
|
}
|
|
|
```
|
|
@@ -292,7 +311,7 @@ cd example
|
|
|
dependencies:
|
|
|
flutter:
|
|
|
sdk: flutter
|
|
|
-+ compdfkit_flutter: ^1.0.0
|
|
|
++ compdfkit_flutter: ^1.11.0
|
|
|
```
|
|
|
|
|
|
7. From the terminal app, run the following command to get all the packages:
|
|
@@ -307,7 +326,7 @@ flutter pub get
|
|
|
open ios/Podfile
|
|
|
```
|
|
|
|
|
|
-9. Update the platform to iOS 10 and add the ComPDFKit Podspec:
|
|
|
+9. Update the platform to iOS 11 and add the ComPDFKit Podspec:
|
|
|
|
|
|
```diff
|
|
|
- platform :ios, '9.0'
|
|
@@ -318,8 +337,8 @@ open ios/Podfile
|
|
|
use_modular_headers!`
|
|
|
|
|
|
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
|
|
|
-+ pod 'ComPDFKit_Tools', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit_tools/latest.podspec'
|
|
|
-+ pod 'ComPDFKit', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit/latest.podspec'
|
|
|
++ pod 'ComPDFKit_Tools', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit_tools/1.11.0.podspec'
|
|
|
++ pod 'ComPDFKit', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit/1.11.0.podspec'
|
|
|
|
|
|
end
|
|
|
```
|
|
@@ -330,12 +349,13 @@ open ios/Podfile
|
|
|
pod install
|
|
|
```
|
|
|
|
|
|
-10. 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.
|
|
|
+11. 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.
|
|
|
|
|
|
```dart
|
|
|
import 'dart:io';
|
|
|
|
|
|
import 'package:compdfkit_flutter/compdfkit.dart';
|
|
|
+import 'package:compdfkit_flutter/cpdf_configuration.dart';
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
@@ -360,43 +380,73 @@ class _MyAppState extends State<MyApp> {
|
|
|
}
|
|
|
|
|
|
void _init() async {
|
|
|
- // Please replace it with your ComPDFKit license
|
|
|
- ComPDFKit.init('your license key', 'your license secret');
|
|
|
+ // Please replace it with your ComPDFKit license
|
|
|
+ ComPDFKit.init('your compdfkit key');
|
|
|
}
|
|
|
|
|
|
@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),
|
|
|
- )),
|
|
|
- ))),
|
|
|
+ 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';
|
|
|
+ var pdfsDir = Directory('${tempDir.path}/pdfs');
|
|
|
+ pdfsDir.createSync(recursive: true);
|
|
|
|
|
|
- final file = await File(tempDocumentPath).create(recursive: true);
|
|
|
- file.writeAsBytesSync(list);
|
|
|
- ComPDFKit.openDocument(tempDocumentPath);
|
|
|
+ final tempDocumentPath = '${tempDir.path}/$DOCUMENT_PATH';
|
|
|
+ final file = File(tempDocumentPath);
|
|
|
+ if (!file.existsSync()) {
|
|
|
+ file.create(recursive: true);
|
|
|
+ file.writeAsBytesSync(list);
|
|
|
+ }
|
|
|
+ var configuration = CPDFConfiguration();
|
|
|
+ // How to disable functionality:
|
|
|
+ // setting the default display mode when opening
|
|
|
+ // configuration.modeConfig = const ModeConfig(initialViewMode: CPreviewMode.annotations);
|
|
|
+ // top toolbar configuration:
|
|
|
+ // android:
|
|
|
+ // configuration.toolbarConfig = const ToolbarConfig(androidAvailableActions: [
|
|
|
+ // ToolbarAction.thumbnail, ToolbarAction.bota,
|
|
|
+ // ToolbarAction.search, ToolbarAction.menu
|
|
|
+ // ],
|
|
|
+ // availableMenus: [
|
|
|
+ // ToolbarMenuAction.viewSettings, ToolbarMenuAction.documentInfo, ToolbarMenuAction.security,
|
|
|
+ // ]);
|
|
|
+ // iOS:
|
|
|
+ // configuration.toolbarConfig = const ToolbarConfig(iosLeftBarAvailableActions: [
|
|
|
+ // ToolbarAction.back, ToolbarAction.thumbnail
|
|
|
+ // ],
|
|
|
+ // iosRightBarAvailableActions: [
|
|
|
+ // ToolbarAction.bota, ToolbarAction.search, ToolbarAction.menu
|
|
|
+ // ],
|
|
|
+ // availableMenus: [
|
|
|
+ // ToolbarMenuAction.viewSettings, ToolbarMenuAction.documentInfo, ToolbarMenuAction.security,
|
|
|
+ // ]);
|
|
|
+ // readerview configuration:
|
|
|
+ // configuration.readerViewConfig = const ReaderViewConfig(linkHighlight: true, formFieldHighlight: true);
|
|
|
+ ComPDFKit.openDocument(tempDocumentPath,
|
|
|
+ password: '', configuration: configuration);
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
-9. Add the PDF documents you want to display in the project
|
|
|
+12. Add the PDF documents you want to display in the project
|
|
|
|
|
|
* create a `pdf` directory
|
|
|
|
|
@@ -406,7 +456,7 @@ class _MyAppState extends State<MyApp> {
|
|
|
|
|
|
* Copy your example document into the newly created `pdfs` directory and name it `PDF_Document.pdf`
|
|
|
|
|
|
-10. Specify the `assets` directory in `pubspec.yaml`
|
|
|
+13. Specify the `assets` directory in `pubspec.yaml`
|
|
|
|
|
|
```diff
|
|
|
flutter:
|
|
@@ -414,35 +464,33 @@ class _MyAppState extends State<MyApp> {
|
|
|
+ - pdfs/
|
|
|
```
|
|
|
|
|
|
-11. To protect user privacy,
|
|
|
+14. 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.
|
|
|
+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.
|
|
|
|
|
|
- 
|
|
|
+
|
|
|
|
|
|
- ```objective-c
|
|
|
- <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>
|
|
|
- ```
|
|
|
+```objective-c
|
|
|
+<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>
|
|
|
+```
|
|
|
|
|
|
-12. Start your Android emulator, or connect a device.
|
|
|
+15. Start your Android emulator, or connect a device.
|
|
|
|
|
|
```bash
|
|
|
flutter emulators --launch apple_ios_simulator
|
|
|
```
|
|
|
|
|
|
-13. Run the app with:
|
|
|
+16. Run the app with:
|
|
|
|
|
|
```bash
|
|
|
flutter run
|
|
@@ -450,9 +498,13 @@ flutter run
|
|
|
|
|
|
|
|
|
|
|
|
-## 4 Support
|
|
|
|
|
|
-### 4.1 Reporting Problems
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+## 3 Support
|
|
|
+
|
|
|
+### 3.1 Reporting Problems
|
|
|
|
|
|
Thank you for your interest in ComPDFKit, 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 Flutter PDF Library, please submit the problem report to the [ComPDFKit team](https://www.compdf.com/support). More information as follows would help us to solve your problem:
|
|
|
|
|
@@ -463,7 +515,7 @@ Thank you for your interest in ComPDFKit, the only easy-to-use but powerful deve
|
|
|
|
|
|
|
|
|
|
|
|
-### 4.2 Contact Information
|
|
|
+### 3.2 Contact Information
|
|
|
|
|
|
**Home Link:**
|
|
|
|