Browse Source

ComPDFKit(flutter) - 新增首页、设置页、新增多语支持

liuxiaolong 1 year ago
parent
commit
50c6edf9fc

+ 1 - 1
android/src/main/java/com/compdfkit/flutter/compdfkit_flutter/plugin/ComPDFKitSDKPlugin.java

@@ -57,7 +57,7 @@ public class ComPDFKitSDKPlugin extends BaseMethodChannelPlugin {
                 CPDFSdk.init(context, androidLicenseKey, false);
                 break;
             case SDK_VERSION_CODE:
-                result.success(CPDFSdk.getSDKVersion());
+                result.success("ComPDFKit " + CPDFSdk.getSDKVersion() + " for Android");
                 break;
             case SDK_BUILD_TAG:
                 result.success(CPDFSdk.getSDKBuildTag());

+ 4 - 0
example/android/app/build.gradle

@@ -61,6 +61,10 @@ android {
 
     buildTypes {
         release {
+            debuggable false
+            minifyEnabled true
+            zipAlignEnabled true
+            shrinkResources true
             signingConfig signingConfigs.release
             proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
         }

File diff suppressed because it is too large
+ 6 - 0
example/images/ic_home_setting.svg


+ 7 - 0
example/images/ic_home_viewer.svg

@@ -0,0 +1,7 @@
+<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect width="30" height="30" rx="4" fill="#F2F3F5"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M18.2071 6.5H7.5V23.5H22.5V10.7929L18.2071 6.5Z" fill="#477EDE" fill-opacity="0.5"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M9.5 8.5H17.5L20.5 11.5V21.5H9.5L9.5 8.5Z" fill="#477EDE"/>
+<path d="M14.9583 17.75C16.6763 17.75 18.1387 16.2833 18.6862 15.6551C18.8279 15.4925 18.8279 15.2575 18.6862 15.0949C18.1387 14.4667 16.6763 13 14.9583 13C13.2404 13 11.778 14.4667 11.2305 15.0949C11.0888 15.2575 11.0888 15.4925 11.2305 15.6551C11.778 16.2833 13.2404 17.75 14.9583 17.75Z" fill="white"/>
+<path d="M14.9583 16.3649C15.5049 16.3649 15.9479 15.9219 15.9479 15.3753C15.9479 14.8288 15.5049 14.3857 14.9583 14.3857C14.4118 14.3857 13.9688 14.8288 13.9688 15.3753C13.9688 15.9219 14.4118 16.3649 14.9583 16.3649Z" stroke="#477EDE" stroke-linejoin="round"/>
+</svg>

+ 3 - 0
example/images/ic_syasarrow.svg

@@ -0,0 +1,3 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M9.77832 4L17.5565 11.7782L9.77832 19.5563" stroke="#999999" stroke-width="1.5"/>
+</svg>

+ 62 - 0
example/lib/features.dart

@@ -0,0 +1,62 @@
+///  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 'package:flutter/material.dart';
+import 'package:flutter_svg/flutter_svg.dart';
+
+class FeatureItem extends StatelessWidget {
+  final String title;
+
+  final String description;
+
+  final GestureTapCallback onTap;
+
+  const FeatureItem(
+      {super.key,
+      required this.title,
+      required this.description,
+      required this.onTap});
+
+  @override
+  Widget build(BuildContext context) {
+    return Ink(
+      child: InkWell(
+        borderRadius: BorderRadius.circular(8),
+        onTap: onTap,
+        child: Padding(padding: const EdgeInsets.symmetric(vertical: 12), child: Row(
+          mainAxisSize: MainAxisSize.min,
+          children: [
+            SvgPicture.asset(
+              'images/ic_home_viewer.svg',
+              width: 38,
+              height: 38,
+            ),
+            const Padding(padding: EdgeInsets.only(left: 8.0)),
+            Expanded(
+                child: Column(
+                  crossAxisAlignment: CrossAxisAlignment.start,
+                  children: [
+                    Text(title, style: Theme.of(context).textTheme.titleSmall),
+                    Text(
+                      description,
+                      style: const TextStyle(fontSize: 12.0),
+                    )
+                  ],
+                )),
+            SvgPicture.asset(
+              'images/ic_syasarrow.svg',
+              width: 24,
+              height: 24,
+              color: Theme.of(context).colorScheme.onPrimary,
+            )
+          ],
+        )),
+      ),
+    );
+  }
+}

+ 24 - 0
example/lib/l10n/app_en.arb

@@ -0,0 +1,24 @@
+{
+  "app_title": "ComPDFKit SDK for Flutter",
+  "setting": "Settings",
+  "features": "Features",
+  "open_document_title": "Open Document",
+  "open_document_desc": "Open sample pdf document",
+  "pick_document_title": "Pick Document",
+  "pick_document_desc": "Select pdf document from system file manager",
+  "sdk_information": "SDK Information",
+  "company_information": "Company Information",
+  "versions" : "Versions",
+  "about_us" : "About ComPDFKit",
+  "technical_support": "Technical Support",
+  "contact_sales": "Contact Sales",
+  "privacy_policy" : "Privacy Policy",
+  "terms_of_service": "Terms of Service",
+  "compdf_official_website": "https://www.compdf.com/",
+  "compdf_email": "support@compdf.com",
+  "compdf_about_us_url":"https://www.compdf.com/company/about",
+  "compdf_technical_support_url":"https://www.compdf.com/support",
+  "compdf_contact_sales_url":"https://www.compdf.com/contact-sales",
+  "compdf_privacy_policy_url":"https://www.compdf.com/privacy-policy",
+  "compdf_terms_of_service_url":"https://www.compdf.com/terms-of-service"
+}

+ 24 - 0
example/lib/l10n/app_zh.arb

@@ -0,0 +1,24 @@
+{
+  "app_title" : "ComPDFKit SDK for Flutter",
+  "setting" : "设置",
+  "features" : "功能",
+  "open_document_title": "打开文档",
+  "open_document_desc": "打开示例提供的PDF文档",
+  "pick_document_title": "选择文档",
+  "pick_document_desc": "从系统文件管理器中选择pdf文档",
+  "sdk_information": "SDK 信息",
+  "company_information": "公司信息",
+  "versions" : "版本",
+  "about_us" : "关于ComPDFKit",
+  "technical_support": "技术支持",
+  "contact_sales": "联系销售",
+  "privacy_policy" : "隐私协议",
+  "terms_of_service": "服务条款",
+  "compdf_official_website": "https://www.compdf.com/zh-cn",
+  "compdf_email": "support@compdf.com",
+  "compdf_about_us_url":"https://www.compdf.com/company/about",
+  "compdf_technical_support_url":"https://www.compdf.com/support",
+  "compdf_contact_sales_url":"https://www.compdf.com/zh-cn/contact-sales",
+  "compdf_privacy_policy_url":"https://www.compdf.com/zh-cn/privacy-policy/",
+  "compdf_terms_of_service_url":"https://www.compdf.com/zh-cn/terms-of-service"
+}

+ 24 - 0
example/lib/l10n/app_zh_Hant.arb

@@ -0,0 +1,24 @@
+{
+  "app_title" : "ComPDFKit SDK for Flutter",
+  "setting" : "設定",
+  "features" : "功能",
+  "open_document_title": "開啟文件",
+  "open_document_desc": "開啟範例提供的PDF文檔",
+  "pick_document_title": "選擇文檔",
+  "pick_document_desc": "從系統文件管理器中選擇pdf文檔",
+  "sdk_information": "SDK 訊息",
+  "company_information": "公司資訊",
+  "versions" : "版本",
+  "about_us" : "關於ComPDFKit",
+  "technical_support": "技術支援",
+  "contact_sales": "聯繫銷售",
+  "privacy_policy" : "隱私協議",
+  "terms_of_service": "服務條款",
+  "compdf_official_website": "https://www.compdf.com/zh-cn",
+  "compdf_email": "support@compdf.com",
+  "compdf_about_us_url":"https://www.compdf.com/company/about",
+  "compdf_technical_support_url":"https://www.compdf.com/support",
+  "compdf_contact_sales_url":"https://www.compdf.com/zh-cn/contact-sales",
+  "compdf_privacy_policy_url":"https://www.compdf.com/zh-cn/privacy-policy/",
+  "compdf_terms_of_service_url":"https://www.compdf.com/zh-cn/terms-of-service"
+}

+ 105 - 53
example/lib/main.dart

@@ -9,8 +9,16 @@ import 'dart:io';
 
 import 'package:compdfkit_flutter/compdfkit.dart';
 import 'package:compdfkit_flutter/cpdf_configuration.dart';
+import 'package:compdfkit_flutter_example/features.dart';
+import 'package:compdfkit_flutter_example/page/settings_page.dart';
+import 'package:compdfkit_flutter_example/theme/themes.dart';
+import 'package:compdfkit_flutter_example/utils/file_util.dart';
+import 'package:file_picker/file_picker.dart';
+import 'package:flutter_gen/gen_l10n/app_localizations.dart';
 
 import 'package:flutter/material.dart';
+import 'package:flutter_localizations/flutter_localizations.dart';
+import 'package:flutter_svg/svg.dart';
 
 const String DOCUMENT_PATH = 'pdfs/PDF_Document.pdf';
 
@@ -18,14 +26,31 @@ void main() {
   runApp(const MyApp());
 }
 
-class MyApp extends StatefulWidget {
+class MyApp extends StatelessWidget {
   const MyApp({super.key});
 
   @override
-  State<MyApp> createState() => _MyAppState();
+  Widget build(BuildContext context) {
+    return MaterialApp(
+      title: 'ComPDFKit SDK for Flutter',
+      theme: lightTheme,
+      darkTheme: darkTheme,
+      themeMode: ThemeMode.system,
+      localizationsDelegates: AppLocalizations.localizationsDelegates,
+      supportedLocales: AppLocalizations.supportedLocales,
+      home: const HomePage(),
+    );
+  }
 }
 
-class _MyAppState extends State<MyApp> {
+class HomePage extends StatefulWidget {
+  const HomePage({super.key});
+
+  @override
+  State<HomePage> createState() => _HomePageState();
+}
+
+class _HomePageState extends State<HomePage> {
   @override
   void initState() {
     super.initState();
@@ -44,60 +69,87 @@ class _MyAppState extends State<MyApp> {
 
   }
 
+  void showDocument() async {
+    File document = await extractAsset(context, DOCUMENT_PATH);
+    ComPDFKit.openDocument(document.path,
+        password: '', configuration: CPDFConfiguration());
+  }
+
+  void pickDocument() async {
+    FilePickerResult? result = await FilePicker.platform.pickFiles(
+      type: FileType.custom,
+      allowedExtensions: ['pdf'],
+    );
+    if (result != null) {
+      ComPDFKit.openDocument(result.files.first.path!,
+          password: '', configuration: CPDFConfiguration());
+    }
+  }
+
   @override
   Widget build(BuildContext context) {
-    return MaterialApp(
-      home: Scaffold(
-          body: SafeArea(
-              child: Center(
-        child: ElevatedButton(
-            onPressed: () async {
-              showDocument(context);
-            },
-            child: const Text('Open Document')),
-      ))),
-    );
+    final exampleList = <Widget>[
+      Text(
+        AppLocalizations.of(context)!.features,
+        style: Theme.of(context).textTheme.bodyLarge,
+      ),
+      FeatureItem(
+          title: AppLocalizations.of(context)!.open_document_title,
+          description: AppLocalizations.of(context)!.open_document_desc,
+          onTap: () => showDocument()),
+      FeatureItem(
+          title: AppLocalizations.of(context)!.pick_document_title,
+          description: AppLocalizations.of(context)!.pick_document_desc,
+          onTap: () => pickDocument()),
+    ];
+
+    return Scaffold(
+        appBar: const CAppBar(), body: ExampleListView(widgets: exampleList));
   }
+}
 
-  void showDocument(BuildContext context) async {
-    final bytes = await DefaultAssetBundle.of(context).load(DOCUMENT_PATH);
-    final list = bytes.buffer.asUint8List();
-    final tempDir = await ComPDFKit.getTemporaryDirectory();
-    var pdfsDir = Directory('${tempDir.path}/pdfs');
-    pdfsDir.createSync(recursive: true);
-    final tempDocumentPath = '${tempDir.path}/$DOCUMENT_PATH';
-    final file = File(tempDocumentPath);
-    if (!file.existsSync()) {
-      file.create(recursive: true);
-      file.writeAsBytesSync(list);
-    }
+class ExampleListView extends StatelessWidget {
+  final List<Widget> widgets;
+
+  const ExampleListView({super.key, required this.widgets});
+
+  @override
+  Widget build(BuildContext context) {
+    return Padding(
+        padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
+        child: ListView.builder(
+            itemCount: widgets.length,
+            itemBuilder: (context, index) {
+              return widgets[index];
+            }));
+  }
+}
+
+class CAppBar extends StatelessWidget implements PreferredSizeWidget {
+  const CAppBar({super.key});
 
-    var configuration = CPDFConfiguration();
-    // How to disable functionality:
-    // setting the default display mode when opening
-    //      configuration.modeConfig = const ModeConfig(initialViewMode: CPreviewMode.digitalSignatures);
-    // top toolbar configuration:
-    // android:
-    //      configuration.toolbarConfig = const ToolbarConfig(androidAvailableActions: [
-    //           ToolbarAction.thumbnail, ToolbarAction.bota,
-    //           ToolbarAction.search, ToolbarAction.menu
-    //      ],
-    //      availableMenus: [
-    //        ToolbarMenuAction.viewSettings, ToolbarMenuAction.documentInfo, ToolbarMenuAction.security,
-    //      ]);
-    // iOS:
-    //      configuration.toolbarConfig = const ToolbarConfig(iosLeftBarAvailableActions: [
-    //          ToolbarAction.back, ToolbarAction.thumbnail
-    //      ],
-    //      iosRightBarAvailableActions: [
-    //        ToolbarAction.bota, ToolbarAction.search, ToolbarAction.menu
-    //      ],
-    //      availableMenus: [
-    //        ToolbarMenuAction.viewSettings, ToolbarMenuAction.documentInfo, ToolbarMenuAction.security,
-    //      ]);
-    // readerview configuration
-    //      configuration.readerViewConfig = const ReaderViewConfig(linkHighlight: true, formFieldHighlight: true);
-    ComPDFKit.openDocument(tempDocumentPath,
-        password: '', configuration: configuration);
+  @override
+  Widget build(BuildContext context) {
+    return AppBar(
+      title: Text(AppLocalizations.of(context)!.app_title),
+      actions: [
+        IconButton(
+            padding: const EdgeInsets.all(16),
+            onPressed: () {
+              Navigator.push(context, MaterialPageRoute(builder: (context) {
+                return const SettingsPage();
+              }));
+            },
+            icon: SvgPicture.asset(
+              'images/ic_home_setting.svg',
+              width: 24,
+              height: 24,
+              color: Theme.of(context).colorScheme.onPrimary,
+            ))
+      ],
+    );
   }
+
+  @override
+  Size get preferredSize => const Size(double.infinity, 56);
 }

+ 124 - 0
example/lib/page/settings_page.dart

@@ -0,0 +1,124 @@
+///  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 'package:compdfkit_flutter/compdfkit.dart';
+import 'package:flutter/gestures.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_svg/flutter_svg.dart';
+import 'package:url_launcher/url_launcher.dart';
+import 'package:flutter_gen/gen_l10n/app_localizations.dart';
+
+class SettingsPage extends StatelessWidget {
+  const SettingsPage({super.key});
+
+  @override
+  Widget build(BuildContext context) {
+    return Scaffold(
+        appBar: AppBar(
+          elevation: 4,
+          excludeHeaderSemantics: true,
+          titleSpacing: 0,
+          title: Text(AppLocalizations.of(context)!.setting),
+        ),
+        body: Column(
+          children: [
+            Column(
+              children: [
+                head(context, AppLocalizations.of(context)!.sdk_information),
+                item(context, AppLocalizations.of(context)!.versions,
+                    trailing: FutureBuilder(
+                        future: ComPDFKit.getVersionCode(),
+                        builder: (context, snap) {
+                          return Text(snap.data ?? "",
+                              style: Theme.of(context).textTheme.bodyMedium);
+                        })),
+                head(context, AppLocalizations.of(context)!.company_information),
+                item(context, AppLocalizations.of(context)!.compdf_official_website,
+                    onTap: () =>
+                        launchUrl(Uri.parse(AppLocalizations.of(context)!.compdf_official_website))),
+                item(context, AppLocalizations.of(context)!.about_us,
+                    onTap: () => launchUrl(
+                        Uri.parse(AppLocalizations.of(context)!.compdf_about_us_url))),
+                item(context, AppLocalizations.of(context)!.technical_support,
+                    onTap: () =>
+                        launchUrl(Uri.parse(AppLocalizations.of(context)!.compdf_technical_support_url))),
+                item(context, AppLocalizations.of(context)!.contact_sales,
+                    onTap: () => launchUrl(
+                        Uri.parse(AppLocalizations.of(context)!.compdf_contact_sales_url))),
+                item(context, AppLocalizations.of(context)!.compdf_email, onTap: () {
+                  launchUrl(Uri.parse(
+                      'mailto:support@compdf.com?subject=${AppLocalizations.of(context)!.technical_support}'));
+                }),
+              ],
+            ),
+            Expanded(
+                child: SafeArea(
+                    child: Padding(
+              padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
+              child: Column(
+                mainAxisAlignment: MainAxisAlignment.end,
+                children: [
+                  Text(
+                    '© 2014-2024 PDF Technologies, Inc. All Rights Reserved.',
+                    style: Theme.of(context)
+                        .textTheme
+                        .bodySmall
+                        ?.copyWith(fontSize: 11),
+                    textAlign: TextAlign.center,
+                  ),
+                  const Padding(padding: EdgeInsets.only(top: 8)),
+                  Text.rich(TextSpan(children: [
+                    TextSpan(
+                        text: AppLocalizations.of(context)!.privacy_policy,
+                        style: Theme.of(context).textTheme.bodySmall?.copyWith(
+                            fontSize: 11, color: const Color(0xFF1460F3)),
+                        recognizer: TapGestureRecognizer()
+                          ..onTap = () => launchUrl(
+                                Uri.parse(
+                                    AppLocalizations.of(context)!.compdf_privacy_policy_url),
+                              )),
+                    const TextSpan(text: ' | '),
+                    TextSpan(
+                        text: AppLocalizations.of(context)!.terms_of_service,
+                        style: Theme.of(context).textTheme.bodySmall?.copyWith(
+                            fontSize: 11, color: const Color(0xFF1460F3)),
+                        recognizer: TapGestureRecognizer()
+                          ..onTap = () => launchUrl(
+                                Uri.parse(
+                                    AppLocalizations.of(context)!.compdf_terms_of_service_url),
+                              )),
+                  ])),
+                ],
+              ),
+            )))
+          ],
+        ));
+  }
+
+  Widget head(BuildContext context, String title) {
+    return Container(
+      width: double.infinity,
+      padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
+      color: Theme.of(context).brightness == Brightness.dark
+          ? const Color(0xFF303238)
+          : const Color(0xFFF2F2F2),
+      child: Text(title, style: Theme.of(context).textTheme.bodySmall),
+    );
+  }
+
+  Widget item(BuildContext context, String title,
+      {Widget? trailing, GestureTapCallback? onTap}) {
+    return ListTile(
+        onTap: onTap,
+        title: Text(title, style: Theme.of(context).textTheme.bodyMedium),
+        trailing: trailing ??
+            SvgPicture.asset(
+              'images/ic_syasarrow.svg',
+              color: Theme.of(context).colorScheme.onPrimary,
+            ));
+  }
+}

+ 62 - 0
example/lib/theme/themes.dart

@@ -0,0 +1,62 @@
+///  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 'package:flutter/material.dart';
+
+final ThemeData lightTheme = ThemeData(
+    useMaterial3: true,
+    brightness: Brightness.light,
+    colorScheme: const ColorScheme.light(
+        primary: Color(0xFFFAFCFF),
+        background: Color(0xFFFFFFFF),
+        surface: Color(0xFFFAFCFF),
+        onPrimary: Color(0xFF43474D),
+        onSecondary: Color(0xFF666666)),
+    textTheme: const TextTheme(
+            bodyMedium: TextStyle(),
+            bodyLarge: TextStyle(),
+            bodySmall: TextStyle(),
+            titleMedium: TextStyle())
+        .apply(
+            displayColor: const Color(0xFF43474D),
+            bodyColor: const Color(0xFF43474D)),
+    appBarTheme: const AppBarTheme(
+        elevation: 4.0,
+        titleTextStyle: TextStyle(
+            fontSize: 18,
+            fontWeight: FontWeight.bold,
+            color: Color(0xFF43474D)),
+        backgroundColor: Color(0xFFFAFCFF),
+        foregroundColor: Color(0xFF43474D)),
+    elevatedButtonTheme: ElevatedButtonThemeData(
+        style: ElevatedButton.styleFrom(foregroundColor: Colors.blue)));
+
+final ThemeData darkTheme = ThemeData(
+    useMaterial3: true,
+    brightness: Brightness.dark,
+    scaffoldBackgroundColor: Colors.black,
+    colorScheme: const ColorScheme.dark(
+        primary: Color(0xFF222429),
+        background: Color(0xFF414347),
+        surface: Color(0xFF222429),
+        onPrimary: Colors.white,
+        onSecondary: Colors.white),
+    textTheme: const TextTheme(
+            bodyMedium: TextStyle(),
+            bodyLarge: TextStyle(),
+            bodySmall: TextStyle(),
+            titleMedium: TextStyle())
+        .apply(displayColor: Colors.white, bodyColor: Colors.white),
+    appBarTheme: const AppBarTheme(
+        elevation: 2.0,
+        titleTextStyle: TextStyle(
+            fontSize: 18, fontWeight: FontWeight.bold, color: Colors.white),
+        backgroundColor: Color(0xFF222429),
+        foregroundColor: Colors.white),
+    elevatedButtonTheme: ElevatedButtonThemeData(
+        style: ElevatedButton.styleFrom(foregroundColor: Colors.blue)));

+ 27 - 0
example/lib/utils/file_util.dart

@@ -0,0 +1,27 @@
+///  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/compdfkit.dart';
+import 'package:flutter/material.dart';
+
+Future<File> extractAsset(BuildContext context, String assetPath,
+    {bool shouldOverwrite = true, String prefix = ''}) async {
+  final bytes = await DefaultAssetBundle.of(context).load(assetPath);
+  final list = bytes.buffer.asUint8List();
+
+  final tempDir = await ComPDFKit.getTemporaryDirectory();
+  final tempDocumentPath = '${tempDir.path}/$prefix$assetPath';
+  final file = File(tempDocumentPath);
+
+  if (shouldOverwrite || !file.existsSync()) {
+    await file.create(recursive: true);
+    file.writeAsBytesSync(list);
+  }
+  return file;
+}

+ 204 - 2
example/pubspec.lock

@@ -1,6 +1,14 @@
 # Generated by pub
 # See https://dart.dev/tools/pub/glossary#lockfile
 packages:
+  args:
+    dependency: transitive
+    description:
+      name: args
+      sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
+      url: "https://pub.dev"
+    source: hosted
+    version: "2.4.2"
   async:
     dependency: transitive
     description:
@@ -64,6 +72,14 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "1.3.1"
+  ffi:
+    dependency: transitive
+    description:
+      name: ffi
+      sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878"
+      url: "https://pub.dev"
+    source: hosted
+    version: "2.1.0"
   file:
     dependency: transitive
     description:
@@ -72,6 +88,14 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "6.1.4"
+  file_picker:
+    dependency: "direct main"
+    description:
+      name: file_picker
+      sha256: caa6bc229eab3e32eb2f37b53a5f9d22a6981474afd210c512a7546c1e1a04f6
+      url: "https://pub.dev"
+    source: hosted
+    version: "6.2.0"
   flutter:
     dependency: "direct main"
     description: flutter
@@ -90,21 +114,71 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "2.0.3"
+  flutter_localizations:
+    dependency: "direct main"
+    description: flutter
+    source: sdk
+    version: "0.0.0"
+  flutter_plugin_android_lifecycle:
+    dependency: transitive
+    description:
+      name: flutter_plugin_android_lifecycle
+      sha256: b068ffc46f82a55844acfa4fdbb61fad72fa2aef0905548419d97f0f95c456da
+      url: "https://pub.dev"
+    source: hosted
+    version: "2.0.17"
+  flutter_svg:
+    dependency: "direct main"
+    description:
+      name: flutter_svg
+      sha256: "7b4ca6cf3304575fe9c8ec64813c8d02ee41d2afe60bcfe0678bcb5375d596a2"
+      url: "https://pub.dev"
+    source: hosted
+    version: "2.0.10+1"
   flutter_test:
     dependency: "direct dev"
     description: flutter
     source: sdk
     version: "0.0.0"
+  flutter_web_plugins:
+    dependency: transitive
+    description: flutter
+    source: sdk
+    version: "0.0.0"
   fuchsia_remote_debug_protocol:
     dependency: transitive
     description: flutter
     source: sdk
     version: "0.0.0"
+  http:
+    dependency: transitive
+    description:
+      name: http
+      sha256: a2bbf9d017fcced29139daa8ed2bba4ece450ab222871df93ca9eec6f80c34ba
+      url: "https://pub.dev"
+    source: hosted
+    version: "1.2.0"
+  http_parser:
+    dependency: transitive
+    description:
+      name: http_parser
+      sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
+      url: "https://pub.dev"
+    source: hosted
+    version: "4.0.2"
   integration_test:
     dependency: "direct dev"
     description: flutter
     source: sdk
     version: "0.0.0"
+  intl:
+    dependency: "direct main"
+    description:
+      name: intl
+      sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
+      url: "https://pub.dev"
+    source: hosted
+    version: "0.18.1"
   lints:
     dependency: transitive
     description:
@@ -145,6 +219,22 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "1.8.3"
+  path_parsing:
+    dependency: transitive
+    description:
+      name: path_parsing
+      sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf
+      url: "https://pub.dev"
+    source: hosted
+    version: "1.0.1"
+  petitparser:
+    dependency: transitive
+    description:
+      name: petitparser
+      sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27
+      url: "https://pub.dev"
+    source: hosted
+    version: "6.0.2"
   platform:
     dependency: transitive
     description:
@@ -230,6 +320,102 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "0.6.1"
+  typed_data:
+    dependency: transitive
+    description:
+      name: typed_data
+      sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
+      url: "https://pub.dev"
+    source: hosted
+    version: "1.3.2"
+  url_launcher:
+    dependency: "direct main"
+    description:
+      name: url_launcher
+      sha256: "0ecc004c62fd3ed36a2ffcbe0dd9700aee63bd7532d0b642a488b1ec310f492e"
+      url: "https://pub.dev"
+    source: hosted
+    version: "6.2.5"
+  url_launcher_android:
+    dependency: transitive
+    description:
+      name: url_launcher_android
+      sha256: d4ed0711849dd8e33eb2dd69c25db0d0d3fdc37e0a62e629fe32f57a22db2745
+      url: "https://pub.dev"
+    source: hosted
+    version: "6.3.0"
+  url_launcher_ios:
+    dependency: transitive
+    description:
+      name: url_launcher_ios
+      sha256: "9149d493b075ed740901f3ee844a38a00b33116c7c5c10d7fb27df8987fb51d5"
+      url: "https://pub.dev"
+    source: hosted
+    version: "6.2.5"
+  url_launcher_linux:
+    dependency: transitive
+    description:
+      name: url_launcher_linux
+      sha256: ab360eb661f8879369acac07b6bb3ff09d9471155357da8443fd5d3cf7363811
+      url: "https://pub.dev"
+    source: hosted
+    version: "3.1.1"
+  url_launcher_macos:
+    dependency: transitive
+    description:
+      name: url_launcher_macos
+      sha256: b7244901ea3cf489c5335bdacda07264a6e960b1c1b1a9f91e4bc371d9e68234
+      url: "https://pub.dev"
+    source: hosted
+    version: "3.1.0"
+  url_launcher_platform_interface:
+    dependency: transitive
+    description:
+      name: url_launcher_platform_interface
+      sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029"
+      url: "https://pub.dev"
+    source: hosted
+    version: "2.3.2"
+  url_launcher_web:
+    dependency: transitive
+    description:
+      name: url_launcher_web
+      sha256: fff0932192afeedf63cdd50ecbb1bc825d31aed259f02bb8dba0f3b729a5e88b
+      url: "https://pub.dev"
+    source: hosted
+    version: "2.2.3"
+  url_launcher_windows:
+    dependency: transitive
+    description:
+      name: url_launcher_windows
+      sha256: ecf9725510600aa2bb6d7ddabe16357691b6d2805f66216a97d1b881e21beff7
+      url: "https://pub.dev"
+    source: hosted
+    version: "3.1.1"
+  vector_graphics:
+    dependency: transitive
+    description:
+      name: vector_graphics
+      sha256: "32c3c684e02f9bc0afb0ae0aa653337a2fe022e8ab064bcd7ffda27a74e288e3"
+      url: "https://pub.dev"
+    source: hosted
+    version: "1.1.11+1"
+  vector_graphics_codec:
+    dependency: transitive
+    description:
+      name: vector_graphics_codec
+      sha256: c86987475f162fadff579e7320c7ddda04cd2fdeffbe1129227a85d9ac9e03da
+      url: "https://pub.dev"
+    source: hosted
+    version: "1.1.11+1"
+  vector_graphics_compiler:
+    dependency: transitive
+    description:
+      name: vector_graphics_compiler
+      sha256: "12faff3f73b1741a36ca7e31b292ddeb629af819ca9efe9953b70bd63fc8cd81"
+      url: "https://pub.dev"
+    source: hosted
+    version: "1.1.11+1"
   vector_math:
     dependency: transitive
     description:
@@ -262,6 +448,22 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "3.0.2"
+  win32:
+    dependency: transitive
+    description:
+      name: win32
+      sha256: "464f5674532865248444b4c3daca12bd9bf2d7c47f759ce2617986e7229494a8"
+      url: "https://pub.dev"
+    source: hosted
+    version: "5.2.0"
+  xml:
+    dependency: transitive
+    description:
+      name: xml
+      sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226
+      url: "https://pub.dev"
+    source: hosted
+    version: "6.5.0"
 sdks:
-  dart: ">=3.2.0-194.0.dev <4.0.0"
-  flutter: ">=3.3.0"
+  dart: ">=3.2.3 <4.0.0"
+  flutter: ">=3.16.6"

+ 9 - 0
example/pubspec.yaml

@@ -30,6 +30,13 @@ dependencies:
   # The following adds the Cupertino Icons font to your application.
   # Use with the CupertinoIcons class for iOS style icons.
   cupertino_icons: ^1.0.2
+  flutter_svg: ^2.0.9
+  file_picker: ^6.1.1
+  url_launcher: ^6.2.3
+  flutter_localizations:
+    sdk: flutter
+  intl: any
+
 
 
 dev_dependencies:
@@ -55,8 +62,10 @@ flutter:
   # included with your application, so that you can use the icons in
   # the material Icons class.
   uses-material-design: true
+  generate: true
   assets:
     - pdfs/
+    - images/
   # To add assets to your application, add an assets section, like this:
   # assets:
   #   - images/a_dot_burr.jpeg