liuxiaolong e7b6be6279 Conversion(flutter) ios端原生代码 | 1 tahun lalu | |
---|---|---|
android | 1 tahun lalu | |
example | 1 tahun lalu | |
ios | 1 tahun lalu | |
lib | 1 tahun lalu | |
.gitignore | 1 tahun lalu | |
.metadata | 1 tahun lalu | |
CHANGELOG.md | 1 tahun lalu | |
LICENSE | 1 tahun lalu | |
README.md | 1 tahun lalu | |
analysis_options.yaml | 1 tahun lalu | |
pubspec.lock | 1 tahun lalu | |
pubspec.yaml | 1 tahun lalu |
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