CPDFReaderWidgetController class viewer-ui
PDF Reader Widget Controller
Examples:
Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(title: const Text('CPDFReaderWidget Example')),
body: CPDFReaderWidget(
document: widget.documentPath,
configuration: CPDFConfiguration(),
onCreated: (controller) {
setState(() {
_controller = controller;
});
},
));
Constructors
- CPDFReaderWidgetController(int id, {CPDFPageChangedCallback? onPageChanged, CPDFDocumentSaveCallback? saveCallback, CPDFPageEditDialogBackPressCallback? onPageEditBackPress, CPDFFillScreenChangedCallback? onFillScreenChanged, CPDFIOSClickBackPressedCallback? onIOSClickBackPressed, CPDFOnTapMainDocAreaCallback? onTapMainDocArea, CPDFOnCustomToolbarItemTappedCallback? onCustomToolbarItemTapped, CPDFOnAnnotationCreationPreparedCallback? onAnnotationCreationPrepared, CPDFOnCustomContextMenuItemTappedCallback? onCustomContextMenuItemTapped})
Properties
- annotationHistoryManager → CPDFAnnotationHistoryManager
-
Get the annotation history manager
This manager is used to handle annotation history operations such as undo and redo.
Example:
no setter
- document → CPDFDocument
-
no setter
- editManager → CPDFEditManager
-
Get the edit manager
This manager is used to handle content editing operations such as changing edit types.
Example:
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
ready
→ Future<
void> -
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addEventListener(
CPDFEvent event, dynamic callback(dynamic)) → Future< void> -
Add event listener for specific
eventwithcallback. Thecallbackwill be invoked when the specified event occurs, and the event data will be passed as a parameter to the callback function. Example: -
clearDisplayRect(
) → Future< void> - Clear the rectangular area set when jumping to the page number through controller.setDisplayPageIndex Example:
-
dismissContextMenu(
) → Future< void> - Dismiss the context menu if it is currently displayed. Example:
-
dispose(
) → void -
enterSnipMode(
) → Future< void> - Enters snip mode, allowing users to capture screenshots.
-
exitFormCreationMode(
) → Future< void> - Exit form creation mode, equivalent to setting the form creation type to CPDFFormType.unknown This method is only available in CPDFViewMode.forms mode. Example:
-
exitSnipMode(
) → Future< void> - Exits snip mode, stopping the screenshot capture.
-
fetchDefaultAnnotationStyle(
) → Future< CPDFAnnotAttribute> - Retrieves the default annotation style for the CPDFReaderWidget. This method returns a CPDFAnnotAttribute object that contains the default annotation attributes such as color, alpha, and border width. example:
-
fetchDefaultWidgetStyle(
) → Future< CPDFFormAttribute> - Retrieves the default widget (form field) style applied inside the reader widget. Returns the current CPDFFormAttribute describing properties such as color and text appearance for interactive form fields.
-
getAnnotationMode(
) → Future< CPDFAnnotationType> - Get the type of annotation added to the current touch page This method is only available in CPDFViewMode.annotations mode. Example:
-
getCurrentPageIndex(
) → Future< int> - get current page index
-
getFormCreationMode(
) → Future< CPDFFormType> - Get the type of form field added to the current touch page This method is only available in CPDFViewMode.forms mode. Example:
-
getPreviewMode(
) → Future< CPDFViewMode> - Get the currently displayed mode
-
getReadBackgroundColor(
) → Future< Color> - Get background color of reader.
-
getScale(
) → Future< double> - Get the page scale
-
hasChange(
) → Future< bool> - Check the document for modifications
-
hideDigitalSignStatusView(
) → Future< void> - Hide the digital signature status view. This method can be used to hide the digital signature status view that is displayed after calling verifyDigitalSignatureStatus. Example:
-
hideTextSearchView(
) → Future< void> - Hide the text search view if it is currently displayed. Example:
-
isAnnotationsVisible(
) → Future< bool> - check if annotations layer is visible Example:
-
isContinueMode(
) → Future< bool> - Whether it is continuous scroll mode.
-
isCoverPageMode(
) → Future< bool> - Whether it is cover page mode.
-
isCropMode(
) → Future< bool> - Whether it is crop mode.
-
isDoublePageMode(
) → Future< bool> - Whether it is double page mode. is_ example:
-
isFormFieldHighlight(
) → Future< bool> - Whether to display highlight Form Field.
-
isLinkHighlight(
) → Future< bool> - Whether to display highlight Link.
-
isPageInScreen(
int pageIndex) → Future< bool> -
Gets whether the specified
pageIndexis displayed on the screen -
isVerticalMode(
) → Future< bool> - Whether it is vertical scroll mode.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
prepareNextImage(
String imagePath) → Future< void> - Pre-configure the next image annotation to be inserted when the user taps the page. Example:
-
prepareNextSignature(
String signaturePath) → Future< void> - Pre-configure the next signature annotation to be inserted when the user taps the page. only use in signature creation mode. CPDFAnnotationType.signature Example:
-
prepareNextStamp(
{String? imagePath, CPDFStandardStamp? standardStamp, CPDFTextStamp? textStamp}) → Future< void> - Pre-configure the next stamp annotation to be inserted when the user taps the page.
-
reloadPages(
) → Future< void> -
reloadPages2(
) → Future< void> -
save(
) → Future< bool> - Save document
-
saveCurrentInk(
) → Future< void> - Save the currently drawing ink annotation Example:
-
saveCurrentPencil(
) → Future< void> - Save the currently drawing pencil annotation This method is only available on the iOS platform. Example:
-
setAnnotationMode(
CPDFAnnotationType type) → Future< void> - Used to add a specified annotation type when touching the page in annotation mode This method is only available in CPDFViewMode.annotations mode. Example:
-
setAnnotationsVisible(
bool visible) → Future< void> - show or hide annotations layer Example:
-
setCanScale(
bool canScale) → Future< void> - Whether allow to scale. Default : true
-
setContinueMode(
bool isContinueMode) → Future< void> - Sets whether it is continuous scroll mode.
-
setCoverPageMode(
bool coverPageMode) → Future< void> - Sets whether it is cover page mode.
-
setCropMode(
bool isCropMode) → Future< void> - Sets whether it is crop mode.
-
setDisplayPageIndex(
{required int pageIndex, bool animated = true, List< CPDFRectF> rectList = const []}) → Future<void> - Jump to the index page.
-
setDoublePageMode(
bool isDoublePageMode) → Future< void> - Sets whether it is double page mode.
-
setFixedScroll(
bool isFixedScroll) → Future< void> - Sets whether to fix the position of the non-swipe direction when zooming in for reading.
-
setFormCreationMode(
CPDFFormType type) → Future< void> - Used to add a specified form field type when touching the page in form creation mode This method is only available in CPDFViewMode.forms mode. Example:
-
setFormFieldHighlight(
bool isFormFieldHighlight) → Future< void> -
Sets whether to display highlight Form Field.
isFormFieldHighlight: true to display highlight Form Field. -
setLinkHighlight(
bool isLinkHighlight) → Future< void> - Sets whether to display highlight Link.
-
setMargins(
CPDFEdgeInsets edgeInsets) → Future< void> - Set document page spacing
-
setPageSameWidth(
bool isSame) → Future< void> - In the single page mode, set whether all pages keep the same width and the original page keeps the same width as readerView
-
setPageSpacing(
int spacing) → Future< void> - Sets the spacing between pages. This method is supported only on Android.
-
setPreviewMode(
CPDFViewMode viewMode) → Future< void> - Switch the mode displayed by the current CPDFReaderWidget. Please see CPDFViewMode for available modes.
-
setReadBackgroundColor(
CPDFThemes theme) → Future< void> -
Sets background color of reader.
The color of each document space will be set to 75% of
colortransparency -
setScale(
double scale) → Future< void> - Set the page scale Value Range: 1.0~5.0
-
setVerticalMode(
bool isVerticalMode) → Future< void> - Sets whether it is vertical scroll mode.
-
setWidgetBackgroundColor(
Color color) → Future< void> -
showAddWatermarkView(
{CPDFWatermarkConfig? config}) → Future< void> - Displays the Add Watermark view, allowing users to add text and/or image watermarks to the current document.
-
showAnnotationPropertiesView(
CPDFAnnotation annotation) → Future< void> - Displays the properties panel for the specified annotation. Only some annotation types are supported. If an unsupported type is passed in (such as eraser, unknown, signature, stamp, sound, image, link, etc.), an exception will be thrown.
-
showBotaView(
) → Future< void> - Displays the BOTA view, which includes the document outline, bookmarks, and annotation list.
-
showDefaultAnnotationPropertiesView(
CPDFAnnotationType type) → Future< void> - Displays the default properties panel for the specified annotation type.
-
showDisplaySettingView(
) → Future< void> - Displays the display settings view, where users can configure options such as scroll direction, scroll mode, and themes.
-
showEditAreaPropertiesView(
CPDFEditArea editArea) → Future< void> - Displays the properties panel for the specified edit area. Only some edit area types are supported. If an unsupported type is passed in (such as path type), an exception will be thrown.
-
showSecurityView(
) → Future< void> - Displays the document security settings view, allowing users to configure document security options.
-
showTextSearchView(
) → Future< void> - Show the text search view. Example:
-
showThumbnailView(
bool editMode) → Future< void> -
Displays the thumbnail view. When
editModeistrue, the page enters edit mode, allowing operations such as insert, delete, extract, etc. -
showWidgetPropertiesView(
CPDFWidget widget) → Future< void> - Displays the properties panel for the specified form field widget. Only some form field types are supported. If an unsupported type is passed in (such as signature fields, unknown, etc.), an exception will be thrown.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateDefaultAnnotationStyle(
CPDFAnnotAttrBase annotationStyle) → Future< void> - Sets the default annotation style for the CPDFReaderWidget. This method allows you to customize the default attributes for annotations such as color, alpha, and border width. example:
-
updateDefaultWidgetStyle(
CPDFAnnotAttrBase widgetStyle) → Future< void> - Persists a new default widget style so subsequent form field creations share consistent appearance characteristics.
-
verifyDigitalSignatureStatus(
) → Future< void> - Verify the status of the digital signature in the document and display the verification result on the screen. If the document contains a digital signature, a status view will be displayed at the top of the document indicating the verification result. If the document does not contain a digital signature, no status view will be displayed. Example:
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited