react-native-pdf 6.7.3 → 6.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/PdfView.js CHANGED
@@ -50,6 +50,7 @@ export default class PdfView extends Component {
50
50
  maxScale: MAX_SCALE,
51
51
  spacing: 10,
52
52
  style: {},
53
+ progressContainerStyle: {},
53
54
  fitPolicy: 2,
54
55
  horizontal: false,
55
56
  centerContent: false,
package/README.md CHANGED
@@ -168,6 +168,15 @@ react-native run-ios
168
168
  ### ChangeLog
169
169
  <details>
170
170
  <summary>ChangeLog details</summary>
171
+ v6.7.5
172
+
173
+ 1. Added progressContainerStyle prop
174
+ 2. Improved: Added enableDoubleTapZoom option
175
+ 3. Fixed: Fix app crash with this.lastRNBFTask.cancel is not a function (#827)
176
+ 4. Fixed: Remove override to fix 'no matching methods to override' error (#822)
177
+
178
+ v6.7.4
179
+ 1. Fixed: fix Android crash issue
171
180
 
172
181
  v6.7.3
173
182
  1. Fixed: fix android package name
@@ -288,35 +297,37 @@ const styles = StyleSheet.create({
288
297
 
289
298
  ### Configuration
290
299
 
291
- | Property | Type | Default | Description | iOS | Android | Windows | FirstRelease |
292
- | ------------- |:-------------:|:----------------:| ------------------- | ------| ------- | ------- | ------------ |
293
- | source | object | not null | PDF source like {uri:xxx, cache:false}. see the following for detail.| | ✔ | ✔ | <3.0 |
294
- | page | number | 1 | initial page index | ✔ | ✔ | ✔ | <3.0 |
295
- | scale | number | 1.0 | should minScale<=scale<=maxScale| ✔ | ✔ | ✔ | <3.0 |
296
- | minScale | number | 1.0 | min scale| ✔ | ✔ | ✔ | 5.0.5 |
297
- | maxScale | number | 3.0 | max scale| ✔ | ✔ | ✔ | 5.0.5 |
298
- | horizontal | bool | false | draw page direction, if you want to listen the orientation change, you can use [[react-native-orientation-locker]](https://github.com/wonday/react-native-orientation-locker)| ✔ | ✔ | ✔ | <3.0 |
299
- | showsHorizontalScrollIndicator | bool | true | shows or hides the horizontal scroll bar indicator on iOS| ✔ | | | 6.6 |
300
- | showsVerticalScrollIndicator | bool | true | shows or hides the vertical scroll bar indicator on iOS| ✔ | | | 6.6 |
301
- | fitWidth | bool | false | if true fit the width of view, can not use fitWidth=true together with scale| ✔ | ✔ | ✔ | <3.0, abandoned from 3.0 |
302
- | fitPolicy | number | 2 | 0:fit width, 1:fit height, 2:fit both(default)| ✔ | ✔ | ✔ | 3.0 |
303
- | spacing | number | 10 | the breaker size between pages| ✔ | ✔ | ✔ | <3.0 |
304
- | password | string | "" | pdf password, if password error, will call OnError() with message "Password required or incorrect password." | ✔ | ✔ | ✔ | <3.0 |
305
- | style | object | {backgroundColor:"#eee"} | support normal view style, you can use this to set border/spacing color... | ✔ | ✔ | ✔ | <3.0 |
306
- | renderActivityIndicator | (progress) => Component | <ProgressBar/> | when loading show it as an indicator, you can use your component| ✔ | ✔ | | <3.0 |
307
- | enableAntialiasing | bool | true | improve rendering a little bit on low-res screens, but maybe course some problem on Android 4.4, so add a switch | | ✔ | ✖ | <3.0 |
308
- | enablePaging | bool | false | only show one page in screen | | | ✔ | 5.0.1 |
309
- | enableRTL | bool | false | scroll page as "page3, page2, page1" | ✔ | | ✔ | 5.0.1 |
310
- | enableAnnotationRendering | bool | true | enable rendering annotation, notice:iOS only support initial setting,not support realtime changing | ✔ | ✔ | ✖ | 5.0.3 |
311
- | trustAllCerts | bool | true | Allow connections to servers with self-signed certification | ✔ | ✔ | ✖ | 6.0.? |
312
- | singlePage | bool | false | Only show first page, useful for thumbnail views | ✔ | ✔ | | 6.2.1 |
313
- | onLoadProgress | function(percent) | null | callback when loading, return loading progress (0-1) | ✔ | ✔ | ✖ | <3.0 |
314
- | onLoadComplete | function(numberOfPages, path, {width, height}, tableContents) | null | callback when pdf load completed, return total page count, pdf local/cache path, {width,height} and table of contents | ✔ | ✔ | ✔ but without tableContents | <3.0 |
315
- | onPageChanged | function(page,numberOfPages) | null | callback when page changed ,return current page and total page count | ✔ | ✔ | | <3.0 |
316
- | onError | function(error) | null | callback when error happened | ✔ | ✔ | ✔ | <3.0 |
317
- | onPageSingleTap | function(page) | null | callback when page was single tapped | ✔ | ✔ | ✔ | 3.0 |
318
- | onScaleChanged | function(scale) | null | callback when scale page | ✔ | ✔ | ✔ | 3.0 |
319
- | onPressLink | function(uri) | null | callback when link tapped | ✔ | ✔ | | 6.0.0 |
300
+ | Property | Type | Default | Description | iOS | Android | Windows | FirstRelease |
301
+ | ------------------------------ | :-----------------------------------------------------------: | :----------------------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------- | --------------------------- | ------------------------ |
302
+ | source | object | not null | PDF source like {uri:xxx, cache:false}. see the following for detail. | | ✔ | ✔ | <3.0 |
303
+ | page | number | 1 | initial page index | ✔ | ✔ | ✔ | <3.0 |
304
+ | scale | number | 1.0 | should minScale<=scale<=maxScale | ✔ | ✔ | ✔ | <3.0 |
305
+ | minScale | number | 1.0 | min scale | ✔ | ✔ | ✔ | 5.0.5 |
306
+ | maxScale | number | 3.0 | max scale | ✔ | ✔ | ✔ | 5.0.5 |
307
+ | horizontal | bool | false | draw page direction, if you want to listen the orientation change, you can use [[react-native-orientation-locker]](https://github.com/wonday/react-native-orientation-locker) | ✔ | ✔ | ✔ | <3.0 |
308
+ | showsHorizontalScrollIndicator | bool | true | shows or hides the horizontal scroll bar indicator on iOS | ✔ | | | 6.6 |
309
+ | showsVerticalScrollIndicator | bool | true | shows or hides the vertical scroll bar indicator on iOS | ✔ | | | 6.6 |
310
+ | fitWidth | bool | false | if true fit the width of view, can not use fitWidth=true together with scale | ✔ | ✔ | ✔ | <3.0, abandoned from 3.0 |
311
+ | fitPolicy | number | 2 | 0:fit width, 1:fit height, 2:fit both(default) | ✔ | ✔ | ✔ | 3.0 |
312
+ | spacing | number | 10 | the breaker size between pages | ✔ | ✔ | ✔ | <3.0 |
313
+ | password | string | "" | pdf password, if password error, will call OnError() with message "Password required or incorrect password." | ✔ | ✔ | ✔ | <3.0 |
314
+ | style | object | {backgroundColor:"#eee"} | support normal view style, you can use this to set border/spacing color... | ✔ | ✔ | ✔ | <3.0
315
+ | progressContainerStyle | object | {backgroundColor:"#eee"} | support normal view style, you can use this to set border/spacing color... | ✔ | ✔ | | 6.9.0 |
316
+ | renderActivityIndicator | (progress) => Component | <ProgressBar/> | when loading show it as an indicator, you can use your component | | ✔ | ✖ | <3.0 |
317
+ | enableAntialiasing | bool | true | improve rendering a little bit on low-res screens, but maybe course some problem on Android 4.4, so add a switch | ✖ | | | <3.0 |
318
+ | enablePaging | bool | false | only show one page in screen | ✔ | | ✔ | 5.0.1 |
319
+ | enableRTL | bool | false | scroll page as "page3, page2, page1" | ✔ | | ✔ | 5.0.1 |
320
+ | enableAnnotationRendering | bool | true | enable rendering annotation, notice:iOS only support initial setting,not support realtime changing | ✔ | ✔ | ✖ | 5.0.3 |
321
+ | enableDoubleTapZoom | bool | true | Enable double tap to zoom gesture | ✔ | ✔ | | 6.8.0 |
322
+ | trustAllCerts | bool | true | Allow connections to servers with self-signed certification | ✔ | ✔ | ✖ | 6.0.? |
323
+ | singlePage | bool | false | Only show first page, useful for thumbnail views | ✔ | ✔ | ✔ | 6.2.1 |
324
+ | onLoadProgress | function(percent) | null | callback when loading, return loading progress (0-1) | ✔ | ✔ | | <3.0 |
325
+ | onLoadComplete | function(numberOfPages, path, {width, height}, tableContents) | null | callback when pdf load completed, return total page count, pdf local/cache path, {width,height} and table of contents | ✔ | ✔ | ✔ but without tableContents | <3.0 |
326
+ | onPageChanged | function(page,numberOfPages) | null | callback when page changed ,return current page and total page count | ✔ | ✔ | ✔ | <3.0 |
327
+ | onError | function(error) | null | callback when error happened | ✔ | ✔ | ✔ | <3.0 |
328
+ | onPageSingleTap | function(page) | null | callback when page was single tapped | ✔ | ✔ | | 3.0 |
329
+ | onScaleChanged | function(scale) | null | callback when scale page | ✔ | ✔ | ✔ | 3.0 |
330
+ | onPressLink | function(uri) | null | callback when link tapped | ✔ | ✔ | ✖ | 6.0.0 |
320
331
 
321
332
  #### parameters of source
322
333
 
@@ -367,3 +378,4 @@ Example:
367
378
  ```
368
379
  this.pdf.setPage(42); // Display the answer to the Ultimate Question of Life, the Universe, and Everything
369
380
  ```
381
+
@@ -1,7 +1,7 @@
1
1
  description = 'react-native-pdf'
2
2
 
3
3
  buildscript {
4
- ext.safeExtGet = {prop, fallback ->
4
+ ext.safeExtGet = { prop, fallback ->
5
5
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
6
6
  }
7
7
  repositories {
@@ -10,7 +10,7 @@ buildscript {
10
10
  }
11
11
 
12
12
  dependencies {
13
- classpath("com.android.tools.build:gradle:7.2.0")
13
+ classpath("com.android.tools.build:gradle:7.4.2")
14
14
  }
15
15
  }
16
16
 
@@ -21,10 +21,11 @@ repositories {
21
21
  url "$projectDir/../node_modules/react-native/android"
22
22
  content {
23
23
  // Use Jitpack only for AndroidPdfViewer; the rest is hosted at mavenCentral.
24
- includeGroup "com.github.TalbotGooday"
24
+ includeGroup "com.github.zacharee"
25
25
  }
26
26
  }
27
27
  maven { url 'https://jitpack.io' }
28
+ google()
28
29
  }
29
30
 
30
31
  apply plugin: 'com.android.library'
@@ -48,9 +49,9 @@ def resolveReactNativeDirectory() {
48
49
  }
49
50
 
50
51
  throw new Exception(
51
- "[react-native-pdf] Unable to resolve react-native location in " +
52
- "node_modules. You should add project extension property (in app/build.gradle) " +
53
- "`REACT_NATIVE_NODE_MODULES_DIR` with path to react-native."
52
+ "[react-native-pdf] Unable to resolve react-native location in " +
53
+ "node_modules. You should add project extension property (in app/build.gradle) " +
54
+ "`REACT_NATIVE_NODE_MODULES_DIR` with path to react-native."
54
55
  )
55
56
  }
56
57
 
@@ -106,12 +107,12 @@ android {
106
107
  }
107
108
 
108
109
  packagingOptions {
109
- pickFirst 'lib/x86/libc++_shared.so'
110
- pickFirst 'lib/x86_64/libjsc.so'
111
- pickFirst 'lib/x86_64/libc++_shared.so'
112
- pickFirst 'lib/arm64-v8a/libjsc.so'
113
- pickFirst 'lib/arm64-v8a/libc++_shared.so'
114
- pickFirst 'lib/armeabi-v7a/libc++_shared.so'
110
+ pickFirst 'lib/x86/libc++_shared.so'
111
+ pickFirst 'lib/x86_64/libjsc.so'
112
+ pickFirst 'lib/x86_64/libc++_shared.so'
113
+ pickFirst 'lib/arm64-v8a/libjsc.so'
114
+ pickFirst 'lib/arm64-v8a/libc++_shared.so'
115
+ pickFirst 'lib/armeabi-v7a/libc++_shared.so'
115
116
  }
116
117
  }
117
118
 
@@ -122,7 +123,9 @@ dependencies {
122
123
  implementation 'com.facebook.react:react-native:+'
123
124
  }
124
125
  // NOTE: The original repo at com.github.barteksc is abandoned by the maintainer; there will be no more updates coming from that repo.
125
- // It was taken over by com.github.TalbotGooday; from now on please use this repo until (if ever) the Barteksc repo is resumed.
126
- implementation 'com.github.TalbotGooday:AndroidPdfViewer:3.1.0-beta.3'
126
+ // The repo from zacharee is based on PdfiumAndroidKt, a much newer fork of PdfiumAndroid, with better maintenance and updated native libraries.
127
+ implementation 'com.github.zacharee:AndroidPdfViewer:4.0.1'
128
+ // Depend on PdfiumAndroidKt directly so this can be updated independently of AndroidPdfViewer as updates are provided.
129
+ implementation 'io.legere:pdfiumandroid:1.0.19'
127
130
  implementation 'com.google.code.gson:gson:2.8.5'
128
131
  }
@@ -0,0 +1,7 @@
1
+ distributionBase=GRADLE_USER_HOME
2
+ distributionPath=wrapper/dists
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4
+ networkTimeout=10000
5
+ validateDistributionUrl=true
6
+ zipStoreBase=GRADLE_USER_HOME
7
+ zipStorePath=wrapper/dists
@@ -0,0 +1,2 @@
1
+ android.useAndroidX=true
2
+ android.enableJetifier=true
@@ -0,0 +1,249 @@
1
+ #!/bin/sh
2
+
3
+ #
4
+ # Copyright © 2015-2021 the original authors.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ ##############################################################################
20
+ #
21
+ # Gradle start up script for POSIX generated by Gradle.
22
+ #
23
+ # Important for running:
24
+ #
25
+ # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26
+ # noncompliant, but you have some other compliant shell such as ksh or
27
+ # bash, then to run this script, type that shell name before the whole
28
+ # command line, like:
29
+ #
30
+ # ksh Gradle
31
+ #
32
+ # Busybox and similar reduced shells will NOT work, because this script
33
+ # requires all of these POSIX shell features:
34
+ # * functions;
35
+ # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36
+ # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37
+ # * compound commands having a testable exit status, especially «case»;
38
+ # * various built-in commands including «command», «set», and «ulimit».
39
+ #
40
+ # Important for patching:
41
+ #
42
+ # (2) This script targets any POSIX shell, so it avoids extensions provided
43
+ # by Bash, Ksh, etc; in particular arrays are avoided.
44
+ #
45
+ # The "traditional" practice of packing multiple parameters into a
46
+ # space-separated string is a well documented source of bugs and security
47
+ # problems, so this is (mostly) avoided, by progressively accumulating
48
+ # options in "$@", and eventually passing that to Java.
49
+ #
50
+ # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51
+ # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52
+ # see the in-line comments for details.
53
+ #
54
+ # There are tweaks for specific operating systems such as AIX, CygWin,
55
+ # Darwin, MinGW, and NonStop.
56
+ #
57
+ # (3) This script is generated from the Groovy template
58
+ # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59
+ # within the Gradle project.
60
+ #
61
+ # You can find Gradle at https://github.com/gradle/gradle/.
62
+ #
63
+ ##############################################################################
64
+
65
+ # Attempt to set APP_HOME
66
+
67
+ # Resolve links: $0 may be a link
68
+ app_path=$0
69
+
70
+ # Need this for daisy-chained symlinks.
71
+ while
72
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73
+ [ -h "$app_path" ]
74
+ do
75
+ ls=$( ls -ld "$app_path" )
76
+ link=${ls#*' -> '}
77
+ case $link in #(
78
+ /*) app_path=$link ;; #(
79
+ *) app_path=$APP_HOME$link ;;
80
+ esac
81
+ done
82
+
83
+ # This is normally unused
84
+ # shellcheck disable=SC2034
85
+ APP_BASE_NAME=${0##*/}
86
+ # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87
+ APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
88
+
89
+ # Use the maximum available, or set MAX_FD != -1 to use that value.
90
+ MAX_FD=maximum
91
+
92
+ warn () {
93
+ echo "$*"
94
+ } >&2
95
+
96
+ die () {
97
+ echo
98
+ echo "$*"
99
+ echo
100
+ exit 1
101
+ } >&2
102
+
103
+ # OS specific support (must be 'true' or 'false').
104
+ cygwin=false
105
+ msys=false
106
+ darwin=false
107
+ nonstop=false
108
+ case "$( uname )" in #(
109
+ CYGWIN* ) cygwin=true ;; #(
110
+ Darwin* ) darwin=true ;; #(
111
+ MSYS* | MINGW* ) msys=true ;; #(
112
+ NONSTOP* ) nonstop=true ;;
113
+ esac
114
+
115
+ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
116
+
117
+
118
+ # Determine the Java command to use to start the JVM.
119
+ if [ -n "$JAVA_HOME" ] ; then
120
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
121
+ # IBM's JDK on AIX uses strange locations for the executables
122
+ JAVACMD=$JAVA_HOME/jre/sh/java
123
+ else
124
+ JAVACMD=$JAVA_HOME/bin/java
125
+ fi
126
+ if [ ! -x "$JAVACMD" ] ; then
127
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
128
+
129
+ Please set the JAVA_HOME variable in your environment to match the
130
+ location of your Java installation."
131
+ fi
132
+ else
133
+ JAVACMD=java
134
+ if ! command -v java >/dev/null 2>&1
135
+ then
136
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137
+
138
+ Please set the JAVA_HOME variable in your environment to match the
139
+ location of your Java installation."
140
+ fi
141
+ fi
142
+
143
+ # Increase the maximum file descriptors if we can.
144
+ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
145
+ case $MAX_FD in #(
146
+ max*)
147
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
148
+ # shellcheck disable=SC2039,SC3045
149
+ MAX_FD=$( ulimit -H -n ) ||
150
+ warn "Could not query maximum file descriptor limit"
151
+ esac
152
+ case $MAX_FD in #(
153
+ '' | soft) :;; #(
154
+ *)
155
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
156
+ # shellcheck disable=SC2039,SC3045
157
+ ulimit -n "$MAX_FD" ||
158
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
159
+ esac
160
+ fi
161
+
162
+ # Collect all arguments for the java command, stacking in reverse order:
163
+ # * args from the command line
164
+ # * the main class name
165
+ # * -classpath
166
+ # * -D...appname settings
167
+ # * --module-path (only if needed)
168
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
169
+
170
+ # For Cygwin or MSYS, switch paths to Windows format before running java
171
+ if "$cygwin" || "$msys" ; then
172
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
173
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
174
+
175
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
176
+
177
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
178
+ for arg do
179
+ if
180
+ case $arg in #(
181
+ -*) false ;; # don't mess with options #(
182
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
183
+ [ -e "$t" ] ;; #(
184
+ *) false ;;
185
+ esac
186
+ then
187
+ arg=$( cygpath --path --ignore --mixed "$arg" )
188
+ fi
189
+ # Roll the args list around exactly as many times as the number of
190
+ # args, so each arg winds up back in the position where it started, but
191
+ # possibly modified.
192
+ #
193
+ # NB: a `for` loop captures its iteration list before it begins, so
194
+ # changing the positional parameters here affects neither the number of
195
+ # iterations, nor the values presented in `arg`.
196
+ shift # remove old arg
197
+ set -- "$@" "$arg" # push replacement arg
198
+ done
199
+ fi
200
+
201
+
202
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203
+ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204
+
205
+ # Collect all arguments for the java command:
206
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207
+ # and any embedded shellness will be escaped.
208
+ # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209
+ # treated as '${Hostname}' itself on the command line.
210
+
211
+ set -- \
212
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
213
+ -classpath "$CLASSPATH" \
214
+ org.gradle.wrapper.GradleWrapperMain \
215
+ "$@"
216
+
217
+ # Stop when "xargs" is not available.
218
+ if ! command -v xargs >/dev/null 2>&1
219
+ then
220
+ die "xargs is not available"
221
+ fi
222
+
223
+ # Use "xargs" to parse quoted args.
224
+ #
225
+ # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
226
+ #
227
+ # In Bash we could simply go:
228
+ #
229
+ # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
230
+ # set -- "${ARGS[@]}" "$@"
231
+ #
232
+ # but POSIX shell has neither arrays nor command substitution, so instead we
233
+ # post-process each arg (as a line of input to sed) to backslash-escape any
234
+ # character that might be a shell metacharacter, then use eval to reverse
235
+ # that process (while maintaining the separation between arguments), and wrap
236
+ # the whole thing up as a single "set" statement.
237
+ #
238
+ # This will of course break if any of these variables contains a newline or
239
+ # an unmatched quote.
240
+ #
241
+
242
+ eval "set -- $(
243
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
244
+ xargs -n1 |
245
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
246
+ tr '\n' ' '
247
+ )" '"$@"'
248
+
249
+ exec "$JAVACMD" "$@"
@@ -0,0 +1,92 @@
1
+ @rem
2
+ @rem Copyright 2015 the original author or authors.
3
+ @rem
4
+ @rem Licensed under the Apache License, Version 2.0 (the "License");
5
+ @rem you may not use this file except in compliance with the License.
6
+ @rem You may obtain a copy of the License at
7
+ @rem
8
+ @rem https://www.apache.org/licenses/LICENSE-2.0
9
+ @rem
10
+ @rem Unless required by applicable law or agreed to in writing, software
11
+ @rem distributed under the License is distributed on an "AS IS" BASIS,
12
+ @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ @rem See the License for the specific language governing permissions and
14
+ @rem limitations under the License.
15
+ @rem
16
+
17
+ @if "%DEBUG%"=="" @echo off
18
+ @rem ##########################################################################
19
+ @rem
20
+ @rem Gradle startup script for Windows
21
+ @rem
22
+ @rem ##########################################################################
23
+
24
+ @rem Set local scope for the variables with windows NT shell
25
+ if "%OS%"=="Windows_NT" setlocal
26
+
27
+ set DIRNAME=%~dp0
28
+ if "%DIRNAME%"=="" set DIRNAME=.
29
+ @rem This is normally unused
30
+ set APP_BASE_NAME=%~n0
31
+ set APP_HOME=%DIRNAME%
32
+
33
+ @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34
+ for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35
+
36
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37
+ set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38
+
39
+ @rem Find java.exe
40
+ if defined JAVA_HOME goto findJavaFromJavaHome
41
+
42
+ set JAVA_EXE=java.exe
43
+ %JAVA_EXE% -version >NUL 2>&1
44
+ if %ERRORLEVEL% equ 0 goto execute
45
+
46
+ echo.
47
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48
+ echo.
49
+ echo Please set the JAVA_HOME variable in your environment to match the
50
+ echo location of your Java installation.
51
+
52
+ goto fail
53
+
54
+ :findJavaFromJavaHome
55
+ set JAVA_HOME=%JAVA_HOME:"=%
56
+ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57
+
58
+ if exist "%JAVA_EXE%" goto execute
59
+
60
+ echo.
61
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62
+ echo.
63
+ echo Please set the JAVA_HOME variable in your environment to match the
64
+ echo location of your Java installation.
65
+
66
+ goto fail
67
+
68
+ :execute
69
+ @rem Setup the command line
70
+
71
+ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72
+
73
+
74
+ @rem Execute Gradle
75
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76
+
77
+ :end
78
+ @rem End local scope for the variables with windows NT shell
79
+ if %ERRORLEVEL% equ 0 goto mainEnd
80
+
81
+ :fail
82
+ rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83
+ rem the _cmd.exe /c_ return code!
84
+ set EXIT_CODE=%ERRORLEVEL%
85
+ if %EXIT_CODE% equ 0 set EXIT_CODE=1
86
+ if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87
+ exit /b %EXIT_CODE%
88
+
89
+ :mainEnd
90
+ if "%OS%"=="Windows_NT" endlocal
91
+
92
+ :omega
@@ -1,4 +1,4 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android">
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.wonday.pdf">
2
2
 
