Kaynağa Gözat

compdfkit(rn) - 更新api文档,优化示例

liuxiaolong 1 ay önce
ebeveyn
işleme
41610173fc

+ 677 - 0
API.md

@@ -209,6 +209,52 @@ Returns a Promise.
 ComPDFKit.removeSignFileList();
 ```
 
+### pickFile
+
+Opens the system file picker to select a PDF document.
+
+Returns a Promise.
+
+| Name   | Type   | Description           |
+| ------ | ------ | --------------------- |
+| result | string | 返回选择的PDF文件路径 |
+
+```tsx
+String? path = ComPDFKit.pickFile();
+```
+
+### setImportFontDir
+
+Imports font files to support displaying additional languages. 
+mported fonts will appear in the font list for FreeText annotations and text editing.
+
+**Note:** Fonts must be imported before initializing the SDK.
+
+
+steps to import fonts:
+1. Copy the fonts you want to import into a custom folder.
+2. Call `setImportFontDir` with the folder path as a parameter.
+3. Initialize the SDK using `ComPDFKit.init_`.
+
+Parameters:
+
+| Name       | Type   | Description                                             |
+| ---------- | ------ | ------------------------------------------------------- |
+| fontDir    | string | The path to the folder containing font files to import. |
+| addSysFont | string | Whether to include system fonts in the font list.       |
+
+Returns a Promise.
+
+| Name   | Type | Description  |
+| ------ | ---- | ------------ |
+| result | bool | 是否设置成功 |
+
+```tsx
+// Set the font directory
+ComPDFKit.setImportFontDir('fontdir', true);
+// Initialize the ComPDFKit SDK
+ComPDFKit.init_('your license key');
+```
 
 
 ## CPDFReaderView - Props
@@ -289,6 +335,27 @@ Used to pass configuration parameters when rendering a PDF file to customize UI
 
 ### Document
 
+#### open
+
+Reopens a specified document in the current `CPDFReaderView` component.
+
+Parameters:
+
+| Name     | Type   | Description                                                |
+| -------- | ------ | ---------------------------------------------------------- |
+| document | string | The file path of the PDF document.                         |
+| password | string | The password for the document, which can be null or empty. |
+
+Returns a Promise.
+
+| Name   | Type | Description                                                  |
+| ------ | ---- | ------------------------------------------------------------ |
+| result | bool | A promise that resolves to `true` if the document is successfully opened, otherwise `false`. |
+
+```tsx
+await pdfReaderRef.current?._pdfDocument.open(document, 'password');
+```
+
 #### hasChange
 Checks whether the document has been modified.
 
@@ -338,6 +405,35 @@ Parameters:
 	/>
 ```
 
+#### getFileName
+Gets the file name of the PDF document.
+
+Returns a Promise.
+
+| Name   | Type   | Description                             |
+| ------ | ------ | --------------------------------------- |
+| result | string | Gets the file name of the PDF document. |
+
+```tsx
+const fileName = await pdfReaderRef.current?._pdfDocument.getFileName();
+```
+
+#### isImageDoc
+
+Checks if the PDF document is an image document. This is a time-consuming operation that depends on the document size.
+
+Returns a Promise.
+
+| Name   | Type    | Description                                                  |
+| ------ | ------- | ------------------------------------------------------------ |
+| result | boolean | Return `true` if the document is a scanned image document, otherwise return `false`. |
+
+```tsx
+const isImageDoc = await pdfReaderRef.current?._pdfDocument.isImageDoc();
+```
+
+
+
 ### Viewer
 
 #### setMargins
@@ -357,7 +453,442 @@ Parameters:
 await pdfReaderRef.current?.setMargins(10,10,10,10);
 ```
 
+#### setPageSpacing
+
+Sets the spacing between pages. This method is supported only on the `Android` platform.
+
+- For the `iOS` platform, use the `setMargins`method instead.The spacing between pages is equal to the value of `CPDFEdgeInsets.top`.
+
+Parameters:
+
+| Name        | Type | Description                         |
+| ----------- | ---- | ----------------------------------- |
+| pageSpacing | int  | The space between pages, in pixels. |
+
+```tsx
+await pdfReaderRef.current?.setPageSpacing(10);
+```
+
+> Note: This method only supports the Android platform.
+
+#### setScale
+
+Set the page scale, Value Range: **1.0~5.0**
+
+Parameters:
+
+| Name  | Type   | Description |
+| ----- | ------ | ----------- |
+| scale | number | scale value |
+
+```tsx
+await pdfReaderRef.current?.setScale(2.0);
+```
+
+#### getScale
+
+Get the current page scale
+
+Returns a Promise.
+
+| Name   | Type   | Description                                 |
+| ------ | ------ | ------------------------------------------- |
+| result | number | Returns the zoom ratio of the current page. |
+
+```tsx
+const scale = await pdfReaderRef.current?.getScale();
+```
+
+#### setCanScale
+
+Whether allow to scale.
+
+Parameters:
+
+| Name     | Type    | Description |
+| -------- | ------- | ----------- |
+| canScale | boolean | scale value |
+
+
+```tsx
+await pdfReaderRef.current?.setCanScale(false);
+```
+
+> Note: This method only supports the Android platform.
+
+#### setReadBackgroundColor
+
+Sets background color of reader.
+
+Parameters:
+
+| Name  | Type       | Description |
+| ----- | ---------- | ----------- |
+| theme | CPDFThemes |             |
+
+
+```tsx
+await pdfReaderRef.current?.setReadBackgroundColor(CPDFThemes.LIGHT);
+```
+
+**Explanation of Themes**
+
+| Mode   | Description                                                  | Option Values     |
+| ------ | ------------------------------------------------------------ | ----------------- |
+| LIGHT  | Uses a white background and black text, suitable for reading in well-lit environments. | CPDFThemes.LIGHT  |
+| DARK   | Uses a dark background and light text, suitable for reading in low-light environments. | CPDFThemes.DARK   |
+| SEPIA  | Use a beige background for users who are used to reading on paper. | CPDFThemes.SEPIA  |
+| RESEDA | Soft light green background reduces discomfort from high brightness and strong contrast when reading, effectively relieving visual fatigue. | CPDFThemes.RESEDA |
+
+#### getReadBackgroundColor
+
+Get background color of reader.
+
+Returns a Promise.
+
+| Name   | Type       | Description |
+| ------ | ---------- | ----------- |
+| result | CPDFThemes |             |
+
+```tsx
+CPDFThemes theme = await pdfReaderRef.current?.getReadBackgroundColor();
+```
+
+#### setFormFieldHighlight
+
+Sets whether to display highlight Form Field.
+
+Parameters:
+
+| Name                 | Type    | Description                           |
+| -------------------- | ------- | ------------------------------------- |
+| isFormFieldHighlight | boolean | true to display highlight Form Field. |
+
+```tsx
+await pdfReaderRef.current?.setFormFieldHighlight(true);
+```
+
+#### isFormFieldHighlight
+
+Whether to display highlight Form Field.
+
+Returns a Promise.
+
+| Name   | Type    | Description        |
+| ------ | ------- | ------------------ |
+| result | boolean | 当前是否高亮表单域 |
+
+```tsx
+const isFormFieldHighlight = await pdfReaderRef.current?.isFormFieldHighlight();
+```
+
+#### setLinkHighlight
+
+Sets whether to display highlight Link.
+
+Parameters:
+
+| Name            | Type    | Description                |
+| --------------- | ------- | -------------------------- |
+| isLinkHighlight | boolean | Whether to highlight Link. |
+
+```tsx
+await pdfReaderRef.current?.setLinkHighlight(true);
+```
+
+#### isLinkHighlight
 
+Whether to display highlight Link.
+
+Returns a Promise.
+
+| Name   | Type    | Description |
+| ------ | ------- | ----------- |
+| result | boolean |             |
+
+```tsx
+const isLinkHighlight = await pdfReaderRef.current?.isLinkHighlight();
+```
+
+#### setVerticalMode
+
+Sets whether it is vertical scroll mode.
+
+Parameters:
+
+| Name           | Type    | Description                         |
+| -------------- | ------- | ----------------------------------- |
+| isVerticalMode | boolean | Whether it is vertical scroll mode. |
+
+```tsx
+await pdfReaderRef.current?.setVerticalMode(true);
+```
+
+#### isVerticalMode
+
+Whether it is vertical scroll mode.
+
+Returns a Promise.
+
+| Name   | Type    | Description                                                  |
+| ------ | ------- | ------------------------------------------------------------ |
+| result | boolean | Returns `true` for vertical scrolling and `false` for horizontal scrolling |
+
+```tsx
+await pdfReaderRef.current?.isVerticalMode();
+```
+
+#### setContinueMode
+
+Sets whether it is continuous scroll mode.
+
+Parameters:
+
+| Name           | Type    | Description                           |
+| -------------- | ------- | ------------------------------------- |
+| isContinueMode | boolean | Whether it is continuous scroll mode. |
+
+```tsx
+await pdfReaderRef.current?.setContinueMode(true);
+```
+
+#### isContinueMode
+
+Whether it is continuous scroll mode.
+
+Returns a Promise.
+
+| Name   | Type    | Description                                                  |
+| ------ | ------- | ------------------------------------------------------------ |
+| result | boolean | Returns `true` if the page is scrolled continuously, otherwise returns `false` |
+
+```tsx
+await pdfReaderRef.current?.isContinueMode();
+```
+
+#### setDoublePageMode
+
+Sets whether it is double page mode.
+
+Parameters:
+
+| Name             | Type    | Description                     |
+| ---------------- | ------- | ------------------------------- |
+| isDoublePageMode | boolean | Whether it is double page mode. |
+
+```tsx
+await pdfReaderRef.current?.setDoublePageMode(true);
+```
+
+#### isDoublePageMode
+
+Whether it is double page mode.
+
+Returns a Promise.
+
+| Name   | Type    | Description                                                  |
+| ------ | ------- | ------------------------------------------------------------ |
+| result | boolean | Returns `true` if double page display is enabled, otherwise returns `false` |
+
+```tsx
+await pdfReaderRef.current?.isDoublePageMode();
+```
+
+```tsx
+await pdfReaderRef.current?.isContinueMode();
+```
+
+#### setCoverPageMode
+
+Sets whether it is cover page mode.
+
+Parameters:
+
+| Name            | Type    | Description                                   |
+| --------------- | ------- | --------------------------------------------- |
+| isCoverPageMode | boolean | Whether to display the document in cover form |
+
+```tsx
+await pdfReaderRef.current?.setCoverPageMode(true);
+```
+
+#### isCoverPageMode
+
+Whether it is cover page mode.
+
+Returns a Promise.
+
+| Name   | Type    | Description                                                  |
+| ------ | ------- | ------------------------------------------------------------ |
+| result | boolean | Returns `true` if the document cover is displayed, otherwise returns `false` |
+
+```tsx
+await pdfReaderRef.current?.isCoverPageMode();
+```
+
+#### setCropMode
+
+Sets whether it is crop mode.
+
+Parameters:
+
+| Name       | Type    | Description              |
+| ---------- | ------- | ------------------------ |
+| isCropMode | boolean | Whether it is crop mode. |
+
+```tsx
+await pdfReaderRef.current?.setCropMode(true);
+```
+
+#### isCropMode
+
+Whether it is cover page mode.
+
+Returns a Promise.
+
+| Name   | Type    | Description                                                  |
+| ------ | ------- | ------------------------------------------------------------ |
+| result | boolean | Returns `true` if the current mode is clipping mode, otherwise returns `false` |
+
+```tsx
+await pdfReaderRef.current?.isCropMode();
+```
+
+#### setPageSameWidth
+
+In the single page mode, set whether all pages keep the same width and the original page keeps the same width as readerView.
+
+Parameters:
+
+| Name            | Type    | Description                                                  |
+| --------------- | ------- | ------------------------------------------------------------ |
+| isPageSameWidth | boolean | true: All pages keep the same width, the original state keeps the same width as readerView; false: Show in the actual width of page |
+
+```tsx
+await pdfReaderRef.current?.setPageSameWidth(true);
+```
+
+> Note: This method only supports the Android platform.
+
+#### isPageInScreen
+
+Gets whether the specified `pageIndex` is displayed on the screen
+
+Parameters:
+
+| Name      | Type | Description |
+| --------- | ---- | ----------- |
+| pageIndex | int  | page index  |
+
+```tsx
+const isPageInScreen = await pdfReaderRef.current?.isPageInScreen(1);
+```
+
+> Note: This method only supports the Android platform.
+
+#### setFixedScroll
+
+Sets whether to fix the position of the non-swipe direction when zooming in for reading.
+
+Parameters:
+
+| Name          | Type    | Description              |
+| ------------- | ------- | ------------------------ |
+| isFixedScroll | boolean | Whether to fix scrolling |
+
+```tsx
+await pdfReaderRef.current?.setFixedScroll(true);
+```
+
+> Note: This method only supports the Android platform.
+
+#### setPreviewMode
+
+Switch the mode displayed by the current CPDFReaderWidget.
+
+Parameters:
+
+| Name     | Type         | Description              |
+| -------- | ------------ | ------------------------ |
+| viewMode | CPDFViewMode | The view mode to display |
+
+```tsx
+await pdfReaderRef.current?.setPreviewMode(CPDFViewMode.VIEWER);
+```
+
+#### getPreviewMode
+
+Get the currently displayed mode.
+
+Returns a Promise.
+
+| Name     | Type         | Description                               |
+| -------- | ------------ | ----------------------------------------- |
+| viewMode | CPDFViewMode | Returns the currently displayed view mode |
+
+```tsx
+const mode = await pdfReaderRef.current?.getPreviewMode();
+```
+
+#### showThumbnailView
+
+Displays the thumbnail view. When [editMode] is `true`,  the page enters edit mode, allowing operations such as insert, delete, extract, etc.
+
+Returns a Promise.
+
+| Name     | Type    | Description                 |
+| -------- | ------- | --------------------------- |
+| editMode | boolean | Whether to enable edit mode |
+
+```tsx
+await pdfReaderRef.current?.showThumbnailView(true);
+```
+
+#### showBotaView
+Displays the BOTA view, which includes the document outline, bookmarks, and annotation list.
+```tsx
+await pdfReaderRef.current?.showBotaView();
+```
+
+#### showAddWatermarkView
+
+Displays the BOTA view, which includes the document outline, bookmarks, and annotation list.
+
+```tsx
+await pdfReaderRef.current?.showAddWatermarkView();
+```
+
+#### showSecurityView
+
+Displays the document security settings view, allowing users to configure document security options.
+
+```tsx
+await pdfReaderRef.current?.showSecurityView();
+```
+
+#### showDisplaySettingView
+
+Displays the display settings view, where users can configure options such as scroll direction, scroll mode, and themes.
+
+```tsx
+await pdfReaderRef.current?.showDisplaySettingView();
+```
+
+#### enterSnipMode
+
+Enters snip mode, allowing users to capture screenshots.
+
+```tsx
+await pdfReaderRef.current?.enterSnipMode();
+```
+
+#### exitSnipMode
+
+Enters snip mode, allowing users to capture screenshots.
+
+```tsx
+await pdfReaderRef.current?.exitSnipMode();
+```
 
 ### Page
 
@@ -410,6 +941,24 @@ Parameters:
   />
 ```
 
