Skip to content

Commit dc88ca4

Browse files
committed
compdfkit_flutter 2.0.2
1 parent dca51fe commit dc88ca4

File tree

56 files changed

+2713
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2713
-237
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1+
## 2.0.2
2+
* Added `CPDFReaderWidget` widget.
3+
```dart
4+
Scaffold(
5+
resizeToAvoidBottomInset: false,
6+
appBar: AppBar(),
7+
body: CPDFReaderWidget(
8+
document: documentPath,
9+
configuration: CPDFConfiguration(),
10+
onCreated: (controller) {},
11+
));
12+
```
13+
114
## 2.0.1
15+
216
* Added the features support for ComPDFKit PDF SDK for iOS V2.0.1.
317
* Added the features support for ComPDFKit PDF SDK for Android V2.0.1.
418
* Fix the issue of continuous memory growth.

CONFIGURATION.md

Lines changed: 1039 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ Please install the following required packages:
4545
Operating Environment Requirements:
4646

4747
* A minSdkVersion of `21` or higher.
48-
* A `compileSdkVersion` of `30` or higher.
49-
* A `targetSdkVersion` of `30` or higher.
48+
* A `compileSdkVersion` of `33` or higher.
49+
* A `targetSdkVersion` of `33` or higher.
5050
* Android ABI(s): x86, x86_64, armeabi-v7a, arm64-v8a.
5151

5252
**iOS**
@@ -59,7 +59,7 @@ Please install the following required packages:
5959

6060
Operating Environment Requirements:
6161

62-
* The iOS 10.0 or higher.
62+
* The iOS 11.0 or higher.
6363
* The Xcode 12.0 or newer for Objective-C or Swift.
6464

6565
### Integrate into a New Flutter APP
@@ -119,22 +119,48 @@ open android/app/build.gradle
119119
}
120120
```
121121

122-
6. Add the ComPDFKit dependency in `pubspec.yaml`
122+
6. 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`:
123+
124+
```diff
125+
- import io.flutter.embedding.android.FlutterActivity;
126+
+ import io.flutter.embedding.android.FlutterFragmentActivity;
127+
128+
- public class MainActivity extends FlutterActivity {
129+
+ public class MainActivity extends FlutterFragmentActivity {
130+
}
131+
```
132+
133+
Alternatively you can update the `AndroidManifest.xml` file to use `FlutterFragmentActivity` as the launcher activity:
134+
135+
```diff
136+
<activity
137+
- android:name=".MainActivity"
138+
+ android:name="io.flutter.embedding.android.FlutterFragmentActivity"
139+
android:exported="true"
140+
android:hardwareAccelerated="true"
141+
android:launchMode="singleTop"
142+
android:theme="@style/LaunchTheme"
143+
android:windowSoftInputMode="adjustPan">
144+
```
145+
146+
> **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.
147+
148+
7. Add the ComPDFKit dependency in `pubspec.yaml`
123149

124150
```diff
125151
dependencies:
126152
flutter:
127153
sdk: flutter
128-
+ compdfkit_flutter: ^2.0.1
154+
+ compdfkit_flutter: ^2.0.2
129155
```
130156

131-
7. From the terminal app, run the following command to get all the packages:
157+
8. From the terminal app, run the following command to get all the packages:
132158

133159
```bash
134160
flutter pub get
135161
```
136162

137-
8. 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.
163+
9. 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.
138164

139165
```dart
140166
import 'dart:io';
@@ -281,7 +307,7 @@ cd example
281307
dependencies:
282308
flutter:
283309
sdk: flutter
284-
+ compdfkit_flutter: ^2.0.1
310+
+ compdfkit_flutter: ^2.0.2
285311
```
286312