3
3
 
4
4
  </manifest>
@@ -124,6 +124,11 @@ public class PdfManager extends SimpleViewManager<PdfView> implements RNPDFPdfVi
124
124
  pdfView.setEnableAnnotationRendering(enableAnnotationRendering);
125
125
  }
126
126
 
127
+ @ReactProp(name = "enableDoubleTapZoom")
128
+ public void setEnableDoubleTapZoom(PdfView pdfView, boolean enableDoubleTap) {
129
+ pdfView.setEnableDoubleTapZoom(enableDoubleTap);
130
+ }
131
+
127
132
  @ReactProp(name = "enablePaging")
128
133
  public void setEnablePaging(PdfView pdfView, boolean enablePaging) {
129
134
  pdfView.setEnablePaging(enablePaging);
@@ -12,22 +12,20 @@ import java.io.File;
12
12
 
13
13
  import android.content.ContentResolver;
14
14
  import android.content.Context;
15
+ import android.util.SizeF;
15
16
  import android.view.View;
16
17
  import android.view.ViewGroup;
17
18
  import android.util.Log;
18
- import android.graphics.PointF;
19
19
  import android.net.Uri;
20
20
  import android.util.AttributeSet;
21
21
  import android.view.MotionEvent;
22
22
  import android.graphics.Canvas;
23
- import javax.annotation.Nullable;
24
23
 
25
24
 
26
25
  import com.github.barteksc.pdfviewer.PDFView;
27
26
  import com.github.barteksc.pdfviewer.listener.OnPageChangeListener;
28
27
  import com.github.barteksc.pdfviewer.listener.OnLoadCompleteListener;
29
28
  import com.github.barteksc.pdfviewer.listener.OnErrorListener;
30
- import com.github.barteksc.pdfviewer.listener.OnRenderListener;
31
29
  import com.github.barteksc.pdfviewer.listener.OnTapListener;
32
30
  import com.github.barteksc.pdfviewer.listener.OnDrawListener;
33
31
  import com.github.barteksc.pdfviewer.listener.OnPageScrollListener;
@@ -41,7 +39,6 @@ import com.facebook.react.bridge.ReactContext;
41
39
  import com.facebook.react.bridge.Arguments;
42
40
  import com.facebook.react.bridge.WritableMap;
43
41
  import com.facebook.react.uimanager.SimpleViewManager;
44
- import com.facebook.react.uimanager.ThemedReactContext;
45
42
  import com.facebook.react.uimanager.annotations.ReactProp;
46
43
  import com.facebook.react.uimanager.events.RCTEventEmitter;
47
44
  import com.facebook.react.common.MapBuilder;
@@ -53,26 +50,21 @@ import static java.lang.String.format;
53
50
 
54
51
  import java.io.FileNotFoundException;
55
52
  import java.io.InputStream;
56
- import java.lang.ClassCastException;
57
53
 
58
- import com.shockwave.pdfium.PdfDocument;
59
54
  import com.google.gson.Gson;
60
- import com.google.gson.GsonBuilder;
61
- import com.shockwave.pdfium.util.SizeF;
62
55
 
63
56
  public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompleteListener,OnErrorListener,OnTapListener,OnDrawListener,OnPageScrollListener, LinkHandler {
64
- private ThemedReactContext context;
65
57
  private int page = 1; // start from 1
66
58
  private boolean horizontal = false;
67
59
  private float scale = 1;
68
60
  private float minScale = 1;
69
61
  private float maxScale = 3;
70
- private String asset;
71
62
  private String path;
72
63
  private int spacing = 10;
73
64
  private String password = "";
74
65
  private boolean enableAntialiasing = true;
75
66
  private boolean enableAnnotationRendering = true;
67
+ private boolean enableDoubleTapZoom = true;
76
68
 
77
69
  private boolean enablePaging = false;
78
70
  private boolean autoSpacing = false;
@@ -81,8 +73,6 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
81
73
  private FitPolicy fitPolicy = FitPolicy.WIDTH;
82
74
  private boolean singlePage = false;
83
75
 
84
- private static PdfView instance = null;
85
-
86
76
  private float originalWidth = 0;
87
77
  private float lastPageWidth = 0;
88
78
  private float lastPageHeight = 0;
@@ -91,10 +81,8 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
91
81
  private int oldW = 0;
92
82
  private int oldH = 0;
93
83
 
94
- public PdfView(ThemedReactContext context, AttributeSet set){
95
- super(context,set);
96
- this.context = context;
97
- this.instance = this;
84
+ public PdfView(Context context, AttributeSet set){
85
+ super(context, set);
98
86
  }
99
87
 
100
88
  @Override
@@ -282,7 +270,7 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
282
270
  .autoSpacing(this.autoSpacing)
283
271
  .pageFling(this.pageFling)
284
272
  .enableSwipe(!this.singlePage)
285
- .enableDoubletap(!this.singlePage)
273
+ .enableDoubletap(!this.singlePage && this.enableDoubleTapZoom)
286
274
  .enableAnnotationRendering(this.enableAnnotationRendering)
287
275
  .linkHandler(this);
288
276
 
@@ -297,6 +285,10 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
297
285
  }
298
286
  }
299
287
 
288
+ public void setEnableDoubleTapZoom(boolean enableDoubleTapZoom) {
289
+ this.enableDoubleTapZoom = enableDoubleTapZoom;
290
+ }
291
+
300
292
  public void setPath(String path) {
301
293
  this.path = path;
302
294
  }
@@ -19,7 +19,7 @@ public class RNPDFPdfViewManagerDelegate<T extends View, U extends BaseViewManag
19
19
  public RNPDFPdfViewManagerDelegate(U viewManager) {
20
20
  super(viewManager);
21
21
  }
22
- @Override
22
+
23
23
  public void setProperty(T view, String propName, @Nullable Object value) {
24
24
  switch (propName) {
25
25
  case "path":
@@ -55,6 +55,9 @@ public class RNPDFPdfViewManagerDelegate<T extends View, U extends BaseViewManag
55
55
  case "enableAnnotationRendering":
56
56
  mViewManager.setEnableAnnotationRendering(view, value == null ? false : (boolean) value);
57
57
  break;
58
+ case "enableDoubleTapZoom":
59
+ mViewManager.setEnableDoubleTapZoom(view, value == null ? false : (boolean) value);
60
+ break;
58
61
  case "enableAntialiasing":
59
62
  mViewManager.setEnableAntialiasing(view, value == null ? false : (boolean) value);
60
63
  break;
@@ -75,7 +78,6 @@ public class RNPDFPdfViewManagerDelegate<T extends View, U extends BaseViewManag
75
78
  }
76
79
  }
77
80
 
78
- @Override
79
81
  public void receiveCommand(T view, String commandName, ReadableArray args) {
80
82
  switch (commandName) {
81
83
  case "setNativePage":
@@ -24,6 +24,7 @@ public interface RNPDFPdfViewManagerInterface<T extends View> {
24
24
  void setEnablePaging(T view, boolean value);
25
25
  void setEnableRTL(T view, boolean value);
26
26
  void setEnableAnnotationRendering(T view, boolean value);
27
+ void setEnableDoubleTapZoom(T view, boolean value);
27
28
  void setEnableAntialiasing(T view, boolean value);
28
29
  void setFitPolicy(T view, int value);
29
30
  void setSpacing(T view, int value);
package/index.d.ts CHANGED
@@ -27,8 +27,9 @@ export type Source = {
27
27
  method?: string;
28
28
  };
29
29
 
30
- interface PdfProps {
30
+ export interface PdfProps {
31
31
  style?: ReactNative.StyleProp<ReactNative.ViewStyle>,
32
+ progressContainerStyle?: ReactNative.StyleProp<ReactNative.ViewStyle>,
32
33
  source: Source | number,
33
34
  page?: number,
34
35
  scale?: number,
@@ -44,6 +45,7 @@ interface PdfProps {
44
45
  enablePaging?: boolean,
45
46
  enableRTL?: boolean,
46
47
  enableAnnotationRendering?: boolean,
48
+ enableDoubleTapZoom?: boolean;
47
49
  fitPolicy?: number,
48
50
  trustAllCerts?: boolean,
49
51
  singlePage?: boolean,
package/index.js CHANGED
@@ -146,8 +146,8 @@ export default class Pdf extends Component {
146
146
  componentWillUnmount() {
147
147
  this._mounted = false;
148
148
  if (this.lastRNBFTask) {
149
- this.lastRNBFTask.cancel(err => {
150
- });
149
+ // this.lastRNBFTask.cancel(err => {
150
+ // });
151
151
  this.lastRNBFTask = null;
152
152
  }
153
153
 
@@ -276,6 +276,9 @@ export default class Pdf extends Component {
276
276
  if (this._mounted) {
277
277
  this.setState({progress: received / total});
278
278
  }
279
+ })
280
+ .catch(async (error) => {
281
+ this._onError(error);
279
282
  });
280
283
 
281
284
  this.lastRNBFTask
@@ -367,11 +370,18 @@ export default class Pdf extends Component {
367
370
  message[4] = message.splice(4).join('|');
368
371
  }
369
372
  if (message[0] === 'loadComplete') {
373
+ let tableContents;
374
+ try {
375
+ tableContents = message[4]&&JSON.parse(message[4]);
376
+ } catch(e) {
377
+ tableContents = message[4];
378
+ }
370
379
  this.props.onLoadComplete && this.props.onLoadComplete(Number(message[1]), this.state.path, {
371
380
  width: Number(message[2]),
372
381
  height: Number(message[3]),
373
382
  },
374
- message[4]&&JSON.parse(message[4]));
383
+ tableContents
384
+ );
375
385
  } else if (message[0] === 'pageChanged') {
376
386
  this.props.onPageChanged && this.props.onPageChanged(Number(message[1]), Number(message[2]));
377
387
  } else if (message[0] === 'error') {
@@ -399,7 +409,7 @@ export default class Pdf extends Component {
399
409
  <View style={[this.props.style,{overflow: 'hidden'}]}>
400
410
  {!this.state.isDownloaded?
401
411
  (<View
402
- style={styles.progressContainer}
412
+ style={[styles.progressContainer, this.props.progressContainerStyle]}
403
413
  >
404
414
  {this.props.renderActivityIndicator
405
415
  ? this.props.renderActivityIndicator(this.state.progress)
package/index.js.flow CHANGED
@@ -53,6 +53,7 @@ export type Props = {
53
53
  onPressLink?: (url: string) => void,
54
54
  page?: number,
55
55
  password?: string,
56
+ progressContainerStyle?: ViewStyleProp,
56
57
  scale?: number,
57
58
  source: AssetId | Source,
58
59
  spacing?: number,
@@ -43,6 +43,7 @@ UIView
43
43
  @property(nonatomic) BOOL enablePaging;
44
44
  @property(nonatomic) BOOL enableRTL;
45
45
  @property(nonatomic) BOOL enableAnnotationRendering;
46
+ @property(nonatomic) BOOL enableDoubleTapZoom;
46
47
  @property(nonatomic) int fitPolicy;
47
48
  @property(nonatomic) int spacing;
48
49
  @property(nonatomic, strong) NSString *password;
@@ -136,6 +136,10 @@ using namespace facebook::react;
136
136
  _enableAnnotationRendering = newProps.enableAnnotationRendering;
137
137
  [updatedPropNames addObject:@"enableAnnotationRendering"];
138
138
  }
139
+ if (_enableDoubleTapZoom != newProps.enableDoubleTapZoom) {
140
+ _enableDoubleTapZoom = newProps.enableDoubleTapZoom;
141
+ [updatedPropNames addObject:@"enableDoubleTapZoom"];
142
+ }
139
143
  if (_fitPolicy != newProps.fitPolicy) {
140
144
  _fitPolicy = newProps.fitPolicy;
141
145
  [updatedPropNames addObject:@"fitPolicy"];
@@ -242,6 +246,7 @@ using namespace facebook::react;
242
246
  _enablePaging = NO;
243
247
  _enableRTL = NO;
244
248
  _enableAnnotationRendering = YES;
249
+ _enableDoubleTapZoom = YES;
245
250
  _fitPolicy = 2;
246
251
  _spacing = 10;
247
252
  _singlePage = NO;
@@ -272,6 +277,12 @@ using namespace facebook::react;
272
277
  [[_pdfView document] setDelegate: self];
273
278
  [_pdfView setDelegate: self];
274
279
 
280
+ // Disable built-in double tap, so as not to conflict with custom recognizers.
281
+ for (UIGestureRecognizer *recognizer in _pdfView.gestureRecognizers) {
282
+ if ([recognizer isKindOfClass:[UITapGestureRecognizer class]]) {
283
+ recognizer.enabled = NO;
284
+ }
285
+ }
275
286
 
276
287
  [self bindTap];
277
288
  }
@@ -495,7 +506,16 @@ using namespace facebook::react;
495
506
  if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"enablePaging"] || [changedProps containsObject:@"horizontal"] || [changedProps containsObject:@"page"])) {
496
507
 
497
508
  PDFPage *pdfPage = [_pdfDocument pageAtIndex:_page-1];
498
- if (pdfPage) {
509
+ if (pdfPage && _page == 1) {
510
+ // goToDestination() would be better. However, there is an
511
+ // error in the pointLeftTop computation that often results in
512
+ // scrolling to the middle of the page.
513
+ // Special case workaround to make starting at the first page
514
+ // align acceptably.
515
+ dispatch_async(dispatch_get_main_queue(), ^{
516
+ [self->_pdfView goToRect:CGRectMake(0, NSUIntegerMax, 1, 1) onPage:pdfPage];
517
+ });
518
+ } else if (pdfPage) {
499
519
  CGRect pdfPageRect = [pdfPage boundsForBox:kPDFDisplayBoxCropBox];
500
520
 
501
521
  // some pdf with rotation, then adjust it
@@ -705,6 +725,19 @@ using namespace facebook::react;
705
725
  */
706
726
  - (void)handleDoubleTap:(UITapGestureRecognizer *)recognizer
707
727
  {
728
+
729
+ // Prevent double tap from selecting text.
730
+ dispatch_async(dispatch_get_main_queue(), ^{
731
+ [self->_pdfView clearSelection];
732
+ });
733
+
734
+ // Event appears to be consumed; broadcast for JS.
735
+ _onChange(@{ @"message": @"pageDoubleTap" });
736
+
737
+ if (!_enableDoubleTapZoom) {
738
+ return;
739
+ }
740
+
708
741
  // Cycle through min/mid/max scale factors to be consistent with Android
709
742
  float min = self->_pdfView.minScaleFactor/self->_fixScaleFactor;
710
743
  float max = self->_pdfView.maxScaleFactor/self->_fixScaleFactor;
@@ -38,6 +38,7 @@ RCT_EXPORT_VIEW_PROPERTY(showsVerticalScrollIndicator, BOOL);
38
38
  RCT_EXPORT_VIEW_PROPERTY(enablePaging, BOOL);
39
39
  RCT_EXPORT_VIEW_PROPERTY(enableRTL, BOOL);
40
40
  RCT_EXPORT_VIEW_PROPERTY(enableAnnotationRendering, BOOL);
41
+ RCT_EXPORT_VIEW_PROPERTY(enableDoubleTapZoom, BOOL);
41
42
  RCT_EXPORT_VIEW_PROPERTY(fitPolicy, int);
42
43
  RCT_EXPORT_VIEW_PROPERTY(spacing, int);
43
44
  RCT_EXPORT_VIEW_PROPERTY(password, NSString);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-pdf",
3
- "version": "6.7.3",
3
+ "version": "6.7.5",
4
4
  "summary": "A react native PDF view component",
5
5
  "description": "A react native PDF view component, support ios and android platform",
6
6
  "main": "index.js",
@@ -17,24 +17,11 @@ Pod::Spec.new do |s|
17
17
  s.framework = "PDFKit"
18
18
 
19
19
  if fabric_enabled
20
- folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
21
-
22
- s.pod_target_xcconfig = {
23
- 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/boost" "$(PODS_ROOT)/boost-for-react-native" "$(PODS_ROOT)/RCT-Folly"',
24
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
25
- }
26
20
  s.platforms = { ios: '11.0', tvos: '11.0' }
27
- s.compiler_flags = folly_compiler_flags + ' -DRCT_NEW_ARCH_ENABLED'
28
21
  s.source_files = 'ios/**/*.{h,m,mm,cpp}'
29
22
  s.requires_arc = true
23
+ install_modules_dependencies(s)
30
24
 
31
- s.dependency "React"
32
- s.dependency "React-RCTFabric"
33
- s.dependency "React-Codegen"
34
- s.dependency "RCT-Folly"
35
- s.dependency "RCTRequired"
36
- s.dependency "RCTTypeSafety"
37
- s.dependency "ReactCommon/turbomodule/core"
38
25
  else
39
26
  s.platform = :ios, '8.0'
40
27
  s.source_files = 'ios/**/*.{h,m,mm}'