+#### getPageCount
+
+Get the total number of pages in the current document
+
+Returns a Promise.
+
+Promise Parameters:
+
+| Name  | Type | Description                                           |
+| ----- | ---- | ----------------------------------------------------- |
+| count | int  | Get the total number of pages in the current document |
+
+```tsx
+const pageCount = await pdfReaderRef.current?._pdfDocument.getPageCount();
+```
+
+#### 
+
 ### Annotations
 
 #### import Annotations
@@ -465,3 +1014,131 @@ Promise Parameters:
 const removeResult = await pdfReaderRef.current?.removeAllAnnotations();
 ```
 
+### Security
+
+#### isEncrypted
+
+Checks if the PDF document is encrypted.
+
+Returns a Promise.
+
+| Name   | Type    | Description        |
+| ------ | ------- | ------------------ |
+| result | boolean | 当前文档是否已加密 |
+
+```tsx
+const isEncrypted = await pdfReaderRef.current?._pdfDocument.isEncrypted();
+```
+
+#### getPermissions
+
+Gets the current document's permissions.
+
+There are three types of permissions:
+
+No restrictions: `CPDFDocumentPermissions.NONE`If the document has an open password and an owner password,using the open password will grant `CPDFDocumentPermissions.USER` permissions, and using the owner password will grant `CPDFDocumentPermissions.OWNER` permissions.
+
+Returns a Promise.
+
+| Name   | Type                    | Description                              |
+| ------ | ----------------------- | ---------------------------------------- |
+| result | CPDFDocumentPermissions | Gets the current document's permissions. |
+
+```tsx
+const permissions = await pdfReaderRef.current?._pdfDocument.getPermissions();
+```
+
+#### checkOwnerUnlocked
+
+Check if owner permissions are unlocked
+
+Returns a Promise.
+
+| Name   | Type    | Description |
+| ------ | ------- | ----------- |
+| result | boolean |             |
+
+```tsx
+const unlocked = await pdfReaderRef.current?._pdfDocument.checkOwnerUnlocked();
+```
+
+#### checkOwnerPassword
+
+Whether the owner password is correct. If the password is correct, the document will be unlocked with full owner permissions.
+
+Parameters:
+
+| Name     | Type   | Description                                 |
+| -------- | ------ | ------------------------------------------- |
+| password | string | password The owner password to be verified. |
+
+Returns a Promise.
+
+| Name   | Type    | Description                                                  |
+| ------ | ------- | ------------------------------------------------------------ |
+| result | boolean | A promise that resolves to `true` if the owner password is correct, otherwise `false`. |
+
+```tsx
+const check = await pdfReaderRef.current?._pdfDocument.checkOwnerPassword('ownerPassword');
+```
+
+#### setPassword
+
+This method sets the document password, including the user password for access restrictions and the owner password for granting permissions.
+
+- To enable permissions like printing or copying, the owner password must be set; otherwise, the settings will not take effect.
+
+Parameters:
+
+| Name           | Type                    | Description                                                  |
+| -------------- | ----------------------- | ------------------------------------------------------------ |
+| userPassword   | string                  | The user password for document access restrictions.          |
+| ownerPassword  | string                  | The owner password to grant permissions (e.g., printing, copying). |
+| allowsPrinting | boolean                 | Whether printing is allowed (true or false).                 |
+| allowsCopying  | boolean                 | Whether copying is allowed (true or false).                  |
+| encryptAlgo    | CPDFDocumentEncryptAlgo | The encryption algorithm to use (e.g., `CPDFDocumentEncryptAlgo.rc4`). |
+
+Returns a Promise.
+
+| Name   | Type    | Description                                                  |
+| ------ | ------- | ------------------------------------------------------------ |
+| result | boolean | A promise that resolves to `true` if the password is successfully set, otherwise `false`. |
+
+```tsx
+const success = await pdfReaderRef.current?._pdfDocument.setPassword(
+  'user_password',
+  'owner_password',
+  false,
+  false,
+  CPDFDocumentEncryptAlgo.rc4
+);
+```
+
+#### removePassword
+
+Remove the user password and owner permission password. set in the document, and perform an incremental save.
+
+Returns a Promise.
+
+| Name   | Type    | Description                                                  |
+| ------ | ------- | ------------------------------------------------------------ |
+| result | boolean | Returns `true` if password removal is successful, otherwise `false`. |
+
+```tsx
+const check = await pdfReaderRef.current?._pdfDocument.checkOwnerPassword('ownerPassword');
+```
+
+#### getEncryptAlgo
+
+Get the encryption algorithm of the current document
+
+Returns a Promise.
+
+| Name   | Type                    | Description     |
+| ------ | ----------------------- | --------------- |
+| result | CPDFDocumentEncryptAlgo | Encryption Type |
+
+```tsx
+const encryptAlgo = await pdfReaderRef.current?._pdfDocument.getEncryptAlgo();
+```
+

+ 2 - 2
example/src/CPDFAnnotationsExample.tsx

@@ -7,9 +7,9 @@
  * This notice may not be removed from this file.
  */
 
-import React, { useState, useEffect, useRef } from 'react';
+import React, { useState, useRef } from 'react';
 import { Image, Platform, StyleSheet, Text, View } from 'react-native';
-import { CPDFReaderView, ComPDFKit, CPDFToolbarAction, CPDFThemes } from '@compdfkit_pdf_sdk/react_native';
+import { CPDFReaderView, ComPDFKit, CPDFToolbarAction, CPDFDocument } from '@compdfkit_pdf_sdk/react_native';
 import { useNavigation, useRoute, RouteProp } from '@react-navigation/native';
 import { HeaderBackButton } from '@react-navigation/elements';
 import { MenuProvider, Menu, MenuTrigger, MenuOptions, MenuOption } from 'react-native-popup-menu';

+ 3 - 3
example/src/CPDFReaderViewControllerExample.tsx

@@ -97,9 +97,9 @@ const CPDFReaderViewControllerExampleScreen = () => {
     const handleMenuItemPress = async (action: string) => {
         switch (action) {
             case 'openDocument':
-                const pdfFile = await ComPDFKit.pickFile();
-                if (pdfFile) {
-                    await pdfReaderRef.current?._pdfDocument.open(pdfFile);
+                const document = await ComPDFKit.pickFile();
+                if (document) {
+                    await pdfReaderRef.current?._pdfDocument.open(document);
                 }
                 break;
             case 'save':

+ 3 - 16
example/src/CPDFSecurityExample.tsx

@@ -7,15 +7,13 @@
  * This notice may not be removed from this file.
  */
 
-import React, { useState, useEffect, useRef } from 'react';
+import React, { useState, useRef } from 'react';
 import { Image, Platform, StyleSheet, Text, View } from 'react-native';
-import { CPDFReaderView, ComPDFKit, CPDFToolbarAction, CPDFThemes } from '@compdfkit_pdf_sdk/react_native';
+import { CPDFReaderView, ComPDFKit, CPDFToolbarAction, CPDFDocumentEncryptAlgo, CPDFDocument } from '@compdfkit_pdf_sdk/react_native';
 import { useNavigation, useRoute, RouteProp } from '@react-navigation/native';
 import { HeaderBackButton } from '@react-navigation/elements';
 import { MenuProvider, Menu, MenuTrigger, MenuOptions, MenuOption } from 'react-native-popup-menu';
 import { SafeAreaView } from 'react-native-safe-area-context';
-import DocumentPicker from 'react-native-document-picker';
-import { CPDFDocumentEncryptAlgo } from '../../src/configuration/CPDFOptions';
 
 type RootStackParamList = {
     CPDFReaderViewExample: { document?: string };
@@ -40,17 +38,6 @@ const CPDFSecurityExampleScreen = () => {
             : 'PDF_Document.pdf')
     );
 
-    const handleSave = async () => {
-        if (pdfReaderRef.current) {
-            const success = await pdfReaderRef.current.save();
-            if (success) {
-                console.log('ComPDFKitRN save() : Document saved successfully');
-            } else {
-                console.log('ComPDFKitRN save() : Failed to save document');
-            }
-        }
-    };
-
     const menuOptions = [
         'Set Password',
         'Remove Password',
@@ -60,7 +47,7 @@ const CPDFSecurityExampleScreen = () => {
     const handleMenuItemPress = async (action: string) => {
         switch (action) {
             case 'Set Password':
-                var document = pdfReaderRef.current?._pdfDocument;
+                var document : CPDFDocument = pdfReaderRef.current?._pdfDocument;
                 const result = await document?.setPassword('1234', '4321', false,false, CPDFDocumentEncryptAlgo.AES128);
                 console.log('ComPDFKit-RN setPassword:', result);
                 break;

+ 4 - 1
src/index.tsx

@@ -192,8 +192,11 @@ export {
   CPDFFormType,
   CPDFCheckStyle,
   CPDFDisplayMode,
-  CPDFThemes } from './configuration/CPDFOptions';
+  CPDFThemes,
+  CPDFDocumentPermissions,
+  CPDFDocumentEncryptAlgo } from './configuration/CPDFOptions';
 export { CPDFReaderView } from './view/CPDFReaderView';
+export { CPDFDocument} from './view/CPDFDocument';
 
 
 ComPDFKit.getDefaultConfig = getDefaultConfig

+ 9 - 9
src/view/CPDFDocument.tsx

@@ -2,7 +2,7 @@ import { NativeModules, findNodeHandle } from 'react-native';
 import { CPDFDocumentEncryptAlgo, CPDFDocumentPermissions } from '../configuration/CPDFOptions';
 const { CPDFViewManager } = NativeModules;
 
-class CPDFDocument {
+export class CPDFDocument {
 
     _viewerRef: any;
 
@@ -14,28 +14,28 @@ class CPDFDocument {
      * Reopens a specified document in the current `CPDFReaderView` component.
      *
      * @example
-     * await pdfReaderRef.current?._pdfDocument.open(filePath, 'password');
+     * await pdfReaderRef.current?._pdfDocument.open(document, 'password');
      *
-     * @param filePath The file path of the PDF document.
+     * @param document The file path of the PDF document.
      * * (Android) For a local storage file path:
      * ```tsx