287313
4. From the terminal app, run the following command to get all the packages:
@@ -310,8 +336,8 @@ open ios/Podfile
310336
use_modular_headers!`
311337

312338
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
313-
+ pod 'ComPDFKit_Tools', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit_tools/2.0.1.podspec'
314-
+ pod 'ComPDFKit', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit/2.0.1.podspec'
339+
+ pod 'ComPDFKit_Tools', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit_tools/2.0.2.podspec'
340+
+ pod 'ComPDFKit', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit/2.0.2.podspec'
315341

316342
end
317343
```
@@ -527,8 +553,8 @@ target 'PDFView_RN' do
527553
# Pods for testing
528554
end
529555

530-
+ pod 'ComPDFKit', :git => 'https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-swift.git', :tag => '2.0.1'
531-
+ pod 'ComPDFKit_Tools', :git => 'https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-swift.git', :tag => '2.0.1'
556+
+ pod 'ComPDFKit', :git => 'https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-swift.git', :tag => '2.0.2'
557+
+ pod 'ComPDFKit_Tools', :git => 'https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-swift.git', :tag => '2.0.2'
532558

533559
# Enables Flipper.
534560
#
@@ -545,7 +571,7 @@ end
545571

546572
## UI Customization
547573

548-
In version **1.12.0**, we have expanded the options that can be defined in the [CPDFConfiguration](./lib/cpdf_configuration.dart) class. When using the `ComPDFKit.openDocument` method to open a PDF View, you can define this object to meet your product requirements. We will continue to enrich configuration options in the future to further enhance the flexibility of the product. Here are some examples of commonly used configuration options:
574+
In the **1.12.0** version, we have expanded the options that can be defined in the [CPDFConfiguration](./lib/cpdf_configuration.dart) class. When using the `ComPDFKit.openDocument` method to open a PDF View or use `CPDFReaderWidget`, you can define this object to meet your product needs. We will continue to enrich the configuration options in the future to further enhance the flexibility of the product. The following are some examples of commonly used configuration options:
549575

550576
1. Set the initial display mode and the list of available modes. The following code shows enabling only the viewer mode and annotations mode:
551577

