Skip to content

Commit 066675c

Browse files
committed
compdfkit(rn) - v2.4.0
1 parent 5b16c6a commit 066675c

File tree

83 files changed

+4151
-2103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+4151
-2103
lines changed

API.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,33 @@ const pages = [0, 1, 2];
10911091
const result = await pdfReaderRef.current?.splitDocumentPages(savePath, pages);
10921092
```
10931093

1094+
#### insertBlankPage
1095+
1096+
Inserts a blank page at the specified index in the document.
1097+
1098+
This method allows adding a blank page of a specified size at a specific index within the PDF document.
1099+
It is useful for document editing scenarios where page insertion is needed.
1100+
1101+
Parameters:
1102+
1103+
| Name | Type | Description |
1104+
| --------- | ------------ | ------------------------------------------------------------ |
1105+
| pageIndex | number | The index position where the blank page will be inserted. Must be a valid index within the document. |
1106+
| pageSize | CPDFPageSize | The size of the blank page to insert. Defaults to A4 size if not specified. |
1107+
1108+
Returns a Promise.
1109+
1110+
| Name | Type | Description |
1111+
| ------ | ---- | ------------------------------------------------------------ |
1112+
| result | bool | A Promise that resolves to a boolean value indicating the success or failure of the blank page insertion. Resolves to `true` if the insertion was successful, `false` otherwise. |
1113+
1114+
```tsx
1115+
const pageSize = CPDFPageSize.a4;
1116+
// Custom page size
1117+
// const pageSize = new CPDFPageSize(500, 800);
1118+
const result = await pdfRef.current?._pdfDocument.insertBlankPage(0, pageSize);
1119+
```
1120+
10941121
### Annotations
10951122

10961123
#### import Annotations
@@ -1170,6 +1197,34 @@ const page = pdfReaderRef?.current?._pdfDocument.pageAtIndex(pageIndex);
11701197
const annotations = await page?.getAnnotations();
11711198
```
11721199

1200+
#### removeAnnotation
1201+
1202+
Removes the specified annotation from the PDF document
1203+
1204+
Parameters:
1205+
1206+
| Name | Type | Description |
1207+
| ---------- | -------------- | ----------------------------- |
1208+
| annotation | CPDFAnnotation | The annotation to be removed. |
1209+
1210+
Returns a Promise.
1211+
1212+
Promise Parameters:
1213+
1214+
| Name | Type | Description |
1215+
| ------ | ------- | ----------------------------------------------------------- |
1216+
| result | boolean | **true**: remove successful,<br />**false**: remove failed. |
1217+
1218+
```tsx
1219+
await pdfReaderRef?.current?._pdfDocument.removeAnnotation(annotation);
1220+
// or use
1221+
const pageIndex = 0;
1222+
const page = pdfReaderRef?.current?._pdfDocument.pageAtIndex(pageIndex);
1223+
const widgets = await page?.getWidgets();
1224+
const widgetToRemove = widgets[0];
1225+
await page?.removeWidget(widgetToRemove);
1226+
```
1227+
11731228
#### flattenAllPages
11741229

