liuxiaolong e7b6be6279 Conversion(flutter) ios端原生代码 | il y a 1 an | |
---|---|---|
android | il y a 1 an | |
example | il y a 1 an | |
ios | il y a 1 an | |
lib | il y a 1 an | |
.gitignore | il y a 1 an | |
.metadata | il y a 1 an | |
CHANGELOG.md | il y a 1 an | |
LICENSE | il y a 1 an | |
README.md | il y a 1 an | |
analysis_options.yaml | il y a 1 an | |
pubspec.lock | il y a 1 an | |
pubspec.yaml | il y a 1 an |
ComPDFKit Conversion SDK for Flutter is a powerful conversion library. Developers can seamlessly integrate PDF documents to Office documents conversion SDK into their applications and services running.
More information can be found at https://www.compdf.com/guides/conversion-sdk/android/overview
First follow the Flutter getting started guides to Install, set up an editor, and Create a Flutter Project. The rest of this guide assumes your project is created by running flutter create myapp.
Add the following dependency to your Flutter project in myapp/pubspec.yaml
file:
flutter packages get
lib/main.dart
, and add the following code: @override
void initState() {
super.initState();
+ CPDFConverter.init("your ComPDFKit key","your ComPDFKit secret");
}
myapp/pubspec.yaml
file:dependencies:
flutter:
sdk: flutter
kmpdfkit_conversion_flutter:
+ file_picker: ^5.2.5
+ permission_handler: ^10.2.0
FilePicker
plugin to select the PDF file that needs to be converted: ///request storage permission
Future<bool> getPermission() async {
var status = await Permission.storage.request();
return status.isGranted;
}
///Select pdf files from android\ios using 'file_picker'
Future<List<String>> getPDFFileList(BuildContext context) async {
bool isGranted = await getPermission();
if (!isGranted) {
return List.empty();
}
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom, allowedExtensions: ['pdf'], allowMultiple: true);
if (result != null) {
List<String?> pdfFiles = result.paths;
var files = pdfFiles.where((element) => element != null);
return List.from(files);
} else {
return List.empty();
}
}
List<String> files = await getPDFFileList(context);
CPDFConverter.convert(
taskId: const Uuid().v4(),
filePath: files.get(0),
convertType: ConvertType.ppt,
options: ConvertPPTOptions(),
callback: (TaskResult result) {
var taskId = result.taskId;
var progress = result.progress;
var taskStatus = result.taskStatus;
var outPutPath = result.outPutPath;
});
dart
CPDFConverter.cancelTask();
See Changelog
See License