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 File',
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);
}
}
Flutter PDF Viewer
ComPDFKit PDF viewer library for Flutter offers flexible PDF viewing within your app. It features an intuitive interface for easy document navigation and gives users a seamless experience with page display modes, PDF navigation, display themes, zooming, text search, text reflow, etc.
Flutter PDF Annotation SDK
Incorporate the ability to add, edit, import, export, and flatten annotations PDF files in your Flutter apps. This powerful annotation library for Flutter allows your users to collaborate by kinds of annotation types like notes, links, free text, shapes, markups, stamps, Ink (pencil), popup, sound, and more.
Flutter Signature SDK
Allow your users to create and add digital signatures and electronic signatures to PDFs directly from your app. This powerful feature supports custom signature styles, saves commonly used signatures for future use, and ensures the authenticity and integrity of documents.
Flutter Document Editor SDK
ComPFKit Flutter document editor library provides complete document editing capabilities, allowing your users to edit documents right within your app. With this SDK, users can add, split, merge, extract, rearrange, remove, rotate, and copy pages.
I googled and reviewed the information on ComPDFKit's official site, their Flutter form package is a perfect match for our invoice management program.
Ahmad Kamel
IT Support Specialist, Insurance