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 configuration of android/app/build.gradle, set the minimum version to Android 6.0 (API 23) or later: android {
defaultConfig {
- minSdkVersion flutter.minSdkVersion
+ minSdkVersion 23
...
}
}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.2.0flutter pub getexample with the flutter CLI:flutter create --org com.compdfkit.flutter examplecd examplepubspec.yaml dependencies:
flutter:
sdk: flutter
+ compdfkit_flutter: ^3.2.0flutter pub getopen ios/Podfileios/Podfile, set the minimum platform version to iOS 13.0 and add the native ComPDF dependencies:- platform :ios, '9.0'
+ platform :ios, '13.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.2.0/ComPDFKit.podspec'
+ pod "ComPDFKit_Tools", podspec:'https://file.compdf.com/cocoapods/ios/compdfkit_pdf_sdk/3.2.0/ComPDFKit_Tools.podspec'
endOpen ios/Runner.xcworkspace in Xcode and set the iOS Deployment Target of the Runner target to 13.0 or later, matching the Podfile configuration.
example/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.
Configure the relevant privacy usage descriptions in ios/Runner/Info.plist for the camera, microphone, and photo library features your application uses.

<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>