Skip to content
ComPDF
DemoFAQ
New Release

Open-Source PDF SDK & AI Document Processing

Get the full self-hosted SDK and AI document processing on GitHub. One-click deploy to quickly build your document workflows.

Guides

Viewer

The ComPDF Flutter SDK provides reader-level callbacks through CPDFReaderWidget. Use these callbacks for viewer lifecycle and UI events.

Available Callbacks

CallbackTrigger TimingPayload
onPageChangedCurrent page changesint pageIndex
onSaveCallbackDocument save completesNo payload
onFillScreenChangedFullscreen state changesbool isFullScreen
onTapMainDocAreaCallbackUser taps the main PDF page areaNo payload
onPageEditDialogBackPressUser taps the back button in the page edit dialogNo payload
onIOSClickBackPressediOS top-left reader back button is tappedNo payload
onSearchBackButtonTappedCallbackUser taps the back button in the search viewNo payload
onAddWatermarkDialogDismissedCallbackAdd watermark dialog is dismissedNo payload

Example Usage

dart
CPDFReaderWidget(
  document: documentPath,
  configuration: configuration,
  onCreated: (controller) {
    // Store the controller if listener events are needed later.
  },
  onPageChanged: (int pageIndex) {
    debugPrint('Current page: $pageIndex');
  },
  onSaveCallback: () {
    debugPrint('Document saved successfully');
  },
  onFillScreenChanged: (bool isFullScreen) {
    debugPrint('Is full screen: $isFullScreen');
  },
  onTapMainDocAreaCallback: () {
    debugPrint('Main document area tapped');
  },
  onPageEditDialogBackPress: () {
    debugPrint('Back button pressed in page edit dialog');
  },
  onIOSClickBackPressed: () {
    debugPrint('iOS back button pressed');
  },
  onSearchBackButtonTappedCallback: () {
    debugPrint('Search back button tapped');
  },
  onAddWatermarkDialogDismissedCallback: () {
    debugPrint('Add watermark dialog dismissed');
  },
);

Note

  • onSearchBackButtonTappedCallback is useful when you manage search state on the Flutter side.
  • onAddWatermarkDialogDismissedCallback fires after the add watermark panel closes. Use it to restore custom UI state or refresh watermark-related controls.