123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- /// 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: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";
- static void init(String key, String secret) async {
- _methodChannel.invokeMethod(initSDK, {'key': key, 'secret' : secret});
- }
- /// 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}) async {
- await _methodChannel.invokeMethod('openDocument', <String, dynamic>{
- 'document': document,
- 'password': password
- });
- }
- /// 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);
- }
- }
|