Skip to content

Commit 0350e99

Browse files
author
PSPDFKit
committed
Release 2.17.0
1 parent 6378b8d commit 0350e99

File tree

205 files changed

+5534
-19267
lines changed

Some content is hidden

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

205 files changed

+5534
-19267
lines changed

ACKNOWLEDGEMENTS.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -2149,6 +2149,8 @@ that were granted to the IJG for code derived from their software.
21492149

21502150

21512151
--------------------------------------------------------------------------------
2152+
## magic_enum (https://github.com/Neargye/magic_enum)
2153+
21522154
MIT License
21532155

21542156
Copyright (c) 2019 - 2024 Daniil Goncharov
@@ -3873,7 +3875,7 @@ limitations under the License.
38733875
--------------------------------------------------------------------------------
38743876
## PorterTokenizer (https://github.com/mozilla/releases-comm-central/blob/master/mailnews/extensions/fts3/src/Normalize.c)
38753877

3876-
Modified file can be obtained by emailing legal@pspdfkit.com
3878+
Modified file can be obtained by emailing legal@nutrient.io
38773879

38783880
This Source Code Form is subject to the terms of the Mozilla Public
38793881
License, v. 2.0. If a copy of the MPL was not distributed with this

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## 2.17.0 - 14 Apr 2025
2+
3+
- Adds new `setPageIndex` API to the `PDFDocument` class. (J#HYB-699)
4+
- Adds the `documentTapped` event to `NotificationCenter` to receive document tap events. (J#HYB-771)
5+
- Adds support for using multiple `PSPDFKitView` components in the same `View`. (J#HYB-692)
6+
- Adds TypeScript types for `FormElement` and `FormField` objects and also introduce new APIs to retrieve and update Form annotation data. (J#HYB-612)
7+
- Adds new `applyTemplate` property to `ToolbarItem` to manage toolbar icon color preservation when being displayed. (J#HYB-741)
8+
- Updates the `addAnnotations` API to accept optional annotation attachments. (J#HYB-782)
9+
- Updates to Nutrient Android SDK 10.1.1.
10+
- Updates to Nutrient iOS SDK 14.6.0.
11+
- Fixes an issue where `selection_tool` was not being added to the `menuItemGrouping` configuration on iOS. (J#HYB-705)
12+
113
## 2.16.1 - 27 Mar 2025
214

315
- Adds support for React Native 0.78. (J#HYB-737)

android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Contains gradle configuration constants
1616
*/
1717
ext {
18-
PSPDFKIT_VERSION = '10.0.1'
18+
PSPDFKIT_VERSION = '10.1.1'
1919
}
2020

2121
buildscript {

android/src/main/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<application>
2424
<meta-data
25-
android:name="pspdfkit_automatic_initialize"
25+
android:name="nutrient_automatic_initialize"
2626
android:value="false" />
2727

2828
<activity

android/src/main/java/com/pspdfkit/react/NutrientNotificationCenter.kt

+26-124
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@ import com.facebook.react.bridge.WritableMap
88
import com.pspdfkit.PSPDFKit
99
import com.pspdfkit.analytics.AnalyticsClient
1010
import com.pspdfkit.annotations.Annotation
11-
import com.pspdfkit.annotations.AnnotationType
12-
import com.pspdfkit.annotations.WidgetAnnotation
1311
import com.pspdfkit.forms.ChoiceFormElement
1412
import com.pspdfkit.forms.ComboBoxFormElement
1513
import com.pspdfkit.forms.EditableButtonFormElement
1614
import com.pspdfkit.forms.FormElement
1715
import com.pspdfkit.forms.FormField
1816
import com.pspdfkit.forms.TextFormElement
19-
import com.pspdfkit.react.helper.JsonUtilities
20-
import org.json.JSONObject
17+
import com.pspdfkit.react.helper.AnnotationUtils
2118

2219
class CustomAnalyticsClient: AnalyticsClient {
2320
override fun onEvent(name: String, data: Bundle?) {
@@ -30,6 +27,7 @@ enum class NotificationEvent(val value: String) {
3027
DOCUMENT_LOAD_FAILED("documentLoadFailed"),
3128
DOCUMENT_PAGE_CHANGED("documentPageChanged"),
3229
DOCUMENT_SCROLLED("documentScrolled"),
30+
DOCUMENT_TAPPED("documentTapped"),
3331
ANNOTATIONS_ADDED("annotationsAdded"),
3432
ANNOTATION_CHANGED("annotationChanged"),
3533
ANNOTATIONS_REMOVED("annotationsRemoved"),
@@ -102,18 +100,27 @@ object NutrientNotificationCenter {
102100
sendEvent(NotificationEvent.DOCUMENT_SCROLLED.value, jsonData)
103101
}
104102

103+
fun didTapDocument(pointF: PointF, documentID: String) {
104+
try {
105+
val pointMap = mapOf("x" to pointF.x, "y" to pointF.y)
106+
val nativePointMap = Arguments.makeNativeMap(pointMap)
107+
108+
val jsonData = Arguments.createMap()
109+
jsonData.putString("event", NotificationEvent.DOCUMENT_TAPPED.value)
110+
jsonData.putMap("point", nativePointMap)
111+
jsonData.putString("documentID", documentID)
112+
sendEvent(NotificationEvent.DOCUMENT_TAPPED.value, jsonData)
113+
} catch (e: Exception) {
114+
// Could not decode point data
115+
}
116+
}
117+
105118
fun annotationsChanged(changeType: String, annotation: Annotation, documentID: String) {
106119
when (changeType) {
107120
"changed" -> {
108121
try {
109-
val instantJson = JSONObject(annotation.toInstantJson())
110122
val annotationsList = mutableListOf<Map<String, Any>>()
111-
val annotationMap = JsonUtilities.jsonObjectToMap(instantJson)
112-
annotationMap["uuid"] = annotation.uuid
113-
if (annotation.type == AnnotationType.WIDGET) {
114-
val widgetAnnotation : WidgetAnnotation = annotation as WidgetAnnotation
115-
annotationMap["isRequired"] = widgetAnnotation.formElement?.isRequired
116-
}
123+
val annotationMap = AnnotationUtils.processAnnotation(annotation)
117124
annotationsList.add(annotationMap)
118125
val nativeAnnotationsList = Arguments.makeNativeArray(annotationsList)
119126

@@ -139,18 +146,12 @@ object NutrientNotificationCenter {
139146
jsonData.putString("event", NotificationEvent.ANNOTATIONS_REMOVED.value)
140147
jsonData.putArray("annotations", nativeAnnotationsList)
141148
jsonData.putString("documentID", documentID)
142-
sendEvent(NotificationEvent.ANNOTATION_CHANGED.value, jsonData)
149+
sendEvent(NotificationEvent.ANNOTATIONS_REMOVED.value, jsonData)
143150
}
144151
"added" -> {
145152
try {
146-
val instantJson = JSONObject(annotation.toInstantJson())
147153
val annotationsList = mutableListOf<Map<String, Any>>()
148-
val annotationMap = JsonUtilities.jsonObjectToMap(instantJson)
149-
annotationMap["uuid"] = annotation.uuid
150-
if (annotation.type == AnnotationType.WIDGET) {
151-
val widgetAnnotation : WidgetAnnotation = annotation as WidgetAnnotation
152-
annotationMap["isRequired"] = widgetAnnotation.formElement?.isRequired
153-
}
154+
val annotationMap = AnnotationUtils.processAnnotation(annotation)
154155
annotationsList.add(annotationMap)
155156
val nativeAnnotationsList = Arguments.makeNativeArray(annotationsList)
156157

@@ -168,14 +169,8 @@ object NutrientNotificationCenter {
168169

169170
fun didSelectAnnotations(annotation: Annotation, documentID: String) {
170171
try {
171-
val instantJson = JSONObject(annotation.toInstantJson())
172172
val annotationsList = mutableListOf<Map<String, Any>>()
173-
val annotationMap = JsonUtilities.jsonObjectToMap(instantJson)
174-
annotationMap["uuid"] = annotation.uuid
175-
if (annotation.type == AnnotationType.WIDGET) {
176-
val widgetAnnotation : WidgetAnnotation = annotation as WidgetAnnotation
177-
annotationMap["isRequired"] = widgetAnnotation.formElement?.isRequired
178-
}
173+
val annotationMap = AnnotationUtils.processAnnotation(annotation)
179174
annotationsList.add(annotationMap)
180175
val nativeAnnotationsList = Arguments.makeNativeArray(annotationsList)
181176

@@ -191,14 +186,8 @@ object NutrientNotificationCenter {
191186

192187
fun didDeselectAnnotations(annotation: Annotation, documentID: String) {
193188
try {
194-
val instantJson = JSONObject(annotation.toInstantJson())
195189
val annotationsList = mutableListOf<Map<String, Any>>()
196-
val annotationMap = JsonUtilities.jsonObjectToMap(instantJson)
197-
annotationMap["uuid"] = annotation.uuid
198-
if (annotation.type == AnnotationType.WIDGET) {
199-
val widgetAnnotation : WidgetAnnotation = annotation as WidgetAnnotation
200-
annotationMap["isRequired"] = widgetAnnotation.formElement?.isRequired
201-
}
190+
val annotationMap = AnnotationUtils.processAnnotation(annotation)
202191
annotationsList.add(annotationMap)
203192
val nativeAnnotationsList = Arguments.makeNativeArray(annotationsList)
204193

@@ -214,13 +203,7 @@ object NutrientNotificationCenter {
214203

215204
fun didTapAnnotation(annotation: Annotation, pointF: PointF, documentID: String) {
216205
try {
217-
val instantJson = JSONObject(annotation.toInstantJson())
218-
val annotationMap = JsonUtilities.jsonObjectToMap(instantJson)
219-
annotationMap["uuid"] = annotation.uuid
220-
if (annotation.type == AnnotationType.WIDGET) {
221-
val widgetAnnotation : WidgetAnnotation = annotation as WidgetAnnotation
222-
annotationMap["isRequired"] = widgetAnnotation.formElement?.isRequired
223-
}
206+
val annotationMap = AnnotationUtils.processAnnotation(annotation)
224207
val nativeAnnotationMap = Arguments.makeNativeMap(annotationMap)
225208

226209
val pointMap = mapOf("x" to pointF.x, "y" to pointF.y)
@@ -248,35 +231,8 @@ object NutrientNotificationCenter {
248231
fun formFieldValuesUpdated(formField: FormField, documentID: String) {
249232
try {
250233
val annotation = formField.formElement.annotation
251-
val instantJson = JSONObject(annotation.toInstantJson())
234+
val annotationMap = AnnotationUtils.processAnnotation(annotation).toMutableMap()
252235
val annotationsList = mutableListOf<Map<String, Any>>()
253-
val annotationMap = JsonUtilities.jsonObjectToMap(instantJson)
254-
annotationMap["uuid"] = annotation.uuid
255-
if (annotation.type == AnnotationType.WIDGET) {
256-
val widgetAnnotation : WidgetAnnotation = annotation as WidgetAnnotation
257-
annotationMap["isRequired"] = widgetAnnotation.formElement?.isRequired
258-
}
259-
260-
(formField.formElement as? TextFormElement).let { textFormElement ->
261-
if (textFormElement != null) {
262-
annotationMap["value"] = textFormElement.text
263-
}
264-
}
265-
(formField.formElement as? EditableButtonFormElement).let { buttonFormElement ->
266-
if (buttonFormElement != null) {
267-
annotationMap["value"] = if (buttonFormElement.isSelected) "selected" else "deselected"
268-
}
269-
}
270-
(formField.formElement as? ComboBoxFormElement).let { comboBoxFormElement ->
271-
if (comboBoxFormElement != null) {
272-
annotationMap["value"] = if (comboBoxFormElement.isCustomTextSet) comboBoxFormElement.customText else comboBoxFormElement.selectedIndexes
273-
}
274-
}
275-
(formField.formElement as? ChoiceFormElement).let { choiceFormElement ->
276-
if (choiceFormElement != null) {
277-
annotationMap["value"] = choiceFormElement.selectedIndexes
278-
}
279-
}
280236

281237
annotationsList.add(annotationMap)
282238
val nativeAnnotationsList = Arguments.makeNativeArray(annotationsList)
@@ -294,34 +250,7 @@ object NutrientNotificationCenter {
294250
fun didSelectFormField(formElement: FormElement, documentID: String) {
295251
try {
296252
val annotation = formElement.annotation
297-
val instantJson = JSONObject(annotation.toInstantJson())
298-
val annotationMap = JsonUtilities.jsonObjectToMap(instantJson)
299-
annotationMap["uuid"] = annotation.uuid
300-
if (annotation.type == AnnotationType.WIDGET) {
301-
val widgetAnnotation : WidgetAnnotation = annotation as WidgetAnnotation
302-
annotationMap["isRequired"] = widgetAnnotation.formElement?.isRequired
303-
}
304-
305-
(formElement as? TextFormElement).let { textFormElement ->
306-
if (textFormElement != null) {
307-
annotationMap["value"] = textFormElement.text
308-
}
309-
}
310-
(formElement as? EditableButtonFormElement).let { buttonFormElement ->
311-
if (buttonFormElement != null) {
312-
annotationMap["value"] = if (buttonFormElement.isSelected) "selected" else "deselected"
313-
}
314-
}
315-
(formElement as? ComboBoxFormElement).let { comboBoxFormElement ->
316-
if (comboBoxFormElement != null) {
317-
annotationMap["value"] = if (comboBoxFormElement.isCustomTextSet) comboBoxFormElement.customText else comboBoxFormElement.selectedIndexes
318-
}
319-
}
320-
(formElement as? ChoiceFormElement).let { choiceFormElement ->
321-
if (choiceFormElement != null) {
322-
annotationMap["value"] = choiceFormElement.selectedIndexes
323-
}
324-
}
253+
val annotationMap = AnnotationUtils.processAnnotation(annotation).toMutableMap()
325254

326255
val nativeAnnotationMap = Arguments.makeNativeMap(annotationMap)
327256
val jsonData = Arguments.createMap()
@@ -337,34 +266,7 @@ object NutrientNotificationCenter {
337266
fun didDeSelectFormField(formElement: FormElement, documentID: String) {
338267
try {
339268
val annotation = formElement.annotation
340-
val instantJson = JSONObject(annotation.toInstantJson())
341-
val annotationMap = JsonUtilities.jsonObjectToMap(instantJson)
342-
annotationMap["uuid"] = annotation.uuid
343-
if (annotation.type == AnnotationType.WIDGET) {
344-
val widgetAnnotation : WidgetAnnotation = annotation as WidgetAnnotation
345-
annotationMap["isRequired"] = widgetAnnotation.formElement?.isRequired
346-
}
347-
348-
(formElement as? TextFormElement).let { textFormElement ->
349-
if (textFormElement != null) {
350-
annotationMap["value"] = textFormElement.text
351-
}
352-
}
353-
(formElement as? EditableButtonFormElement).let { buttonFormElement ->
354-
if (buttonFormElement != null) {
355-
annotationMap["value"] = if (buttonFormElement.isSelected) "selected" else "deselected"
356-
}
357-
}
358-
(formElement as? ComboBoxFormElement).let { comboBoxFormElement ->
359-
if (comboBoxFormElement != null) {
360-
annotationMap["value"] = if (comboBoxFormElement.isCustomTextSet) comboBoxFormElement.customText else comboBoxFormElement.selectedIndexes
361-
}
362-
}
363-
(formElement as? ChoiceFormElement).let { choiceFormElement ->
364-
if (choiceFormElement != null) {
365-
annotationMap["value"] = choiceFormElement.selectedIndexes
366-
}
367-
}
269+
val annotationMap = AnnotationUtils.processAnnotation(annotation).toMutableMap()
368270

369271
val nativeAnnotationMap = Arguments.makeNativeMap(annotationMap)
370272
val jsonData = Arguments.createMap()

0 commit comments

Comments
 (0)