1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- /// Copyright © 2014-2023 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";
- /// init ComPDFKit sdk, please enter your ComPDFKit [key] and [secret]
- /// A new license is enabled in ComPDFKit SDK V1.11.0.
- /// If you are using a version before V1.11.0 and do not have a new license,
- /// please contact our technical team.
- static void init(String key) async {
- _methodChannel.invokeMethod(initSDK, {'key': key});
- }
- /// get ComPDFKit SDK version code
- static Future<String> getVersionCode() async {
- String versionCode =
- await _methodChannel.invokeMethod(ComPDFKit.sdkVersionCode);
- return versionCode;
- }
- /// get ComPDFKit SDK build tag info
- static Future<String> getSDKBuildTag() async {
- String buildTag = await _methodChannel.invokeMethod(ComPDFKit.sdkBuildTag);
- return buildTag;
- }
- /// Pass in the local file path of the PDF document and display it within a newly opened view.
- 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 temporary directory path of the currently running platform.
- /// Currently, only [Android] and [IOS] are supported.
- 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);
- }
- }
|