11751230
Flatten all pages of the current document.
@@ -1326,6 +1381,34 @@ await signatureWidget.addImageSignature('/path/to/image');
13261381
await signatureWidget.updateAp();
13271382
```
13281383

1384+
#### removeWidget
1385+
1386+
Removes the specified widget from the PDF document
1387+
1388+
Parameters:
1389+
1390+
| Name | Type | Description |
1391+
| ------ | ---------- | ------------------------- |
1392+
| widget | CPDFWidget | The widget to be removed. |
1393+
1394+
Returns a Promise.
1395+
1396+
Promise Parameters:
1397+
1398+
| Name | Type | Description |
1399+
| ------ | ------- | ----------------------------------------------------------- |
1400+
| result | boolean | **true**: remove successful,<br />**false**: remove failed. |
1401+
1402+
```tsx
1403+
await pdfReaderRef?.current?._pdfDocument.removeWidget(widget);
1404+
// or use
1405+
const pageIndex = 0;
1406+
const page = pdfReaderRef?.current?._pdfDocument.pageAtIndex(pageIndex);
1407+
const annotations = await page?.getAnnotations();
1408+
const annotationToRemove = annotations[0];
1409+
await page?.removeAnnotation(annotationToRemove);
1410+
```
1411+
13291412
### Security
13301413

13311414
#### isEncrypted

CHANGELOG.md

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

3+
### 2.4.0 - 15 May. 2025
4+
5+
1. Added the features support for ComPDFKit PDF SDK for iOS V2.4.0.
6+
2. Added the features support for ComPDFKit PDF SDK for Android V2.4.0.
7+
3. Added configuration options for signature methods in signature form fields on Android.
8+
4. Added a document save reminder when exiting the interface on Android.
9+
5. Added functionality to erase existing Ink annotations on Android.
10+
6. Added APIs to delete annotations and form fields.
11+
7. Added an API to insert blank pages.
12+
8. Enhanced annotation property data.
13+
9. Enhanced form field property data.
14+
10. Fixed OOM crash issues on some devices during SDK initialization.
15+
11. Fixed an issue where signature appearance was not correctly displayed after digital signing.
16+
12. Fixed an issue where images failed to display after adding a watermark to certain documents.
17+
13. Fixed an issue that prevented inserting PNG images when inserting pages.
18+
14. Fixed incorrect handling of `ActionType_GoToR` and `ActionType_Launch` in hyperlink annotations.
19+
15. Fixed an issue where long input in electronic signatures within `ComPDFKit_Tools` caused incomplete display after saving.
20+
16. Fixed blurry display issue after zooming in on text annotations.
21+
17. Fixed jump behavior of `CPDFReaderView.setScale() `scaling method.
22+
18. Fixed a font inconsistency issue during content editing when adding text to already selected text with an existing device font.
23+
24+
25+
26+
## Previous Release
27+
328
### 2.3.0 - 21 Mar. 2025
429

530
1. Added the features support for ComPDFKit PDF SDK for iOS iOS V2.3.0.
@@ -22,8 +47,6 @@
2247
18. Fixed the issue of Chinese garbled characters in the form name.
2348
19. Fixed the issue where the prompt did not appear for scanned PDF documents on iOS.
2449

25-
## Previous Release
26-
2750
### 2.3.0-beta.1 - 28 Feb. 2025
2851

2952
* Added import/export interface for form data in XFDF format files.

CONFIGURATION.md

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -213,24 +213,25 @@ Configure annotation-related settings, such as enabling types displayed in the a
213213

214214
##### **availableTypes Constants**
215215

216-
| Name |
217-
| --------- |
218-
| note |
219-
| highlight |
220-
| underline |
221-
| squiggly |
222-
| strikeout |
223-
| ink |
224-
| circle |
225-
| square |
226-
| arrow |
227-
| line |
228-
| freetext |
229-
| signature |
230-
| stamp |
231-
| pictures |
232-
| link |
233-
| sound |
216+
| Name |
217+
| ---------- |
218+
| note |
219+
| highlight |
220+
| underline |
221+
| squiggly |
222+
| strikeout |
223+
| ink |
224+
| ink_eraser |
225+
| circle |
226+
| square |
227+
| arrow |
228+
| line |
229+
| freetext |
230+
| signature |
231+
| stamp |
232+
| pictures |
233+
| link |
234+
| sound |
234235

235236
##### availableTools Constants
236237

@@ -366,6 +367,7 @@ Configure annotation-related settings, such as enabling types displayed in the a
366367
"squiggly",
367368
"strikeout",
368369
"ink",
370+
"ink_eraser",
369371
"circle",
370372
"square",
371373
"arrow",
@@ -474,7 +476,7 @@ Switch to content editing mode to edit text and images. This configuration optio
474476
| -------------- | ----- | ------------------------------------------------------------ |
475477
| availableTypes | Array | Content editing mode, the editing mode displayed at the bottom of the view.<br>Default order: `editorText`, `editorImage` |
476478
| availableTools | Array | Available tools.<br/>including: `setting`, `undo`,`redo` |
477-
| initAttribute | obj | 添加文本时的默认属性 |
479+
| initAttribute | obj | Default properties when adding text |
478480

479481
* text
480482

@@ -784,11 +786,13 @@ This section is used to configure the types of forms enabled in the view's botto
784786

785787
##### Parameters
786788

787-
| Name | Type | Example | Description |
788-
| ----------------------- | ------------------- | ---------------------------- | ------------------------------------------------------------ |
789-
| themeMode | CPDFThemeMode | light | Set the view theme style, support `light`, `dark`, `system`, the default is `light` theme<br />**ComPDFKit SDK for Flutter:** => 2.0.2<br />Only Android Platform. |
790-
| fileSaveExtraFontSubset | boolean | true | When saving a document, whether to save the used font set together with the document. |
791-
| watermark | CPDFWatermarkConfig | { "saveAsNewFile" : true } | The user can configure the watermark addition popup, allowing them to choose whether to save the watermark directly to the current document or save it to a different directory.<br>**true**: Save to a different directory<br>**false**: Add to the current document directly |
789+
| Name | Type | Example | Description |
790+
| ----------------------- | ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
791+
| themeMode | CPDFThemeMode | light | Set the view theme style, support `light`, `dark`, `system`, the default is `light` theme<br />**ComPDFKit SDK for Flutter:** => 2.0.2<br />Only Android Platform. |
792+
| fileSaveExtraFontSubset | boolean | true | When saving a document, whether to save the used font set together with the document. |
793+
| watermark | CPDFWatermarkConfig | { "saveAsNewFile" : true, <br />"outsideBackgroundColor: ""<br />} | The user can configure the watermark addition popup, allowing them to choose whether to save the watermark directly to the current document or save it to a different directory.<br>**true**: Save to a different directory<br>**false**: Add to the current document directly |
794+
| signatureType | String | manual | Used to configure the default signing method when signing in the form field of CPDFReaderView.<br />Type:<br />* manual<br />* digital<br />* electronic |
795+
| enableExitSaveTips | boolean | true \| false | When exiting, check if the document has been modified and prompt to save the document |
792796

793797
##### themeMode Constants
794798

@@ -854,6 +858,7 @@ This section is used to configure the types of forms enabled in the view's botto
854858
"squiggly",
855859
"strikeout",
856860
"ink",
861+
"ink_eraser",
857862
"circle",
858863
"square",
859864
"arrow",
@@ -1069,8 +1074,11 @@ This section is used to configure the types of forms enabled in the view's botto
10691074
"themeMode" : "system",
10701075
"fileSaveExtraFontSubset" : true,
10711076
"watermark": {
1072-
"saveAsNewFile" : true
1073-
}
1077+
"saveAsNewFile" : true,
1078+
"outsideBackgroundColor" :""
1079+
},
1080+
"signatureType": "manual",
1081+
"enableExitSaveTips" : true
10741082
}
10751083
}
10761084
```

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
[ComPDFKit for React Native](https://www.compdf.com/react-native) allows you to quickly and seamlessly add PDF functions to any React Native application, elevating your Android and iOS apps with annotations, content editing, conversion, data extraction, etc.
88

9+
Watch the video here:
10+
[![image](https://img.youtube.com/vi/2ug2nPkuOy4/maxresdefault.jpg)](https://youtu.be/2ug2nPkuOy4)
11+
912
## Related
1013

1114
- [ComPDFKit PDF Library for iOS](https://github.com/ComPDFKit/PDF-SDK-iOS)
@@ -17,6 +20,8 @@
1720

1821
## Prerequisites
1922

23+
A development environment for running React Native projects using the React Native CLI. If you're using **Expo**, check out our [integration guide docs](./docs/How to Use ComPDFKit PDF SDK for ReactNative with Expo.md) on the topic.
24+
2025
* A license is required for trial. Please contact our [sales team](https://www.compdf.com/contact-sales) to obtain a free trial license.
2126
* npm or yarn
2227
* ComPDFKit SDK => 2.0.1
@@ -115,8 +120,8 @@ open ios/Podfile
115120
```diff
116121
target 'MyApp' do
117122
# ...
118-
+ pod "ComPDFKit", podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit/2.3.0.podspec'
119-
+ pod "ComPDFKit_Tools", podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit_tools/2.3.0.podspec'
123+
+ pod "ComPDFKit", podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit/2.4.0.podspec'
124+
+ pod "ComPDFKit_Tools", podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit_tools/2.4.0.podspec'
120125
# ...
121126
end
122127
```
@@ -126,8 +131,8 @@ end
126131
```diff
127132
target 'MyApp' do
128133
# ...
129-
+ pod 'ComPDFKit', :git => 'https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-swift.git', :tag => '2.3.0'
130-
+ pod 'ComPDFKit_Tools', :git => 'https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-swift.git', :tag => '2.3.0'
134+
+ pod 'ComPDFKit', :git => 'https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-swift.git', :tag => '2.4.0'
135+
+ pod 'ComPDFKit_Tools', :git => 'https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-swift.git', :tag => '2.4.0'
131136
# ...
132137
end
133138
```

android/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,14 @@ repositories {
7878

7979
mavenCentral()
8080
google()
81-
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
82-
8381
}
8482

8583

8684
dependencies {
8785
compileOnly fileTree(include: ['*.jar','*.aar'], dir: 'libs')
8886
implementation "com.facebook.react:react-native:+"
8987

90-
api "com.compdf:compdfkit-tools:2.3.0"
88+
api "com.compdf:compdfkit-tools:2.4.0"
9189
api 'com.github.bumptech.glide:glide:4.15.1'
9290
annotationProcessor 'com.github.bumptech.glide:compiler:4.15.1'
9391
api 'androidx.documentfile:documentfile:1.0.1'

android/src/main/java/com/compdfkitpdf/reactnative/CompdfkitPdfModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import androidx.annotation.NonNull;
2424

25+
import com.compdfkit.core.document.CPDFAbility;
2526
import com.compdfkit.core.document.CPDFSdk;
2627
import com.compdfkit.tools.common.pdf.CPDFConfigurationUtils;
2728
import com.compdfkit.tools.common.pdf.CPDFDocumentActivity;
@@ -117,6 +118,7 @@ public void init_(String license, Promise promise) {
117118
CPDFSdk.init(mReactContext, license, true, (code, msg) -> {
118119
Log.d(TAG, "init_: code:" + code + ", msg:" + msg);
119120
promise.resolve(code == CPDFSdk.VERIFY_SUCCESS);
121+
CPDFAbility.checkLicenseAllAbility();
120122
});
121123
}
122124

android/src/main/java/com/compdfkitpdf/reactnative/modules/CPDFViewModule.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,28 @@ public void addWidgetImageSignature(int tag, int pageIndex, String uuid, String
489489
});
490490
}
491491

492+
@ReactMethod
493+
public void removeAnnotation(int tag, int pageIndex, String uuid, Promise promise) {
494+
uiBlock(nativeViewHierarchyManager -> {
495+
promise.resolve(mPDFViewInstance.removeAnnotation(tag, pageIndex, uuid));
496+
});
497+
}
498+
499+
@ReactMethod
500+
public void removeWidget(int tag, int pageIndex, String uuid, Promise promise){
501+
uiBlock(nativeViewHierarchyManager -> {
502+
promise.resolve(mPDFViewInstance.removeWidget(tag, pageIndex, uuid));
503+
});
504+
}
505+
506+
@ReactMethod
507+
public void insertBlankPage(int tag, int pageIndex, int width, int height, Promise promise){
508+
uiBlock(nativeViewHierarchyManager -> {
509+
promise.resolve(mPDFViewInstance.insertBlankPage(tag, pageIndex, width, height));
510+
});
511+
}
512+
513+
492514
private void uiBlock(UIBlock uiBlock) {
493515
UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class);
494516
if (uiManager != null) {
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright © 2014-2025 PDF Technologies, Inc. All Rights Reserved.
3+
*
4+
* THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
5+
* AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
6+
* UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
7+
* This notice may not be removed from this file.
8+
*
9+
*/
10+
11+
package com.compdfkitpdf.reactnative.util;
12+
13+
14+
import androidx.annotation.ColorInt;
15+
import com.facebook.react.bridge.Arguments;
16+
import com.facebook.react.bridge.WritableArray;
17+
18+
public class CAppUtils {
19+
20+
21+
public static String toHexColor(@ColorInt int color){
22+
int rgb = color & 0x00FFFFFF;
23+
String hex = Integer.toHexString(rgb).toUpperCase();
24+
while (hex.length() < 6) {
25+
hex = "0" + hex;
26+
}
27+
return "#" + hex;
28+
}
29+
30+
public static WritableArray intArrayToWritableArray(int[] intArray) {
31+
WritableArray writableArray = Arguments.createArray();
32+
if (intArray != null) {
33+
for (int value : intArray) {
34+
writableArray.pushInt(value);
35+
}
36+
}
37+
return writableArray;
38+
}
39+
}

0 commit comments

Comments
 (0)