Skip to content

Commit 2a543d8

Browse files
committed
compdfkit(rn) - 2.2.0
1 parent e105908 commit 2a543d8

36 files changed

+10435
-779
lines changed

API.md

Lines changed: 192 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ ComPDFKit React Native supports TypeScript. Types used in this document will be
88

99
ComPDFKit contains static methods for global library initialization, configuration, and utility methods.
1010

11-
12-
1311
### init_
1412

1513
Initialize the ComPDFKit SDK offline using your ComPDFKit commercial license key. Please contact our sales to obtain a trial license.
@@ -140,7 +138,6 @@ ComPDFKit.openDocument(document, '', ComPDFKit.getDefaultConfig({}))
140138

141139
When using the `ComPDFKit.openDocument` method or the `CPDFReaderView` UI component to display a PDF file, you need to pass configuration parameters to customize the UI features and PDF view properties. `ComPDFKit` provides default configuration parameters through `ComPDFKit.getDefaultConfig`. You can retrieve them using the following example:
142140

143-
---
144141

145142
```tsx
146143
ComPDFKit.getDefaultConfig({})
@@ -198,6 +195,22 @@ ComPDFKit.getDefaultConfig({
198195

199196
For more configuration parameter descriptions, please see [CPDFCONFIGURATION.md](./CONFIGURATION.md).
200197

198+
### removeSignFileList
199+
200+
Delete the signature saved in the electronic signature annotation list.
201+
202+
Returns a Promise.
203+
204+
| Name | Type | Description |
205+
| ------ | ------- | ------------------------------------------------------------ |
206+
| result | boolean | Returns `true` if the deletion was successful, otherwise returns `false`. |
207+
208+
```tsx
209+
ComPDFKit.removeSignFileList();
210+
```
211+
212+
213+
201214
## CPDFReaderView - Props
202215

203216
### Open Document
@@ -274,5 +287,181 @@ Used to pass configuration parameters when rendering a PDF file to customize UI
274287
/>
275288
```
276289

290+
### Document
291+
292+
#### hasChange
293+
Checks whether the document has been modified.
294+
295+
Returns a Promise.
296+
297+
Promise Parameters:
298+
299+
| Name | Type | Description |
300+
| --------- | ------- | ------------------------------------------------------------ |
301+
| hasChange | boolean | `true`: The document has been modified, <br/>`false`: The document has not been modified. |
302+
303+
```tsx
304+
const hasChange = await pdfReaderRef.current?.hasChange();
305+
```
306+
307+
#### save
308+
309+
Save the current document changes.
310+
311+
Returns a Promise.
312+
313+
Promise Parameters:
314+
315+
| Name | Type | Description |
316+
| ------ | ------- | ------------------------------------------------------ |
317+
| result | boolean | **true**: Save successful,<br/>**false**: Save failed. |
277318

