compdfkit_flutter 1.0.0 copy "compdfkit_flutter: ^1.0.0" to clipboard
compdfkit_flutter: ^1.0.0 copied to clipboard

ComPDFKit for Flutter is a comprehensive SDK that allows you to quickly add PDF fuctions to any Flutter application, such as viewer, annotations, editing PDFs, forms and signatures.

example/lib/main.dart

///  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/compdfkit.dart';

import 'package:flutter/material.dart';

const String DOCUMENT_PATH = 'pdfs/PDF_Document.pdf';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    _init();
  }

  void _init() async {
    ComPDFKit.init('your license key', 'your license secret');
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          body: SafeArea(
              child: Center(
        child: ElevatedButton(
            onPressed: () async {
              showDocument(context);
            },
            child: const Text(
              'Open Document',
              style: TextStyle(color: Colors.white),
            )),
      ))),
    );
  }

  void showDocument(BuildContext context) async {
    final bytes = await DefaultAssetBundle.of(context).load(DOCUMENT_PATH);
    final list = bytes.buffer.asUint8List();

    final tempDir = await ComPDFKit.getTemporaryDirectory();
    final tempDocumentPath = '${tempDir.path}/$DOCUMENT_PATH';

    final file = await File(tempDocumentPath).create(recursive: true);
    file.writeAsBytesSync(list);
    ComPDFKit.openDocument(tempDocumentPath);
  }
}
43
likes
0
pub points
63%
popularity

Publisher

verified publishercompdf.com

ComPDFKit for Flutter is a comprehensive SDK that allows you to quickly add PDF fuctions to any Flutter application, such as viewer, annotations, editing PDFs, forms and signatures.

Homepage
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on compdfkit_flutter