PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
ComPDF SDK for Flutter offers multiple ways to open PDF documents depending on your use case:
CPDFReaderWidget to display an embedded reader UI.ComPDFKit.openDocument() to quickly launch a full-screen document viewer.CPDFDocument for background processing or non-UI operations.Using CPDFReaderWidget (Recommended for embedded reader scenarios)
const String _documentPath = 'pdfs/PDF_Document.pdf';
File document = await CPDFFileUtil.extractAsset(_documentPath, shouldOverwrite: false);
Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(),
body: CPDFReaderWidget(
document: document.path,
configuration: CPDFConfiguration(),
onCreated: (controller) {
},))Using ComPDFKit.openDocument() (Quick full-screen viewer)
This is ideal for quickly launching a standalone document viewer.
const String _documentPath = 'pdfs/PDF_Document.pdf';
File document = await CPDFFileUtil.extractAsset(_documentPath);
ComPDFKit.openDocument(document.path, password: '', configuration: CPDFConfiguration());Using CPDFDocument (For background or logic-only use cases)
This is useful for non-UI operations such as annotation management, import/export, etc.
const String _documentPath = 'pdfs/PDF_Document.pdf';
File document = await CPDFFileUtil.extractAsset(context, _documentPath);
// Create and open the document
CPDFDocument document = await CPDFDocument.createInstance();
CPDFDocumentError error = await document.open(document.path);
if (error == CPDFDocumentError.success) {
// Perform operations with the CPDFDocument instance...
}