@@ -585,7 +611,7 @@ var configuration = CPDFConfiguration(
585611
ComPDFKit.openDocument(documentPath, password: '', configuration: configuration);
586612
```
587613

588-
> Note: For more information, please refer to the options defined in the [CPDFConfiguration](./lib/cpdf_configuration.dart) class
614+
> Note: For more information, please refer to the options defined in the [CONFIGURATION.md](./CONFIGURATION.md) class
589615
590616
## Example APP
591617

@@ -604,6 +630,15 @@ ComPDFKit.init('your compdfkit key')
604630
605631
/// open pdf document
606632
ComPDFKit.openDocument(tempDocumentPath, password: '', configuration: CPDFConfiguration());
633+
634+
/// Here’s how you can open a PDF document using CPDFReaderWidget:
635+
Scaffold(
636+
resizeToAvoidBottomInset: false,
637+
appBar: AppBar(title: const Text('CPDFReaderWidget Example'),),
638+
body: CPDFReaderWidget(
639+
document: widget.documentPath,
640+
configuration: CPDFConfiguration()
641+
));
607642
```
608643

609644
## Support

android/build.gradle

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ rootProject.allprojects {
1616
repositories {
1717
google()
1818
mavenCentral()
19-
maven {
20-
url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
21-
}
2219
}
2320
}
2421

@@ -37,13 +34,13 @@ android {
3734
}
3835

3936
dependencies {
40-
compileOnly fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
37+
compileOnly fileTree(include: ['*.jar','*.aar'], dir: 'libs')
4138
implementation 'com.google.android.material:material:1.8.0'
4239
implementation 'androidx.appcompat:appcompat:1.6.1'
4340
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
44-
api 'com.compdf:compdfkit:2.0.1'
45-
api 'com.compdf:compdfkit-ui:2.0.1'
46-
api ('com.compdf:compdfkit-tools:2.0.1')
41+
42+
// dependencies compdfkit pdf sdk
43+
api 'com.compdf:compdfkit-tools:2.0.2'
4744

4845
testImplementation 'junit:junit:4.13.2'
4946
testImplementation 'org.mockito:mockito-core:5.0.0'

android/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.compdfkit.flutter.compdfkit_flutter">
2+
xmlns:tools="http://schemas.android.com/tools"
3+
package="com.compdfkit.flutter.compdfkit_flutter">
4+
35
<application>
46

57
</application>

android/src/main/java/com/compdfkit/flutter/compdfkit_flutter/CompdfkitFlutterPlugin.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import androidx.annotation.NonNull;
1313

1414
import com.compdfkit.flutter.compdfkit_flutter.plugin.ComPDFKitSDKPlugin;
15+
import com.compdfkit.flutter.compdfkit_flutter.platformview.CPDFViewCtrlFactory;
1516

1617
import io.flutter.embedding.engine.plugins.FlutterPlugin;
1718
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
@@ -24,10 +25,16 @@ public class CompdfkitFlutterPlugin implements FlutterPlugin, ActivityAware {
2425

2526
private BinaryMessenger mMessenger;
2627

28+
private PlatformViewRegistry mRegistry;
29+
30+
private static final String PDF_DOCUMENT_VIEW_TYPE_ID = "com.compdfkit.flutter.ui.pdfviewer";
31+
2732
@Override
2833
public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
2934
mMessenger = flutterPluginBinding.getBinaryMessenger();
30-
new ComPDFKitSDKPlugin(flutterPluginBinding.getApplicationContext(), mMessenger);
35+
mRegistry = flutterPluginBinding.getPlatformViewRegistry();
36+
new ComPDFKitSDKPlugin(flutterPluginBinding.getApplicationContext(), mMessenger)
37+
.register();
3138
}
3239

3340
@Override
@@ -36,6 +43,9 @@ public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
3643

3744
@Override
3845
public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) {
46+
if (mRegistry != null) {
47+
mRegistry.registerViewFactory(PDF_DOCUMENT_VIEW_TYPE_ID,new CPDFViewCtrlFactory(mMessenger));
48+
}
3949
}
4050

4151
@Override
@@ -45,7 +55,6 @@ public void onDetachedFromActivityForConfigChanges() {
4555

4656
@Override
4757
public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
48-
4958
}
5059

5160
@Override
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright © 2014-2024 PDF Technologies, Inc. All Rights Reserved.
3+
*
4+
* THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
5+
* AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
6+
* UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
7+
* This notice may not be removed from this file.
8+
*
9+
*/
10+
11+
package com.compdfkit.flutter.compdfkit_flutter.platformview;
12+
13+
14+
import android.content.Context;
15+
16+
import androidx.annotation.NonNull;
17+
import androidx.annotation.Nullable;
18+
19+
import java.util.Map;
20+
21+
import io.flutter.plugin.common.BinaryMessenger;
22+
import io.flutter.plugin.common.StandardMessageCodec;
23+
import io.flutter.plugin.platform.PlatformView;
24+
import io.flutter.plugin.platform.PlatformViewFactory;
25+
26+
public class CPDFViewCtrlFactory extends PlatformViewFactory {
27+
28+
private final BinaryMessenger binaryMessenger;
29+
30+
public CPDFViewCtrlFactory(BinaryMessenger binaryMessenger) {
31+
super(StandardMessageCodec.INSTANCE);
32+
this.binaryMessenger = binaryMessenger;
33+
}
34+
35+
@NonNull
36+
@Override
37+
public PlatformView create(Context context, int viewId, @Nullable Object args) {
38+
@SuppressWarnings("unchecked")
39+
Map<String, Object> creationParams = (Map<String, Object>) args;
40+
return new CPDFViewCtrlFlutter(context, binaryMessenger, viewId, creationParams);
41+
}
42+
}

0 commit comments

Comments
 (0)