Skip to content

Commit 8b4d9ef

Browse files
author
PSPDFKit
committed
Release 2.11.0
1 parent 34697d8 commit 8b4d9ef

Some content is hidden

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

53 files changed

+1195
-5682
lines changed

CHANGELOG.md

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

3+
### 2.11.0 - 07 Jun 2024
4+
5+
- Adds the ability to clear the document cache. (J#HYB-347)
6+
- Adds support for opening PDF documents from a remote URL. (J#HYB-354)
7+
- Updates `setAnnotationFlags` and `getAnnotationFlags` APIs to support using annotation `name` as an identifier. (J#HYB-372)
8+
- Fixes an issue where calling `exitCurrentlyActiveMode` while not in annotation editing mode generates an exception on iOS. (J#HYB-373)
9+
- Fixes an issue where the annotation `uuid` isn't included in `onAnnotationTapped` callbacks. (J#HYB-374)
10+
- Fixes an issue where Instant configuration wasn't applied when using the `presentInstant` API on iOS. (J#HYB-375)
11+
12+
## Previous Releases
13+
314
### 2.10.0 - 06 May 2024
415

516
- Adds the ability to define annotation behavior using flags. (J#HYB-283)
@@ -9,8 +20,6 @@
920
- Fixes an issue where selecting a measurement annotation without the Measurement Tools license causes a crash. (J#HYB-318)
1021
- Fixes an issue where the `removeAnnotation` API sometimes failed to remove an annotation on iOS. (J#HYB-43)
1122

12-
## Previous Releases
13-
1423
### 2.9.1 - 12 Apr 2024
1524

1625
- Adds the ability to import and export annotations from XFDF files. (J#HYB-293)

License-Evaluation.pdf

-33.6 KB
Binary file not shown.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.pspdfkit.react
2+
3+
import com.facebook.react.bridge.Promise
4+
import com.facebook.react.bridge.ReactApplicationContext
5+
import com.facebook.react.bridge.ReactContextBaseJavaModule
6+
import com.facebook.react.bridge.ReactMethod
7+
import com.facebook.react.module.annotations.ReactModule
8+
import com.pspdfkit.document.PdfDocument
9+
10+
@ReactModule(name = PDFDocumentModule.NAME)
11+
class PDFDocumentModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
12+
13+
private var documents = mutableMapOf<Int, PdfDocument>()
14+
15+
override fun getName(): String {
16+
return NAME
17+
}
18+
19+
private fun getDocument(reference: Int): PdfDocument? {
20+
return this.documents[reference]
21+
}
22+
23+
fun setDocument(document: PdfDocument, reference: Int) {
24+
this.documents[reference] = document
25+
}
26+
27+
@ReactMethod fun getDocumentId(reference: Int, promise: Promise) {
28+
try {
29+
// Using uid here until Android exposes the documentId property.
30+
promise.resolve(this.getDocument(reference)?.uid)
31+
} catch (e: Throwable) {
32+
promise.reject("getDocumentId error", e)
33+
}
34+
}
35+
36+
@ReactMethod fun invalidateCacheForPage(reference: Int, pageIndex: Int, promise: Promise) {
37+
try {
38+
this.getDocument(reference)?.invalidateCacheForPage(pageIndex)
39+
promise.resolve(true)
40+
} catch (e: Throwable) {
41+
promise.reject("invalidateCacheForPage error", e)
42+
}
43+
}
44+
45+
@ReactMethod fun invalidateCache(reference: Int, promise: Promise) {
46+
try {
47+
this.getDocument(reference)?.invalidateCache()
48+
promise.resolve(true)
49+
} catch (e: Throwable) {
50+
promise.reject("invalidateCache error", e)
51+
}
52+
}
53+
54+
companion object {
55+
const val NAME = "PDFDocumentManager"
56+
}
57+
}

android/src/main/java/com/pspdfkit/react/PSPDFKitModule.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,10 @@ public String getName() {
107107

108108
@ReactMethod
109109
public void present(@NonNull String document, @NonNull ReadableMap configuration, @Nullable Promise promise) {
110-
File documentFile = new File(document);
111-
if(PSPDFKitUtils.isValidPdf(documentFile)) {
110+
if(PSPDFKitUtils.isValidPdf(document)) {
112111
lastPresentPromise = promise;
113112
presentPdf(document, configuration, promise);
114-
} else if(PSPDFKitUtils.isValidImage(documentFile)) {
113+
} else if(PSPDFKitUtils.isValidImage(document)) {
115114
lastPresentPromise = promise;
116115
presentImage(document, configuration, promise);
117116
}else {

android/src/main/java/com/pspdfkit/react/PSPDFKitPackage.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ public List<NativeModule> createNativeModules(ReactApplicationContext reactConte
3333
modules.add(new PSPDFKitModule(reactContext));
3434
modules.add(new TestingModule(reactContext));
3535
modules.add(new RNProcessor(reactContext));
36+
modules.add(new PDFDocumentModule(reactContext));
3637
return modules;
3738
}
3839

3940
@Override
4041
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
4142
List<ViewManager> viewManagers = new ArrayList<>();
42-
viewManagers.add(new ReactPdfViewManager());
43+
viewManagers.add(new ReactPdfViewManager(reactContext));
4344
return viewManagers;
4445
}
4546
}

android/src/main/java/com/pspdfkit/react/ReactPdfViewManager.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import androidx.annotation.NonNull;
1919
import androidx.fragment.app.FragmentActivity;
2020

21+
import com.facebook.react.bridge.ReactApplicationContext;
2122
import com.facebook.react.bridge.ReadableArray;
2223
import com.facebook.react.bridge.ReadableMap;
2324
import com.facebook.react.bridge.WritableArray;
@@ -78,6 +79,12 @@ public class ReactPdfViewManager extends ViewGroupManager<PdfView> {
7879

7980
private final CompositeDisposable annotationDisposables = new CompositeDisposable();
8081

82+
private final ReactApplicationContext reactApplicationContext;
83+
84+
public ReactPdfViewManager(ReactApplicationContext reactApplicationContext) {
85+
this.reactApplicationContext = reactApplicationContext;
86+
}
87+
8188
@NonNull
8289
@Override
8390
public String getName() {
@@ -152,13 +159,14 @@ public void setConfiguration(PdfView view, @NonNull ReadableMap configuration) {
152159
view.setConfiguration(configurationBuild);
153160
}
154161
view.setDocumentPassword(configuration.getString("documentPassword"));
162+
view.setRemoteDocumentConfiguration(configuration.getMap("remoteDocumentConfiguration"));
155163
// Although MeasurementValueConfigurations is specified as part of Configuration, it is configured separately on the Android SDK
156164
if (configuration.getArray("measurementValueConfigurations") != null) {
157165
view.setMeasurementValueConfigurations(configuration.getArray("measurementValueConfigurations"));
158-
}
166+
}
159167
}
160168

161-
@ReactProp(name = "annotationPresets")
169+
@ReactProp(name = "annotationPresets")
162170
public void setAnnotationPresets(PdfView view, @NonNull ReadableMap annotationPresets) {
163171
Map<AnnotationType, AnnotationConfiguration> annotationsConfiguration = AnnotationConfigurationAdaptor.convertAnnotationConfigurations(
164172
view.getContext(), annotationPresets
@@ -168,7 +176,7 @@ public void setAnnotationPresets(PdfView view, @NonNull ReadableMap annotationPr
168176

169177
@ReactProp(name = "document")
170178
public void setDocument(PdfView view, @NonNull String document) {
171-
view.setDocument(document);
179+
view.setDocument(document, this.reactApplicationContext);
172180
}
173181

174182
@ReactProp(name = "pageIndex")

android/src/main/java/com/pspdfkit/react/events/CustomAnnotationContextualMenuItemTappedEvent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class CustomAnnotationContextualMenuItemTappedEvent: Event<CustomAnnotationConte
1313
this.buttonId = buttonId
1414
}
1515

16-
override fun getEventName(): String? {
16+
override fun getEventName(): String {
1717
return EVENT_NAME
1818
}
1919

android/src/main/java/com/pspdfkit/react/events/CustomToolbarButtonTappedEvent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class CustomToolbarButtonTappedEvent: Event<CustomToolbarButtonTappedEvent> {
1313
this.buttonId = buttonId
1414
}
1515

16-
override fun getEventName(): String? {
16+
override fun getEventName(): String {
1717
return EVENT_NAME
1818
}
1919

android/src/main/java/com/pspdfkit/react/events/PdfViewAnnotationTappedEvent.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public void dispatch(RCTEventEmitter rctEventEmitter) {
5555
if (rawInstantJson != null && !rawInstantJson.equals("null")) {
5656
JSONObject instantJson = new JSONObject(rawInstantJson);
5757
Map<String, Object> map = JsonUtilities.jsonObjectToMap(instantJson);
58+
map.put("uuid", annotation.getUuid());
5859
WritableMap eventData = Arguments.makeNativeMap(map);
5960
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), eventData);
6061
}

android/src/main/java/com/pspdfkit/react/events/PdfViewDataReturnedEvent.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public PdfViewDataReturnedEvent(@IdRes int viewId, int requestId, @NonNull List<
5151
continue;
5252
}
5353
JSONObject instantJson = new JSONObject(annotation.toInstantJson());
54-
annotationsSerialized.add(JsonUtilities.jsonObjectToMap(instantJson));
54+
Map<String, Object> annotationMap = JsonUtilities.jsonObjectToMap(instantJson);
55+
annotationMap.put("uuid", annotation.getUuid());
56+
annotationsSerialized.add(annotationMap);
5557
}
5658

5759
Map<String, Object> annotations = new HashMap<>();

0 commit comments

Comments
 (0)