PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
example with the flutter CLI:flutter create --org com.compdfkit.flutter examplecd exampleexample/android/app/src/main/AndroidManifest.xml , add Internet Permission and Storage Permission:<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.compdfkit.flutter.example">
+ <uses-permission android:name="android.permission.INTERNET"/>
<!-- 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"/>
<!-- Optional settings -->
+ <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<application
+ android:requestLegacyExternalStorage="true">
</application>
</manifest>android/app/build.gradle:open android/app/build.gradleandroid section: android {
defaultConfig {
- minSdkVersion flutter.minSdkVersion
+ minSdkVersion 21
...
}
}android/app/src/main/java/com/example/compdfkit/flutter/example/MainActivity.java, Change the base Activity to extend FlutterFragmentActivity:- import io.flutter.embedding.android.FlutterActivity;
+ import io.flutter.embedding.android.FlutterFragmentActivity;
- public class MainActivity extends FlutterActivity {
+ public class MainActivity extends FlutterFragmentActivity {
}Alternatively you can update the AndroidManifest.xml file to use FlutterFragmentActivity as the launcher activity:
<activity
- android:name=".MainActivity"
+ android:name="io.flutter.embedding.android.FlutterFragmentActivity"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustPan">Note:
FlutterFragmentActivityis not an official part of the Flutter SDK. If you need to useCPDFReaderWidgetin ComPDF for Flutter, you need to use this part of the code. You can skip this step if you don't need to use.
pubspec.yaml dependencies:
flutter:
sdk: flutter
+ compdfkit_flutter: ^3.0.0flutter pub getexample with the flutter CLI:flutter create --org com.compdfkit.flutter examplecd examplepubspec.yaml dependencies:
flutter:
sdk: flutter
+ compdfkit_flutter: ^3.0.0flutter pub getopen ios/Podfile- platform :ios, '9.0'
+ platform :ios, '12.0'
...
target 'Runner' do
use_frameworks!
use_modular_headers!`
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
+ pod "ComPDFKit", podspec:'https://file.compdf.com/cocoapods/ios/compdfkit_pdf_sdk/3.0.0/ComPDFKit.podspec'
+ pod "ComPDFKit_Tools", podspec:'https://file.compdf.com/cocoapods/ios/compdfkit_pdf_sdk/3.0.0/ComPDFKit_Tools.podspec'
endexample/ios folder and run the pod install command:pod installNote: If SSL network requests fail to download the ComPDF library when you run pod install, you can see the processing method in Troubleshooting.
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>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>