319+
```js
320+
const saveResult = await pdfReaderRef.current.save();
321+
```
322+
323+
#### onSaveDocument
324+
325+
function, optional
326+
327+
This function will be called when the document is saved.
328+
329+
Parameters:
330+
331+
| Name | Type | Description |
332+
| ---------- | ---- | ----------------------- |
333+
| pageNumber | int | the current page number |
334+
335+
```tsx
336+
<CPDFReaderView
337+
onSaveDocument={()=>{}}
338+
/>
339+
```
340+
341+
### Viewer
342+
343+
#### setMargins
344+
345+
Set the current PDF view margin.
346+
347+
Parameters:
348+
349+
| Name | Type | Description |
350+
| ------ | ---- | ------------- |
351+
| left | int | margin left |
352+
| top | int | margin top |
353+
| right | int | margin right |
354+
| bottom | int | margin bottom |
355+
356+
```tsx
357+
await pdfReaderRef.current?.setMargins(10,10,10,10);
358+
```
359+
360+
361+
362+
### Page
363+
364+
#### setDisplayPageIndex
365+
366+
Jump to the index page.
367+
368+
Parameters:
369+
370+
| Name | Type | Description |
371+
| --------- | ---- | -------------- |
372+
| pageIndex | int | 需要跳转的页码 |
373+
374+
```tsx
375+
await pdfReaderRef.current?.setDisplayPageIndex(1);
376+
```
377+
378+
#### getCurrentPageIndex
379+
380+
get current page index.
381+
382+
Returns a Promise.
383+
384+
Promise Parameters:
385+
386+
| Name | Type | Description |
387+
| --------- | ---- | -------------------------- |
388+
| pageIndex | int | 返回当前文档展示的页面索引 |
389+
390+
```tsx
391+
const pageIndex = await pdfReaderRef.current?.getCurrentPageIndex();
392+
```
393+
394+
#### onPageChanged
395+
396+
function, optional
397+
398+
This function is called when the page number has been changed.
399+
400+
Parameters:
401+
402+
| Name | Type | Description |
403+
| ---------- | ---- | ----------------------- |
404+
| pageNumber | int | the current page number |
405+
406+
```tsx
407+
<CPDFReaderView
408+
onPageChanged={(pageIndex:number)=>{
409+
}}
410+
/>
411+
```
412+
413+
### Annotations
414+
415+
#### import Annotations
416+
417+
Imports annotations from the specified XFDF file into the current PDF document.
418+
419+
Parameters:
420+
421+
| Name | Type | Description |
422+
| -------- | ------ | ------------------------------------------------------------ |
423+
| xfdfFile | string | Path of the XFDF file to be imported.<br/>The Android platform supports the following paths:<br/>- **assets file**:'file:///android_assets/test.xfdf'<br/>- **file path**: '/data/xxx.xfdf'<br/>- **Uri**: 'content://xxxx' |
424+
425+
Returns a Promise.
426+
427+
Promise Parameters:
428+
429+
| Name | Type | Description |
430+
| ------ | ------- | ---------------------------------------------------------- |
431+
| result | boolean | **true**: import successful,<br/>**false**: import failed. |
432+
433+
```tsx
434+
const result = await pdfReaderRef.current.importAnnotations('xxx.xfdf');
435+
```
436+
437+
#### export Annotations
438+
Exports annotations from the current PDF document to an XFDF file.
439+
440+
Returns a Promise.
441+
442+
Promise Parameters:
443+
444+
| Name | Type | Description |
445+
| -------- | ------ | ------------------------------------------------------------ |
446+
| xfdfPath | string | The path of the XFDF file if export is successful; an empty string if the export fails. |
447+
448+
```tsx
449+
const exportXfdfFilePath = await pdfReaderRef.current?.exportAnnotations();
450+
```
451+
452+
453+
#### removeAllAnnotations
454+
Delete all comments in the current document.
455+
456+
Returns a Promise.
457+
458+
Promise Parameters:
459+
460+
| Name | Type | Description |
461+
| ------ | ------- | ----------- |
462+
| result | boolean | true、false |
463+
464+
```tsx
465+
const removeResult = await pdfReaderRef.current?.removeAllAnnotations();
466+
```
278467

CHANGELOG.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
## Newest Release
22