-     *    filePath = 'file:///storage/emulated/0/Download/sample.pdf'
+     *    document = 'file:///storage/emulated/0/Download/sample.pdf'
      * ```
      * * (Android) For a content URI:
      * ```tsx
-     *    filePath = 'content://...'
+     *    document = 'content://...'
      * ```
      * * (Android) For an asset file path:
      * ```tsx
-     *    filePath = "file:///android_asset/..."
+     *    document = "file:///android_asset/..."
      * ```
      * @param password The password for the document, which can be null or empty.
      * @returns A promise that resolves to `true` if the document is successfully opened, otherwise `false`.
      */
-    open = (filePath: string, password: string | null = null): Promise<boolean> => {
+    open = (document: string, password: string | null = null): Promise<boolean> => {
         const tag = findNodeHandle(this._viewerRef);
         if (tag != null) {
-            return CPDFViewManager.open(tag, filePath, password);
+            return CPDFViewManager.open(tag, document, password);
         }
         return Promise.reject('Unable to find the native view reference');
     };
@@ -321,4 +321,4 @@ class CPDFDocument {
     }
 
 }
-export default CPDFDocument;
+// export default CPDFDocument;

+ 7 - 7
src/view/CPDFReaderView.tsx

@@ -526,7 +526,7 @@ export class CPDFReaderView extends PureComponent<CPDFReaderViewProps, any> {
    * Whether it is double page mode.
    * @example
    * await pdfReaderRef.current?.isDoublePageMode();
-   * @returns
+   * @returns Returns `true` if double page display is enabled, otherwise returns `false`
    */
   isDoublePageMode = () : Promise<boolean> => {
     const tag = findNodeHandle(this._viewerRef);
@@ -540,7 +540,7 @@ export class CPDFReaderView extends PureComponent<CPDFReaderViewProps, any> {
    * Sets whether it is cover page mode.
    * @example
    * await pdfReaderRef.current?.setCoverPageMode(true);
-   * @param isCoverPageMode
+   * @param isCoverPageMode Whether to display the document in cover form
    * @returns
    */
   setCoverPageMode = (isCoverPageMode : boolean) : Promise<void> => {
@@ -555,7 +555,7 @@ export class CPDFReaderView extends PureComponent<CPDFReaderViewProps, any> {
    * Whether it is cover page mode.
    * @example
    * await pdfReaderRef.current?.isCoverPageMode();
-   * @returns
+   * @returns Returns `true` if the document cover is displayed, otherwise returns `false`
    */
   isCoverPageMode = () : Promise<boolean> => {
     const tag = findNodeHandle(this._viewerRef);
@@ -582,7 +582,7 @@ export class CPDFReaderView extends PureComponent<CPDFReaderViewProps, any> {
    * Whether it is crop mode.
    * @example
    * await pdfReaderRef.current?.isCropMode();
-   * @returns
+   * @returns Returns `true` if the current mode is clipping mode, otherwise returns `false`
    */
   isCropMode = () : Promise<boolean> => {
     const tag = findNodeHandle(this._viewerRef);
@@ -632,7 +632,7 @@ export class CPDFReaderView extends PureComponent<CPDFReaderViewProps, any> {
    * Sets whether to fix the position of the non-swipe direction when zooming in for reading.
    * @example
    * await pdfReaderRef.current?.setFixedScroll(true);
-   * @param isFixedScroll
+   * @param isFixedScroll Whether to fix scrolling
    * @returns
    */
   setFixedScroll = (isFixedScroll : boolean) : Promise<void> => {
@@ -652,7 +652,7 @@ export class CPDFReaderView extends PureComponent<CPDFReaderViewProps, any> {
    *
    * @example
    * await pdfReaderRef.current?.setPreviewMode(CPDFViewMode.VIEWER);
-   * @param viewMode
+   * @param viewMode The view mode to display
    * @returns
    */
   setPreviewMode = (viewMode : CPDFViewMode) : Promise<void> => {
@@ -689,7 +689,7 @@ export class CPDFReaderView extends PureComponent<CPDFReaderViewProps, any> {
    * @example
    * await pdfReaderRef.current?.showThumbnailView(true);
    *
-   * @param editMode
+   * @param editMode Whether to enable edit mode
    * @returns
    */
   showThumbnailView = (editMode : boolean) : Promise<void> => {