소스 검색

【代码优化】 1.更新README文档

liuxiaolong 1 년 전
부모
커밋
0169a002f5
2개의 변경된 파일136개의 추가작업 그리고 22개의 파일을 삭제
  1. 123 16
      README.md
  2. 13 6
      example/lib/states/convert_provider.dart

+ 123 - 16
README.md

@@ -1,26 +1,133 @@
-# Conversion SDK Flutter
+# Introduction to Conversion SDK Flutter
 
-## How to Use
+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.
 
-* InitSDK
+## Overview
+
+### Key Features
+* Convert PDF documents to Word documents.
+    * Reconstruct content from PDF files into reusable data.
+    * Reconstruction (recover page layout, columns, formatting, graphics, and preserve text flow).
+    * Support mapping conversion to split-column function.
+    * Support the function of combining letters into a string of text.
+    * Support floating insertion such as picture rotation cutting.
+    * Support converting partial Math or Chemistry function.
+    * Support font size, color, bold, italic, and underline recognition.
+    * Support two layout options to choose from: Retain Flowing Text and Retain Page Layout.
+* Convert PDF documents to Excel documents.
+    * Support data mapping to Excel cells.
+    * Support recognition of a small number, currency, and other formats.
+    * Support multiple cells merge function.
+    * Support different types of content, including text, table, or all content in PDF.
+    * Support multiple Worksheet options, including converting one table to one sheet, all tables on one page to one sheet, or all tables in the entire document to one sheet.
+* Convert PDF documents to PPT documents.
+    * Convert each page to an editable slide.
+    * Support converting text to a PowerPoint text box.
+    * Support picture rotation cutting and other floating insertion.
+    * Support converting partial Math or Chemistry function.
+* Convert PDF documents to TXT documents.
+* Convert PDF documents to CSV documents.
+    * Support extracting only tables from PDF accurately and converting them to CSV, and one table is converted to one CSV file. Or you can also merge multiple tables into one CSV file.
+* Convert PDF documents to Image documents.
+    * Support converting PDF to high-quality image formats, including PNG and JPEG. All image quality and resolution will remain intact. And the image DPI can be set freely.
+* Convert PDF documents to RTF documents.
+    * Support converting PDF to Rich Text Format documents, including text and images.
+* Convert PDF documents to HTML documents.
+    * Support converting PDF to HTML, including single-page and multiple-page.
+
+More information can be found at [https://www.compdf.com/guides/conversion-sdk/android/overview](https://www.compdf.com/guides/conversion-sdk/android/overview)
+
+
+## Installation
+1. First follow the Flutter getting started guides to [Install](https://docs.flutter.dev/get-started/install), [set up an editor](https://docs.flutter.dev/get-started/editor), and [Create a Flutter Project.](https://docs.flutter.dev/get-started/test-drive?tab=terminal#create-app)  The rest of this guide assumes your project is created by running `flutter create myapp.`
+
+2. Add the following dependency to your Flutter project in `myapp/pubspec.yaml` file:
+
+* If you want to use our null safe package from pub.dev:
+```diff
+dependencies:
+    flutter:
+      sdk: flutter
++   kmpdfkit_conversion_flutter:
+```
+3. Run the following command in the myapp directory to retrieve the dependencies:
+```
+flutter packages get
+```
+
+
+## Usage
+
+1. Open `lib/main.dart`, and add the following code:
+```diff
+  @override
+  void initState() {
+    super.initState();
++   CPDFConverter.init("your ComPDFKit key","your ComPDFKit secret");
+  }
+```
+
+2. To select a local PDF file, add the following dependencies to the `myapp/pubspec.yaml` file:
+```diff
+dependencies:
+    flutter:
+      sdk: flutter
+    kmpdfkit_conversion_flutter:
++   file_picker: ^5.2.5
++   permission_handler: ^10.2.0
+```
+
+3. After obtaining the storage permission, use the `FilePicker` plugin to select the PDF file that needs to be converted:
 ```dart
-    CPDFConverter.init("key", "secret");
+  ///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();
+    }
+  }
 ```
-* Conversion PDF
+
+4. Convert file formats using the Conversion SDK:
 ```dart
-    CPDFConverter.convert(
+  List<String> files = await getPDFFileList(context);
+
+  CPDFConverter.convert(
         taskId: const Uuid().v4(),
-        filePath: "pdfFilePath",
-        convertType: ConvertType.ppt, 
-        options: ConvertPPTOptions(
-            containAnnotations: true, 
-            containImages: true), 
+        filePath: files.get(0),
+        convertType: ConvertType.ppt,
+        options: ConvertPPTOptions(),
         callback: (TaskResult result) {
-            var progress = result.progress;
-            var taskId = result.taskId;
-            var taskStatus = result.taskStatus;
-            var outputPath = result.outPutPath;
-    });
+          var taskId = result.taskId;
+          var progress = result.progress;
+          var taskStatus = result.taskStatus;
+          var outPutPath = result.outPutPath;
+        });
 ```
 
+5. Cancel the conversion task:
+```dart
+  CPDFConverter.cancelTask();
+```
+
+## Changelog
+See Changelog
+
+## License
+See License
 

+ 13 - 6
example/lib/states/convert_provider.dart

@@ -10,6 +10,7 @@ import 'package:flutter/material.dart';
 import 'package:kmpdfkit_conversion_flutter/cpdf_converter.dart';
 import 'package:kmpdfkit_conversion_flutter/models/convert_status.dart';
 import 'package:kmpdfkit_conversion_flutter/models/convert_type.dart';
+import 'package:kmpdfkit_conversion_flutter/models/options/convert_ppt_options.dart';
 import 'package:kmpdfkit_conversion_flutter/models/options/options.dart';
 import 'package:kmpdfkit_conversion_flutter/models/task_result.dart';
 import 'package:kmpdfkit_conversion_flutter/util/string_extensions.dart';
@@ -48,7 +49,8 @@ class ConvertTaskQueueProvider extends ChangeNotifier {
     }
 
     if (!_isExecuting && autoTask) {
-      conversionLog("There is no task in progress, and the conversion task is started");
+      conversionLog(
+          "There is no task in progress, and the conversion task is started");
       executeNextTask();
     }
     notifyListeners();
@@ -57,10 +59,12 @@ class ConvertTaskQueueProvider extends ChangeNotifier {
   void executeNextTask() {
     ConvertTask? nextTask = getNextTask();
     if (nextTask != null) {
-      conversionLog("The waiting task in the queue is not empty, and the file transfer is started");
+      conversionLog(
+          "The waiting task in the queue is not empty, and the file transfer is started");
       startTask(nextTask);
-    }else{
-      conversionLog("There is no waiting transfer task in the queue, and the task ends");
+    } else {
+      conversionLog(
+          "There is no waiting transfer task in the queue, and the task ends");
     }
   }
 
@@ -78,13 +82,16 @@ class ConvertTaskQueueProvider extends ChangeNotifier {
               result.outPutPath);
           if (result.taskStatus == TaskStatus.success ||
               result.taskStatus == TaskStatus.fail) {
-            conversionLog("convert:${result.taskStatus.name}, start the next task");
+            conversionLog(
+                "convert:${result.taskStatus.name}, start the next task");
             _isExecuting = false;
-            if(autoTask){
+            if (autoTask) {
               executeNextTask();
             }
           }
         });
+
+    CPDFConverter.cancelTask()
   }
 
   void updateStatus(