3+
### 2.2.0 - 13 Dec. 2024
4+
* Added features support for ComPDFKit PDF SDK for [Android V2.2.0](https://www.compdf.com/pdf-sdk/changelog-android#v2-2-0).
5+
* Added features support for ComPDFKit PDF SDK for [iOS V2.2.0](https://www.compdf.com/pdf-sdk/changelog-ios#v2-2-0).
6+
* Added import and export annotation interfaces.
7+
* Added delete all annotations interface.
8+
* Added get page number interface and page number listener callback.
9+
* Added save document callback.
10+
* Optimized document saving logic on iOS platform.
11+
12+
13+
14+
## Previous Release
15+
316
### 2.1.3-2 - 26 Sep 2024
417

518
* Added the features support for ComPDFKit PDF SDK for Android V2.1.3.
@@ -11,8 +24,6 @@
1124
* Fixed crash when releasing watermarks.
1225
* Fixed memory leak in the property window of the ComPDFKit_Tools module.
1326

14-
## Previous Release
15-
1627
### 2.1.3-1 - 25 Sep 2024
1728

1829
* Added the features support for ComPDFKit PDF SDK for iOS V2.1.3.

CONFIGURATION.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ Used to configure the initial display mode and supported modes when displaying a
114114
{
115115
"modeConfig": {
116116
"initialViewMode": "viewer",
117+
"readerOnly": false,
117118
"availableViewModes": [
118119
"viewer",
119120
"annotations",
@@ -131,12 +132,13 @@ Configure functions for the top toolbar in the PDF view.
131132

132133
##### **Parameters**
133134

134-
| Name | Type | Description |
135-
| --------------------------- | ----- | ------------------------------------------------------------ |
136-
| androidAvailableActions | Array | Functions available in the top toolbar for Android platform.<br />Defaults: `thumbnail`, `search`, `bota`, `menu` |
137-
| iosLeftBarAvailableActions | Array | Functions available in the left side of the top toolbar for iOS platform.<br />Defaults: `back`, `thumbnail` |
138-
| iosRightBarAvailableActions | Array | Functions available in the right side of the top toolbar for iOS platform.<br />Defaults: `search`, `bota`, `menu` |
139-
| availableMenus | Array | A list of more functions popped up by the `menu` option on the top toolbar. |
135+
| Name | Type | Description |
136+
| --------------------------- | ------- | ------------------------------------------------------------ |
137+
| androidAvailableActions | Array | Functions available in the top toolbar for Android platform.<br />Defaults: `thumbnail`, `search`, `bota`, `menu` |
138+
| iosLeftBarAvailableActions | Array | Functions available in the left side of the top toolbar for iOS platform.<br />Defaults: `back`, `thumbnail` |
139+
| iosRightBarAvailableActions | Array | Functions available in the right side of the top toolbar for iOS platform.<br />Defaults: `search`, `bota`, `menu` |
140+
| availableMenus | Array | A list of more functions popped up by the `menu` option on the top toolbar. |
141+
| mainToolbarVisible | boolean | 是否显示主界面视图顶部工具栏 |
140142

141143
##### **Constants**
142144

@@ -160,9 +162,11 @@ Configure functions for the top toolbar in the PDF view.
160162
| save | Saves the document. |
161163
| share | Shares the PDF document. |
162164
| openDocument | Opens the system file selector to choose and open a PDF document. |
165+
| snip | The PDF capture function allows you to capture an area in the PDF document and convert it into an image. |
163166
```json
164167
{
165168
"toolbarConfig": {
169+
"mainToolbarVisible" : true,
166170
"androidAvailableActions": [
167171
"thumbnail",
168172
"search",
@@ -187,7 +191,8 @@ Configure functions for the top toolbar in the PDF view.
187191
"flattened",
188192
"save",
189193
"share",
190-
"openDocument"
194+
"openDocument",
195+
"snip"
191196
]
192197
}
193198
}
@@ -756,6 +761,7 @@ This section is used to configure the types of forms enabled in the view's botto
756761
| pageSpacing | int | 10 | Spacing between each page of the PDF.<br/>default `10px`. |
757762
| pageScale | double | 1.0 | Page scale value, default 1.0.<br/>value range:1.0~5.0 |
758763
| pageSameWidth | boolean | true | only android platform. |
764+
| margins | Array | [0,0,0,0] | Set the outer spacing of the PDF area. The setting order is: left, top, right, bottom. |
759765

760766
##### displayMode Constants
761767

@@ -809,6 +815,7 @@ This section is used to configure the types of forms enabled in the view's botto
809815
]
810816
},
811817
"toolbarConfig": {
818+
"mainToolbarVisible" : true,
812819
"androidAvailableActions": [
813820
"thumbnail",
814821
"search",
@@ -833,7 +840,8 @@ This section is used to configure the types of forms enabled in the view's botto
833840
"flattened",
834841
"save",
835842
"share",
836-
"openDocument"
843+
"openDocument",
844+
"snip"
837845
]
838846
},
839847
"annotationsConfig": {
@@ -1052,6 +1060,7 @@ This section is used to configure the types of forms enabled in the view's botto
10521060
"enableSliderBar": true,
10531061
"enablePageIndicator": true,
10541062
"pageSpacing": 10,
1063+
"margins" : [0,0,0,0],
10551064
"pageScale": 1.0,
10561065
"pageSameWidth":true
10571066
},

0 commit comments

Comments
 (0)