123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- /// Copyright © 2014-2024 PDF Technologies, Inc. All Rights Reserved.
- ///
- /// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
- /// AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
- /// UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
- /// This notice may not be removed from this file.
- import 'dart:io';
- import 'package:compdfkit_flutter/cpdf_configuration.dart';
- import 'package:flutter/services.dart';
- class ComPDFKit {
- static const MethodChannel _methodChannel =
- MethodChannel('com.compdfkit.flutter.plugin');
- static const initSDK = 'init_sdk';
- static const sdkVersionCode = 'sdk_version_code';
- static const sdkBuildTag = "sdk_build_tag";
- /// Please enter your ComPDFKit license to initialize the ComPDFKit SDK.<br/>
- /// In version **1.13.0**, we have introduced a brand-new online authentication licensing scheme.
- /// By default, the ComPDFKit SDK performs online authentication.
- /// If you obtained your ComPDFKit License before the release of version 1.13.0, please set [offline=true].<br/>
- /// If you are unsure about the type of your license, please contact the [ComPDFKit team.](https://www.compdf.com/support).
- ///
- /// **samples:**<br/>
- /// ```dart
- /// ComPDFKit.init('your compdfkit license')
- /// ```
- @Deprecated(
- 'in 1.13.0 deprecated, please use initialize(String key, {bool offline = true})')
- static void init(String key) async {
- _methodChannel.invokeMethod(initSDK, {'key': key, 'online': false});
- }
- /// Please enter your ComPDFKit license to initialize the ComPDFKit SDK.<br/>
- /// In version **1.13.0**, we have introduced a brand-new online authentication licensing scheme.
- /// By default, the ComPDFKit SDK performs online authentication.
- /// If you obtained your ComPDFKit License before the release of version 1.13.0, please set [offline=true].
- /// or use ComPDFKit.init(String key) <br/>
- /// If you are unsure about the type of your license, please contact the [ComPDFKit team.](https://www.compdf.com/support).
- ///
- /// **samples:**<br/>
- /// **online auth**
- /// ```dart
- /// ComPDFKit.initialize('your compdfkit license')
- /// ```
- ///
- /// <br/>
- /// **offline auth**
- /// ```dart
- /// ComPDFKit.initialize('your compdfkit license', offline = true)
- /// ```
- static void initialize(String key, {bool offline = false}) {
- _methodChannel.invokeMethod(initSDK, {'key': key, 'offline': offline});
- }
- /// Get the version code of the ComPDFKit SDK.
- static Future<String> getVersionCode() async {
- String versionCode =
- await _methodChannel.invokeMethod(ComPDFKit.sdkVersionCode);
- return versionCode;
- }
- /// Get the version information of ComPDFKit SDK.
- static Future<String> getSDKBuildTag() async {
- String buildTag = await _methodChannel.invokeMethod(ComPDFKit.sdkBuildTag);
- return buildTag;
- }
- /// Enter the local PDF file path, document password (if required),
- /// and configuration parameters, and display the PDF document in a new window.
- ///
- /// **for Samples:**
- /// ```dart
- /// ComPDFKit.openDocument(
- /// 'xxx/compdfkit.pdf',
- /// password : '',
- /// configuration:CPDFConfiguration())
- /// ```
- static void openDocument(String document,
- {String? password, CPDFConfiguration? configuration}) async {
- await _methodChannel.invokeMethod('openDocument', <String, dynamic>{
- 'document': document,
- 'password': password,
- 'configuration': configuration?.toJson()
- });
- }
- /// Retrieve the path of your operating system's temporary directory.
- /// Support [Android] and [iOS] only for now.
- static Future<Directory> getTemporaryDirectory() async {
- final String? path =
- await _methodChannel.invokeMethod('getTemporaryDirectory');
- if (path == null) {
- throw Exception('Unable to get temporary directory');
- }
- return Directory(path);
- }
- }
|