Skip to content

Commit 3c6ec7b

Browse files
author
PSPDFKit
committed
Release 2.8.0
1 parent 5b2716a commit 3c6ec7b

File tree

135 files changed

+58774
-14665
lines changed

Some content is hidden

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

135 files changed

+58774
-14665
lines changed

.eslintrc.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
module.exports = {
22
root: true,
3-
extends: [
4-
'eslint:recommended',
5-
'plugin:react/recommended',
6-
'@react-native-community',
7-
],
3+
extends: ['eslint:recommended', 'plugin:react/recommended', '@react-native'],
84
plugins: ['simple-import-sort'],
95
parserOptions: {
106
ecmaVersion: 12,

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,7 @@ PSPDFKit/PSPDFKitUI.xcframework
5050
# UWP license file
5151
samples/Catalog/windows/Catalog/License.xaml
5252

53+
#Jsdoc
54+
jsdoc/
55+
5356
.fake

ACKNOWLEDGEMENTS.md

Lines changed: 647 additions & 441 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
## Newest Release
22

3+
### 2.8.0 - 18 Dec 2023
4+
5+
- Adds TypeScript types support to PSPDFKit plugin. (#42380)
6+
- Adds support for loading image documents using the PSPDFKit component on Android. (#42692)
7+
- Updates plugin to target React Native 0.72.7. (#42800)
8+
- Updates Android compileSdkVersion to API 34 and Gradle to 8. (#42380)
9+
- Updates PSPDFKit for Android version to 8.10.0.
10+
- Updates PSPDFKit for iOS version to 13.1.0.
11+
- Fixes issue where building iOS project led to "'PSPDFKitReactNativeiOS-Swift.h' file not found" error. (#41986)
12+
- Fixes issue where getAnnotations with invalid page index caused a crash on Android. (#42073)
13+
- Fixes issue where onAnnotationsChanged event did not fire when a form field was updated on Android. (#42525)
14+
- Fixes issue where annotation toolbar color picker wasn't added by default. (#42761)
15+
16+
## Previous Releases
17+
318
### 2.7.0 - 07 Sep 2023
419

520
- Adds Annotation Preset customization. (#41528)
621
- Updates for PSPDFKit 8.8.1 for Android. (#41910)
722
- Updates for PSPDFKit 12.3.1 for iOS. (#41910)
823
- Updates the deployment target to iOS 15. (#39956)
9-
- Fixed issue where configuration is overridden by ToolbarMenuItems. (#41681)
10-
- Fixed issue where PDF generation returns "can not get property of null" on iOS. (#41247)
11-
- Fixed annotation toolbar menu grouping customization values. (#41197)
12-
- Fixed issue where the close button is not displayed on iOS. (#41710)
13-
- Fixed issue where showCloseButton config removes all other BarButtonItems on iOS. (#41731)
14-
- Fixed issue where presentInstant uses different parameters on iOS and Android. (#41922)
15-
16-
## Previous Releases
24+
- Fixes issue where configuration is overridden by ToolbarMenuItems. (#41681)
25+
- Fixes issue where PDF generation returns "can not get property of null" on iOS. (#41247)
26+
- Fixes annotation toolbar menu grouping customization values. (#41197)
27+
- Fixes issue where the close button is not displayed on iOS. (#41710)
28+
- Fixes issue where showCloseButton config removes all other BarButtonItems on iOS. (#41731)
29+
- Fixes issue where presentInstant uses different parameters on iOS and Android. (#41922)
1730

1831
### 2.6.1 - 19 Jun 2023
1932

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,12 @@ Let's create a simple app that integrates PSPDFKit and uses the `react-native-ps
102102
Your Podfile should look like this:
103103

104104
```diff
105-
require_relative '../node_modules/react-native/scripts/react_native_pods'
106-
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
105+
# Resolve react_native_pods.rb with node to allow for hoisting
106+
require Pod::Executable.execute_command('node', ['-p',
107+
'require.resolve(
108+
"react-native/scripts/react_native_pods.rb",
109+
{paths: [process.argv[1]]},
110+
)', __dir__]).strip
107111

108112
- platform :ios, '10.0'
109113
+ platform :ios, '15.0'
@@ -130,7 +134,7 @@ Let's create a simple app that integrates PSPDFKit and uses the `react-native-ps
130134
use_flipper!()
131135

132136
post_install do |installer|
133-
react_native_post_install(installer)
137+
react_native_post_install(installer, config[:reactNativePath])
134138
end
135139
end
136140
```
@@ -542,7 +546,7 @@ Let's create a simple app that integrates PSPDFKit and uses the `react-native-ps
542546
pageTransition: 'scrollContinuous',
543547
scrollDirection: 'vertical',
544548
}}
545-
ref="pdfView"
549+
ref={ this.pdfRef }
546550
fragmentTag="PDF1"
547551
style={{ flex: 1 }}
548552
/>

android/build.gradle

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Contains gradle configuration constants
1616
*/
1717
ext {
18-
PSPDFKIT_VERSION = '8.8.1'
18+
PSPDFKIT_VERSION = '8.10.0'
1919
}
2020

2121
buildscript {
@@ -32,7 +32,7 @@ buildscript {
3232
}
3333

3434
dependencies {
35-
classpath 'com.android.tools.build:gradle:7.1.0-alpha03'
35+
classpath("com.android.tools.build:gradle:8.1.0")
3636
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
3737
}
3838
}
@@ -41,24 +41,29 @@ apply plugin: 'com.android.library'
4141
apply plugin: 'kotlin-android'
4242

4343
android {
44-
compileSdkVersion 33
45-
buildToolsVersion "30.0.3"
44+
compileSdkVersion 34
45+
buildToolsVersion "34.0.0"
4646

47+
namespace "com.pspdfkit.react"
4748
defaultConfig {
4849
minSdkVersion 21
49-
targetSdkVersion 33
50+
targetSdkVersion 34
5051
versionCode 1
5152
versionName "1.0"
5253
}
5354

5455
compileOptions {
55-
sourceCompatibility JavaVersion.VERSION_1_8
56-
targetCompatibility JavaVersion.VERSION_1_8
56+
sourceCompatibility JavaVersion.VERSION_17
57+
targetCompatibility JavaVersion.VERSION_17
5758
}
5859

5960
lintOptions {
6061
abortOnError false
6162
}
63+
64+
buildFeatures {
65+
buildConfig true
66+
}
6267
}
6368

6469
dependencies {

android/src/main/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
2222

2323
<application>
24+
<meta-data
25+
android:name="pspdfkit_automatic_initialize"
26+
android:value="false" />
27+
2428
<activity
2529
android:name="com.pspdfkit.ui.PdfActivity"
2630
android:windowSoftInputMode="adjustNothing" />

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

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import com.pspdfkit.react.RNInstantPdfActivity;
4848
import com.pspdfkit.listeners.SimpleDocumentListener;
4949
import com.pspdfkit.react.helper.ConversionHelpers;
50+
import com.pspdfkit.react.helper.PSPDFKitUtils;
5051
import com.pspdfkit.ui.PdfActivity;
5152
import com.pspdfkit.ui.PdfFragment;
5253

@@ -65,15 +66,7 @@ public class PSPDFKitModule extends ReactContextBaseJavaModule implements Applic
6566

6667
private static final int REQUEST_CODE_TO_INDEX = 16;
6768
private static final int MASKED_REQUEST_CODE_TO_REAL_CODE = 0xffff;
68-
private static final String[] SUPPORTED_IMAGE_TYPES = new String[] {
69-
".jpg",
70-
".png",
71-
".jpeg",
72-
".tif",
73-
".tiff"
74-
};
75-
76-
69+
7770
@Nullable
7871
private Activity resumedActivity;
7972
@Nullable
@@ -115,10 +108,10 @@ public String getName() {
115108
@ReactMethod
116109
public void present(@NonNull String document, @NonNull ReadableMap configuration, @Nullable Promise promise) {
117110
File documentFile = new File(document);
118-
if(isPdf(documentFile)) {
111+
if(PSPDFKitUtils.isValidPdf(documentFile)) {
119112
lastPresentPromise = promise;
120113
presentPdf(document, configuration, promise);
121-
} else if(isImage(documentFile)) {
114+
} else if(PSPDFKitUtils.isValidImage(documentFile)) {
122115
lastPresentPromise = promise;
123116
presentImage(document, configuration, promise);
124117
}else {
@@ -166,7 +159,18 @@ public void presentImage(@NonNull String imageDocument, @NonNull ReadableMap con
166159
}
167160

168161
@ReactMethod
169-
public void presentInstant(@NonNull String serverUrl, @NonNull String jwt, @NonNull ReadableMap configuration, @Nullable Promise promise) {
162+
public void presentInstant(@NonNull ReadableMap documentData, @NonNull ReadableMap configuration, @Nullable Promise promise) {
163+
String serverUrl = documentData.getString("serverUrl");
164+
String jwt = documentData.getString("jwt");
165+
166+
if (serverUrl == null || jwt == null) {
167+
Throwable error = new Throwable("serverUrl and jwt are required");
168+
if (promise != null) {
169+
promise.reject(error);
170+
}
171+
return;
172+
}
173+
170174
if (getCurrentActivity() != null) {
171175
if (resumedActivity == null) {
172176
// We register an activity lifecycle callback so we can get notified of the current activity.
@@ -178,7 +182,7 @@ public void presentInstant(@NonNull String serverUrl, @NonNull String jwt, @NonN
178182
RNInstantPdfActivity.showInstantDocument(getCurrentActivity(), serverUrl, jwt, configurationAdapter.build());
179183
}
180184
}
181-
185+
182186
@ReactMethod
183187
public synchronized void setPageIndex(final int pageIndex, final boolean animated) {
184188
if (resumedActivity instanceof PdfActivity) {
@@ -447,17 +451,4 @@ public void run() {
447451
public void onNewIntent(Intent intent) {
448452
// Not required right now.
449453
}
450-
451-
private boolean isPdf(File file) {
452-
return file.getName().toLowerCase().endsWith(".pdf");
453-
}
454-
455-
private boolean isImage(File file) {
456-
for (String extension: SUPPORTED_IMAGE_TYPES) {
457-
if (file.getName().toLowerCase().endsWith(extension)) {
458-
return true;
459-
}
460-
}
461-
return false;
462-
}
463454
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.pspdfkit.react.helper
2+
3+
import java.io.File
4+
import java.util.Locale
5+
6+
7+
class PSPDFKitUtils {
8+
companion object {
9+
10+
private val SUPPORTED_IMAGE_TYPES = arrayOf(
11+
".jpg",
12+
".png",
13+
".jpeg",
14+
".tif",
15+
".tiff"
16+
)
17+
18+
@JvmStatic
19+
public fun isValidImage(file: File): Boolean {
20+
for (extension in SUPPORTED_IMAGE_TYPES) {
21+
if (file.name.lowercase(Locale.getDefault()).endsWith(extension)) {
22+
return true
23+
}
24+
}
25+
return false
26+
}
27+
28+
@JvmStatic
29+
public fun isValidPdf(file: File): Boolean {
30+
return file.name.lowercase(Locale.getDefault()).endsWith(".pdf")
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)