Used to add a specified annotation type when touching the page in annotation mode This method is only available in [CPDFViewMode.ANNOTATIONS] mode.
The type of annotation mode to set.
A promise that resolves when the operation completes.
Get the type of annotation added to the current touch page. This method is only available in [CPDFViewMode.ANNOTATIONS] mode.
A promise that resolves to the current annotation mode.
Displays the default properties panel for the specified annotation type.
Only some annotation types are supported. Please refer to the documentation for the list of supported types.
The type of annotation for which to display the properties panel.
A promise that resolves when the operation completes.
Displays the properties panel for the specified annotation.
Only some annotation types are supported. Please refer to the documentation for the list of supported types.
The annotation for which to display the properties panel.
A promise that resolves when the operation completes.
Pre-configures the next stamp annotation to be inserted when the user taps on the page.
An object containing exactly one of the following properties:
imagePath Path to an image stamp.
Android: file path or drawable resource name
iOS: file path or bundled image name
standardStamp
Built-in standard stamp enum value (for example, CPDFStandardStamp.Approved).
textStamp
A CPDFTextStamp instance that defines custom text, colors, font size, and other properties.
A promise that resolves when the operation completes.
A Promise<void> that resolves when the native side has been notified.
Call this method after entering stamp creation mode to specify which type of stamp (image / standard / text) should be inserted on the next tap.
Exactly one of imagePath, standardStamp, or textStamp must be provided.
Providing none or more than one will result in an error.
Throws an Error if the "exactly one parameter" rule is violated.
The error message is in English.
// Prepares an image stamp for the next tap
await pdfReaderRef.current?.prepareNextStamp({ imagePath: '/path/to/stamp.png' });
// Prepares a standard "Approved" stamp for the next tap
await pdfReaderRef.current?.prepareNextStamp({standardStamp: CPDFStandardStamp.Approved});
// Prepares a custom text stamp for the next tap
await pdfReaderRef.current?.prepareNextStamp({
textStamp: {
content: "ComPDFKit",
date: CPDFDateUtil.getTextStampDate({
timeSwitch: true,
dateSwitch: true,
}),
color: CPDFTextStampColor.blue,
shape: CPDFTextStampShape.leftTriangle,
},
});
Fetches the default annotation style. Use this after the CPDFReaderView is initialized to retrieve the current default annotation style.
The current default annotation style; returns an empty object if the native view is unavailable.
Updates the default annotation style. When updating annotation styles, you can pass only the properties that need to be modified, and other properties will remain unchanged. All HexColor values are normalized to ARGB before being sent to native.
The annotation attributes to update.
A promise that resolves when the operation completes.
Displays the properties panel for the specified edit area. support:
The edit area for which to display the properties panel.
A promise that resolves when the operation completes.
Path of the XFDF file to be imported.
true if the import is successful; otherwise, false.
Use _pdfDocument.importAnnotations() instead.
Imports annotations from the specified XFDF file into the current PDF document.
// Android - assets file
const testXfdf = 'file:///android_asset/test.xfdf';
const importResult = await pdfReaderRef.current?.importAnnotations(testXfdf);
// Android - file path
const testXfdf = '/data/user/0/com.compdfkit.reactnative.example/xxx/xxx.xfdf';
const importResult = await pdfReaderRef.current?.importAnnotations(testXfdf);
// Android - Uri
const xfdfUri = 'content://xxxx'
const importResult = await pdfReaderRef.current?.importAnnotations(xfdfUri);
// iOS
The path of the XFDF file if export is successful; an empty string if the export fails.
Displays the "Add Watermark" view, where users can add watermarks to the document.
Optionalconfig: CPDFWatermarkConfigA promise that resolves when the operation completes.
Returns a Promise indicating if the document has been modified.
true: The document has been modified,
false: The document has not been modified.
If the native view reference cannot be found, a rejected Promise will be returned.
Reloads all pages in the readerview.
A promise that resolves when the operation completes.
Reloads all pages while preserving the current reading position.
On Android, this keeps the current viewport anchored to the same visual position
after the refresh. For example, if the viewer is currently showing page 2 at about
20% scroll progress, the same position remains visible after reloading.
On iOS, this falls back to reloadPages() because the native implementation does
not expose a position-preserving reload path.
A promise that resolves when the operation completes.
Register an event listener for a specific event with type-safe callbacks.
The event type to listen for
The callback function with typed event data
// Annotation created event - returns CPDFAnnotation
pdfReaderRef.current?.addEventListener(CPDFEvent.ANNOTATIONS_CREATED, (annotation) => {
console.log('Annotation created:', annotation.type);
});
// Form field selected event - returns CPDFWidget
pdfReaderRef.current?.addEventListener(CPDFEvent.FORM_FIELDS_SELECTED, (widget) => {
console.log('Form field selected:', widget.type);
});
// Editor selection - returns CPDFEditArea | null
pdfReaderRef.current?.addEventListener(CPDFEvent.EDITOR_SELECTION_DESELECTED, (editArea) => {
if (editArea) {
console.log('Edit area deselected');
}
});
Remove an event listener for a specific event.
The event type to stop listening for
The callback function to remove
set current form creation mode. This method is only available in [CPDFViewMode.FORMS] mode.
The type of form field to create.
A promise that resolves when the operation completes.
get current form creation mode. This method is only available in [CPDFViewMode.FORMS] mode.
get current form creation mode.
Displays the properties panel for the specified form field widget.
Only some widget types are supported. Please refer to the documentation for the list of supported types.
The form widget whose properties or appearance will be updated.
A promise that resolves when the operation completes.
Fetches the default widget style.
The current default widget style; returns an empty object if the native view is unavailable.
Updates the default widget style. When updating form fields, you can pass only the properties that need to be modified, and other properties will remain unchanged. All HexColor values are normalized to ARGB before being sent to native.
The widget attributes to update.
A promise that resolves when the default widget style is updated.
Pre-configure the next signature annotation to be inserted when the user taps the page. only use in signature creation mode. [CPDFAnnotationType.signature]
// first enter signature creation mode await controller.setAnnotationMode(CPDFAnnotationType.signature);
// then prepare the signature image path await controller.prepareNextSignature('/path/to/signature.png');
// now, when the user taps the page, the signature will be inserted using the specified image
@param signaturePath The local path of the signature image to insert.
@returns A promise that resolves when the operation completes.
@group Digital
Pre-configure the next image annotation to be inserted when the user taps the page.
The path of the image to be used for the next image annotation.
// first enter image creation mode await pdfReaderRef.current?.setAnnotationMode(CPDFAnnotationType.PICTURES);
// then prepare the image path await pdfReaderRef.current?.prepareNextImage('/path/to/image.png');
// now, when the user taps the page, the image annotation will be inserted using the specified image
@returns A promise that resolves when the operation completes.
@group
Jump to the index page.
A promise that resolves when the operation completes.
Displays the thumbnail view. When [editMode] is true,
the page enters edit mode, allowing operations such as insert, delete, extract, etc.
Whether to enable edit mode
A promise that resolves when the operation completes.
Set the reading area spacing.
The left reading-area margin.
The top reading-area margin.
The right reading-area margin.
The bottom reading-area margin.
A promise that resolves when the operation completes.
Sets background color of reader. The color of each document space will be set to 75% of [color] transparency
The reading background theme to apply.
A promise that resolves when the operation completes.
Sets the spacing between pages. This method is supported only on the [Android] platform.
The space between pages, in pixels.
A promise that resolves when the operation completes.
In the single page mode, set whether all pages keep the same width and the original page keeps the same width as readerView.
true: All pages keep the same width, the original state keeps the same width as readerView; false: Show in the actual width of page
A promise that resolves when the operation completes.
Gets whether the specified [pageIndex] is displayed on the screen
The zero-based page index to check.
A promise that resolves to whether the specified page is currently visible.
Switch the mode displayed by the current CPDFReaderWidget. Please see [CPDFViewMode] for available modes.
The view mode to display
A promise that resolves when the operation completes.
Get the currently displayed mode.
A promise that resolves to the current view mode.
Native PDF reader component for viewing and editing a document.
Since
3.0.0
Remarks
Supported on Android and iOS. Platform-specific methods document their limitations.