react-native-pdf 6.3.0 → 6.6.0

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.
Files changed (116) hide show
  1. package/README.md +59 -69
  2. package/android/.gradle/5.6.1/fileChanges/last-build.bin +0 -0
  3. package/android/.gradle/5.6.1/fileHashes/fileHashes.lock +0 -0
  4. package/android/.gradle/5.6.1/gc.properties +0 -0
  5. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  6. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  7. package/android/.gradle/vcs-1/gc.properties +0 -0
  8. package/android/build.gradle +3 -3
  9. package/android/src/main/java/org/wonday/pdf/PdfView.java +21 -2
  10. package/ios/RCTPdf/PdfManager.m +11 -1
  11. package/ios/RCTPdf/RCTPdfView.h +2 -0
  12. package/ios/RCTPdf/RCTPdfView.m +21 -5
  13. package/ios/RCTPdf/RCTPdfViewManager.m +1 -1
  14. package/ios/RCTPdf.xcodeproj/xcuserdata/wonday.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  15. package/package.json +18 -6
  16. package/windows/RCTPdf/RCTPdfControl.xaml +0 -1
  17. package/windows/README.md +4 -8
  18. package/.babelrc +0 -3
  19. package/.github/workflows/windows-ci.yml +0 -39
  20. package/DoubleTapView.js +0 -126
  21. package/PdfManager.js +0 -31
  22. package/PdfPageView.js +0 -54
  23. package/PdfView.js +0 -416
  24. package/PdfViewFlatList.js +0 -31
  25. package/PinchZoomView.js +0 -126
  26. package/example/.eslintrc.js +0 -4
  27. package/example/PDFExample.js +0 -180
  28. package/example/__windows_tests__/TestPDF.js +0 -43
  29. package/example/android/app/BUCK +0 -55
  30. package/example/android/app/build.gradle +0 -210
  31. package/example/android/app/build_defs.bzl +0 -19
  32. package/example/android/app/proguard-rules.pro +0 -10
  33. package/example/android/app/src/debug/AndroidManifest.xml +0 -8
  34. package/example/android/app/src/main/AndroidManifest.xml +0 -26
  35. package/example/android/app/src/main/assets/test.pdf +0 -0
  36. package/example/android/app/src/main/java/com/pdfexample/MainActivity.java +0 -15
  37. package/example/android/app/src/main/java/com/pdfexample/MainApplication.java +0 -49
  38. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  39. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  40. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  41. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  42. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  43. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  44. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  45. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  46. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  47. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  48. package/example/android/app/src/main/res/values/strings.xml +0 -3
  49. package/example/android/app/src/main/res/values/styles.xml +0 -9
  50. package/example/android/build.gradle +0 -38
  51. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  52. package/example/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  53. package/example/android/gradle.properties +0 -21
  54. package/example/android/gradlew +0 -188
  55. package/example/android/gradlew.bat +0 -100
  56. package/example/android/settings.gradle +0 -3
  57. package/example/app.json +0 -4
  58. package/example/babel.config.js +0 -3
  59. package/example/index.js +0 -9
  60. package/example/ios/PDFExample/AppDelegate.h +0 -15
  61. package/example/ios/PDFExample/AppDelegate.m +0 -42
  62. package/example/ios/PDFExample/Base.lproj/LaunchScreen.xib +0 -42
  63. package/example/ios/PDFExample/Images.xcassets/AppIcon.appiconset/Contents.json +0 -38
  64. package/example/ios/PDFExample/Images.xcassets/Contents.json +0 -6
  65. package/example/ios/PDFExample/Info.plist +0 -57
  66. package/example/ios/PDFExample/main.m +0 -16
  67. package/example/ios/PDFExample-tvOS/Info.plist +0 -53
  68. package/example/ios/PDFExample-tvOSTests/Info.plist +0 -24
  69. package/example/ios/PDFExample.xcodeproj/project.pbxproj +0 -923
  70. package/example/ios/PDFExample.xcodeproj/xcshareddata/xcschemes/PDFExample-tvOS.xcscheme +0 -129
  71. package/example/ios/PDFExample.xcodeproj/xcshareddata/xcschemes/PDFExample.xcscheme +0 -129
  72. package/example/ios/PDFExample.xcworkspace/contents.xcworkspacedata +0 -10
  73. package/example/ios/PDFExampleTests/Info.plist +0 -24
  74. package/example/ios/PDFExampleTests/PDFExampleTests.m +0 -68
  75. package/example/ios/Podfile +0 -47
  76. package/example/ios/Podfile.lock +0 -205
  77. package/example/jest-windows/driver.setup.js +0 -12
  78. package/example/jest-windows/jest.setup.js +0 -1
  79. package/example/jest.windows.config.js +0 -4
  80. package/example/metro.config.js +0 -29
  81. package/example/package.json +0 -48
  82. package/example/test.pdf +0 -0
  83. package/example/windows/PDFExample/App.cpp +0 -80
  84. package/example/windows/PDFExample/App.h +0 -20
  85. package/example/windows/PDFExample/App.idl +0 -3
  86. package/example/windows/PDFExample/App.xaml +0 -10
  87. package/example/windows/PDFExample/Assets/LockScreenLogo.scale-200.png +0 -0
  88. package/example/windows/PDFExample/Assets/SplashScreen.scale-200.png +0 -0
  89. package/example/windows/PDFExample/Assets/Square150x150Logo.scale-200.png +0 -0
  90. package/example/windows/PDFExample/Assets/Square44x44Logo.scale-200.png +0 -0
  91. package/example/windows/PDFExample/Assets/Square44x44Logo.targetsize-24_altform-unplated.png +0 -0
  92. package/example/windows/PDFExample/Assets/StoreLogo.png +0 -0
  93. package/example/windows/PDFExample/Assets/Wide310x150Logo.scale-200.png +0 -0
  94. package/example/windows/PDFExample/AutolinkedNativeModules.g.cpp +0 -18
  95. package/example/windows/PDFExample/AutolinkedNativeModules.g.h +0 -10
  96. package/example/windows/PDFExample/AutolinkedNativeModules.g.props +0 -6
  97. package/example/windows/PDFExample/AutolinkedNativeModules.g.targets +0 -10
  98. package/example/windows/PDFExample/MainPage.cpp +0 -24
  99. package/example/windows/PDFExample/MainPage.h +0 -21
  100. package/example/windows/PDFExample/MainPage.idl +0 -8
  101. package/example/windows/PDFExample/MainPage.xaml +0 -16
  102. package/example/windows/PDFExample/PDFExample.vcxproj +0 -205
  103. package/example/windows/PDFExample/PDFExample.vcxproj.filters +0 -64
  104. package/example/windows/PDFExample/PDFExample_TemporaryKey.pfx +0 -0
  105. package/example/windows/PDFExample/Package.appxmanifest +0 -52
  106. package/example/windows/PDFExample/PropertySheet.props +0 -16
  107. package/example/windows/PDFExample/ReactPackageProvider.cpp +0 -18
  108. package/example/windows/PDFExample/ReactPackageProvider.h +0 -15
  109. package/example/windows/PDFExample/packages.config +0 -5
  110. package/example/windows/PDFExample/pch.cpp +0 -1
  111. package/example/windows/PDFExample/pch.h +0 -29
  112. package/example/windows/PDFExample.sln +0 -264
  113. package/index.d.ts +0 -51
  114. package/index.js +0 -493
  115. package/index.js.flow +0 -63
  116. package/issue_template.md +0 -13
package/README.md CHANGED
@@ -5,7 +5,7 @@ A react native PDF view component (cross-platform support)
5
5
 
6
6
  ### Feature
7
7
 
8
- * read a PDF from url/local file/asset and can cache it.
8
+ * read a PDF from url, blob, local file or asset and can cache it.
9
9
  * display horizontally or vertically
10
10
  * drag and zoom
11
11
  * double tap for zoom
@@ -13,36 +13,27 @@ A react native PDF view component (cross-platform support)
13
13
  * jump to a specific page in the pdf
14
14
 
15
15
  ### Supported versions
16
- We use [`rn-fetch-blob`](https://github.com/joltup/rn-fetch-blob) to handle file system access in this package,
17
- So you should install react-native-pdf and rn-fetch-blob
16
+ We use [`react-native-blob-util`](https://github.com/RonRadtke/react-native-blob-util) to handle file system access in this package,
17
+ So you should install react-native-pdf and react-native-blob-util
18
18
 
19
- > The table below shows the supported versions of React Native and rn-fetch-blob for different versions of `react-native-pdf`.
19
+ > The table below shows the supported versions of React Native and react-native-blob-util for different versions of `react-native-pdf`.
20
20
 
21
- | React Native | 0.4x - 0.56 | 0.57 | 0.60+ | 0.62+ |
22
- | ------------------------- | --------------- | ------- | -------- | -------- |
23
- | react-native-pdf | 4.x.x - 5.0.x | 5.0.9+ | 6.0.0+ | 6.2.0+ |
24
- | rn-fetch-blob | 0.10.15 | 0.10.15 | 0.11.0+ | 0.11.0+ |
25
- | progress-bar-android | | | | 1.0.3+ |
26
- | progress-view | | | | 1.0.3+ |
21
+ | React Native | 0.4x - 0.56 | 0.57 | 0.60+ | 0.62+ | 0.62+ |
22
+ | ------------------------- | --------------- | ------- | -------- | -------- | -------- |
23
+ | react-native-pdf | 4.x.x - 5.0.x | 5.0.9+ | 6.0.0+ | 6.2.0+ | 6.4.0+ |
24
+ | react-native-blob-util | | | | | 0.13.7+ |
27
25
 
28
- Currently, Windows support is partial. For Windows, it's necessary to install `rn-fetch-blob` from the [PR that adds Windows support](https://github.com/joltup/rn-fetch-blob/pull/701):
29
- ```
30
- yarn add github:joltup/rn-fetch-blob#pull/701/head
31
- ```
26
+
27
+ > 🚨 Expo: This package is not available in the [Expo Go](https://expo.dev/client) app. Learn how you can use this package in [Custom Dev Clients](https://docs.expo.dev/development/getting-started/) via the out-of-tree [Expo Config Plugin](https://github.com/expo/config-plugins/tree/master/packages/react-native-pdf). Example: [`with-pdf`](https://github.com/expo/examples/tree/master/with-pdf).
32
28
 
33
29
  ### Installation
34
30
 
35
31
  ```bash
36
32
  # Using npm
37
- npm install react-native-pdf rn-fetch-blob @react-native-community/progress-bar-android @react-native-community/progress-view --save
33
+ npm install react-native-pdf react-native-blob-util --save
38
34
 
39
35
  # or using yarn:
40
- yarn add react-native-pdf rn-fetch-blob @react-native-community/progress-bar-android @react-native-community/progress-view
41
- ```
42
-
43
- For Windows, it's necessary to install `rn-fetch-blob` from the [PR that adds Windows support](https://github.com/joltup/rn-fetch-blob/pull/701):
44
- ```
45
- yarn add github:joltup/rn-fetch-blob#pull/701/head
36
+ yarn add react-native-pdf react-native-blob-util
46
37
  ```
47
38
 
48
39
  Then follow the instructions for your platform to link react-native-pdf into your project:
@@ -58,9 +49,7 @@ Run `pod install` in the `ios` directory. Linking is not required in React Nativ
58
49
  **React Native 0.59 and below**
59
50
 
60
51
  ```bash
61
- react-native link rn-fetch-blob
62
- react-native link @react-native-community/progress-bar-android
63
- react-native link @react-native-community/progress-view
52
+ react-native link react-native-blob-util
64
53
  react-native link react-native-pdf
65
54
  ```
66
55
  </details>
@@ -87,9 +76,7 @@ android {
87
76
 
88
77
  **React Native 0.59.0 and below**
89
78
  ```bash
90
- react-native link rn-fetch-blob
91
- react-native link @react-native-community/progress-bar-android
92
- react-native link @react-native-community/progress-view
79
+ react-native link react-native-blob-util
93
80
  react-native link react-native-pdf
94
81
  ```
95
82
 
@@ -102,16 +89,16 @@ react-native link react-native-pdf
102
89
 
103
90
  - Open your solution in Visual Studio 2019 (eg. `windows\yourapp.sln`)
104
91
  - Right-click Solution icon in Solution Explorer > Add > Existing Project...
105
- - Add `node_modules\@react-native-community\progress-view\windows\progress-view\progress-view.vcxproj`
106
92
  - If running RNW 0.62: add `node_modules\react-native-pdf\windows\RCTPdf\RCTPdf.vcxproj`
107
- - If running RNW 0.62: add `node_modules\rn-fetch-blob\windows\RNFetchBlob\RNFetchBlob.vcxproj`
93
+ - If running RNW 0.62: add `node_modules\react-native-blob-util\windows\ReactNativeBlobUtil\ReactNativeBlobUtil.vcxproj`
108
94
  - Right-click main application project > Add > Reference...
109
- - Select `progress-view` and in Solution Projects
110
- - If running 0.62, also select `RCTPdf` and `RNFetchBlob`
111
- - In app `pch.h` add `#include "winrt/progress_view.h"` and `#include "winrt/RCTPdf.h"`
112
- - If running 0.62, also select `#include "winrt/RNFetchBlob.h"`
95
+ - Select `progress-view` and in Solution Projects
96
+ - If running 0.62, also select `RCTPdf` and `ReactNativeBlobUtil`
97
+ - In app `pch.h` add `#include "winrt/RCTPdf.h"`
98
+ - If running 0.62, also select `#include "winrt/ReactNativeBlobUtil.h"`
113
99
  - In `App.cpp` add `PackageProviders().Append(winrt::progress_view::ReactPackageProvider());` before `InitializeComponent();`
114
- - If running RNW 0.62, also add `PackageProviders().Append(winrt::RCTPdf::ReactPackageProvider());` and `PackageProviders().Append(winrt::RNFetchBlob::ReactPackageProvider());`
100
+ - If running RNW 0.62, also add `PackageProviders().Append(winrt::RCTPdf::ReactPackageProvider());` and `PackageProviders().Append(winrt::ReactNativeBlobUtil::ReactPackageProvider());`
101
+
115
102
 
116
103
  #### Bundling PDFs with the app
117
104
  To add a `test.pdf` like in the example add:
@@ -182,6 +169,26 @@ react-native run-ios
182
169
  <details>
183
170
  <summary>ChangeLog details</summary>
184
171
 
172
+ v6.6.0
173
+ 1. Fixed: Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'
174
+ 2. Added: Decode File Path for iOS
175
+ 3. Improved: prefer current page for calculating scale factor on fit
176
+ 4. Improved: Typescript version source
177
+
178
+ v6.5.0
179
+ 1. Fixed: replace mavenCentral with maven
180
+ 2. Breaking Change(Android): replace deprecated repository: jcenter()
181
+ 3. Fixed: loading progress
182
+ 4. Added: Typed "source" prop
183
+ 5. Removed: dependency to fbjs
184
+
185
+ v6.4.0
186
+ 1. Remove sample for reducing NPM package size
187
+ 2. Add support for setting a filename for the cached pdf file
188
+ 3. Use react-native-blob-util instead of rn-fetch-blob
189
+ 4. Add blob support
190
+ 5. remove progress-view dependency
191
+
185
192
  v6.3.0
186
193
  1. Add windows support
187
194
  2. Fixed some bugs
@@ -221,25 +228,6 @@ v6.0.0
221
228
  1. Add JS callback onPressLink for pdf link press listener
222
229
  2. Fix calling setState while unmounted
223
230
 
224
- v5.1.7
225
- 1. Downgraded to AndroidPdfViewer 3.1.0-beta.1
226
-
227
- v5.1.6
228
- 1. Fixed componentWillReceiveProps and componentWillMount warnings
229
-
230
- v5.1.5
231
- 1. Added setPage() method
232
- 2. Upgraded to AndroidPdfViewer to 3.2.0-beta.1
233
- 3. Fixed some codes ,readme and sample
234
-
235
- v5.1.4
236
- 1. Updated example project to RN 0.60.4
237
- 2. Fixed blank view after native module got recycled in onDetachedFromWindow event
238
- 3. Restore singleTap, only callback, do not change scale
239
-
240
- v5.1.3
241
- 1. Removed singleTap action from iOS, make the same with Android.
242
-
243
231
 
244
232
  [[more]](https://github.com/wonday/react-native-pdf/releases)
245
233
 
@@ -258,38 +246,38 @@ v5.1.3
258
246
 
259
247
  import React from 'react';
260
248
  import { StyleSheet, Dimensions, View } from 'react-native';
261
-
262
249
  import Pdf from 'react-native-pdf';
263
250
 
264
251
  export default class PDFExample extends React.Component {
265
252
  render() {
266
- const source = {uri:'http://samples.leanpub.com/thereactnativebook-sample.pdf',cache:true};
253
+ const source = { uri: 'http://samples.leanpub.com/thereactnativebook-sample.pdf', cache: true };
267
254
  //const source = require('./test.pdf'); // ios only
268
- //const source = {uri:'bundle-assets://test.pdf'};
269
-
255
+ //const source = {uri:'bundle-assets://test.pdf' };
270
256
  //const source = {uri:'file:///sdcard/test.pdf'};
271
257
  //const source = {uri:"data:application/pdf;base64,JVBERi0xLjcKJc..."};
258
+ //const source = {uri:"content://com.example.blobs/xxxxxxxx-...?offset=0&size=xxx"};
259
+ //const source = {uri:"blob:xxxxxxxx-...?offset=0&size=xxx"};
272
260
 
273
261
  return (
274
262
  <View style={styles.container}>
275
263
  <Pdf
276
264
  source={source}
277
- onLoadComplete={(numberOfPages,filePath)=>{
278
- console.log(`number of pages: ${numberOfPages}`);
265
+ onLoadComplete={(numberOfPages,filePath) => {
266
+ console.log(`Number of pages: ${numberOfPages}`);
279
267
  }}
280
- onPageChanged={(page,numberOfPages)=>{
281
- console.log(`current page: ${page}`);
268
+ onPageChanged={(page,numberOfPages) => {
269
+ console.log(`Current page: ${page}`);
282
270
  }}
283
- onError={(error)=>{
271
+ onError={(error) => {
284
272
  console.log(error);
285
273
  }}
286
- onPressLink={(uri)=>{
287
- console.log(`Link presse: ${uri}`)
274
+ onPressLink={(uri) => {
275
+ console.log(`Link pressed: ${uri}`);
288
276
  }}
289
277
  style={styles.pdf}/>
290
278
  </View>
291
279
  )
292
- }
280
+ }
293
281
  }
294
282
 
295
283
  const styles = StyleSheet.create({
@@ -324,14 +312,13 @@ const styles = StyleSheet.create({
324
312
  | spacing | number | 10 | the breaker size between pages| ✔ | ✔ | ✔ | <3.0 |
325
313
  | password | string | "" | pdf password, if password error, will call OnError() with message "Password required or incorrect password." | ✔ | ✔ | ✔ | <3.0 |
326
314
  | style | object | {backgroundColor:"#eee"} | support normal view style, you can use this to set border/spacing color... | ✔ | ✔ | ✔ | <3.0 |
327
- | activityIndicator | Component | <ProgressBar/> | when loading show it as an indicator, you can use your component| ✔ | ✔ | ✖ | <3.0 |
328
- | activityIndicatorProps | object | {color:'#009900', progressTintColor:'#009900'} | activityIndicator props | ✔ | ✔ | ✖ | 3.1 |
315
+ | renderActivityIndicator | (progress) => Component | <ProgressBar/> | when loading show it as an indicator, you can use your component| ✔ | ✔ | ✖ | <3.0 |
329
316
  | 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 |
330
317
  | enablePaging | bool | false | only show one page in screen | ✔ | ✔ | ✔ | 5.0.1 |
331
318
  | enableRTL | bool | false | scroll page as "page3, page2, page1" | ✔ | ✖ | ✔ | 5.0.1 |
332
319
  | enableAnnotationRendering | bool | true | enable rendering annotation, notice:iOS only support initial setting,not support realtime changing | ✔ | ✔ | ✖ | 5.0.3 |
333
320
  | trustAllCerts | bool | true | Allow connections to servers with self-signed certification | ✔ | ✔ | ✖ | 6.0.? |
334
- | singlePage | bool | false | Only show first page, useful for thumbnail views | ✔ | ✔ | ✔ | 6.1.2 |
321
+ | singlePage | bool | false | Only show first page, useful for thumbnail views | ✔ | ✔ | ✔ | 6.2.1 |
335
322
  | onLoadProgress | function(percent) | null | callback when loading, return loading progress (0-1) | ✔ | ✔ | ✖ | <3.0 |
336
323
  | 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 |
337
324
  | onPageChanged | function(page,numberOfPages) | null | callback when page changed ,return current page and total page count | ✔ | ✔ | ✔ | <3.0 |
@@ -346,6 +333,7 @@ const styles = StyleSheet.create({
346
333
  | ------------ | ----------- | ------- | --- | ------- | ------- |
347
334
  | uri | pdf source, see the forllowing for detail.| required | ✔ | ✔ | ✔ |
348
335
  | cache | use cache or not | false | ✔ | ✔ | ✖ |
336
+ | cacheFileName | specific file name for cached pdf file | SHA1(uri) result | ✔ | ✔ | ✖ |
349
337
  | expiration | cache file expired seconds (0 is not expired) | 0 | ✔ | ✔ | ✖ |
350
338
  | method | request method when uri is a url | "GET" | ✔ | ✔ | ✖ |
351
339
  | headers | request headers when uri is a url | {} | ✔ | ✔ | ✖ |
@@ -361,8 +349,10 @@ const styles = StyleSheet.create({
361
349
  | `{uri:"data:application/pdf;base64,JVBERi0xLjcKJc..."}` | load pdf from base64 string | ✔ | ✔ | ✔ |
362
350
  | `{uri:"file:///absolute/path/to/xxx.pdf"}` | load pdf from local file system | ✔ | ✔ | ✔ |
363
351
  | `{uri:"ms-appx:///xxx.pdf"}}` | load pdf bundled with UWP app | ✖ | ✖ | ✔ |
352
+ | `{uri:"content://com.example.blobs/xxxxxxxx-...?offset=0&size=xxx"}` | load pdf from content URI | ✔* | ✖ | ✖ |
353
+ | `{uri:"blob:xxxxxxxx-...?offset=0&size=xxx"}` | load pdf from blob URL | ✖ | ✔ | ✖ |
364
354
 
365
-
355
+ \*) requires building React Native from source with [this patch](https://github.com/facebook/react-native/pull/31789)
366
356
  ### Methods
367
357
  * [setPage](#setPage)
368
358
 
File without changes
@@ -0,0 +1,2 @@
1
+ #Sat Oct 12 21:44:37 CST 2019
2
+ gradle.version=5.6.1
File without changes
@@ -2,7 +2,7 @@ description = 'react-native-pdf'
2
2
 
3
3
  buildscript {
4
4
  repositories {
5
- jcenter()
5
+ mavenCentral()
6
6
  google()
7
7
  }
8
8
 
@@ -12,11 +12,11 @@ buildscript {
12
12
  }
13
13
 
14
14
  repositories {
15
- jcenter()
15
+ mavenCentral()
16
16
  maven {
17
17
  url 'https://jitpack.io'
18
18
  content {
19
- // Use Jitpack only for AndroidPdfViewer; the rest is hosted at jcenter.
19
+ // Use Jitpack only for AndroidPdfViewer; the rest is hosted at mavenCentral.
20
20
  includeGroup "com.github.TalbotGooday"
21
21
  }
22
22
  }
@@ -10,6 +10,7 @@ package org.wonday.pdf;
10
10
 
11
11
  import java.io.File;
12
12
 
13
+ import android.content.ContentResolver;
13
14
  import android.content.Context;
14
15
  import android.view.View;
15
16
  import android.view.ViewGroup;
@@ -49,6 +50,9 @@ import com.facebook.common.logging.FLog;
49
50
  import com.facebook.react.common.ReactConstants;
50
51
 
51
52
  import static java.lang.String.format;
53
+
54
+ import java.io.FileNotFoundException;
55
+ import java.io.InputStream;
52
56
  import java.lang.ClassCastException;
53
57
 
54
58
  import com.shockwave.pdfium.PdfDocument;
@@ -222,8 +226,23 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
222
226
  Constants.Pinch.MINIMUM_ZOOM = this.minScale;
223
227
  Constants.Pinch.MAXIMUM_ZOOM = this.maxScale;
224
228
 
225
- Configurator configurator = this.fromUri(getURI(this.path))
226
- .defaultPage(this.page-1)
229
+ Configurator configurator;
230
+
231
+ if (this.path.startsWith("content://")) {
232
+ ContentResolver contentResolver = getContext().getContentResolver();
233
+ InputStream inputStream = null;
234
+ Uri uri = Uri.parse(this.path);
235
+ try {
236
+ inputStream = contentResolver.openInputStream(uri);
237
+ } catch (FileNotFoundException e) {
238
+ throw new RuntimeException(e.getMessage());
239
+ }
240
+ configurator = this.fromStream(inputStream);
241
+ } else {
242
+ configurator = this.fromUri(getURI(this.path));
243
+ }
244
+
245
+ configurator.defaultPage(this.page-1)
227
246
  .swipeHorizontal(this.horizontal)
228
247
  .onPageChange(this)
229
248
  .onLoad(this)
@@ -50,7 +50,17 @@ RCT_EXPORT_METHOD(loadFile:(NSString *)path
50
50
 
51
51
  if (path != nil && path.length != 0) {
52
52
 
53
- NSURL *pdfURL = [NSURL fileURLWithPath:path];
53
+ NSString *decodedPath = (__bridge_transfer NSString *)CFURLCreateStringByReplacingPercentEscapes(NULL, (CFStringRef)path, CFSTR(""));
54
+
55
+ NSString *finalPath = NULL;
56
+ if (decodedPath == NULL) {
57
+ // use orignal provided path
58
+ finalPath = path;
59
+ } else {
60
+ finalPath = decodedPath;
61
+ }
62
+
63
+ NSURL *pdfURL = [NSURL fileURLWithPath:finalPath];
54
64
  CGPDFDocumentRef pdfRef = CGPDFDocumentCreateWithURL((__bridge CFURLRef) pdfURL);
55
65
 
56
66
  if (pdfRef == NULL) {
@@ -22,6 +22,8 @@
22
22
 
23
23
  NS_CLASS_AVAILABLE_IOS(11_0) @interface RCTPdfView : UIView <UIGestureRecognizerDelegate>
24
24
 
25
+ - (instancetype)initWithBridge:(RCTBridge *)bridge;
26
+
25
27
  @property(nonatomic, strong) NSString *path;
26
28
  @property(nonatomic) int page;
27
29
  @property(nonatomic) float scale;
@@ -17,11 +17,13 @@
17
17
  #import <React/RCTEventDispatcher.h>
18
18
  #import <React/UIView+React.h>
19
19
  #import <React/RCTLog.h>
20
+ #import <React/RCTBlobManager.h>
20
21
  #else
21
22
  #import "RCTBridgeModule.h"
22
23
  #import "RCTEventDispatcher.h"
23
24
  #import "UIView+React.h"
24
25
  #import "RCTLog.h"
26
+ #import <RCTBlobManager.h">
25
27
  #endif
26
28
 
27
29
  #ifndef __OPTIMIZE__
@@ -39,6 +41,7 @@ const float MIN_SCALE = 1.0f;
39
41
 
40
42
  @implementation RCTPdfView
41
43
  {
44
+ RCTBridge *_bridge;
42
45
  PDFDocument *_pdfDocument;
43
46
  PDFView *_pdfView;
44
47
  PDFOutline *root;
@@ -47,11 +50,12 @@ const float MIN_SCALE = 1.0f;
47
50
  NSArray<NSString *> *_changedProps;
48
51
  }
49
52
 
50
- - (instancetype)init
53
+ - (instancetype)initWithBridge:(RCTBridge *)bridge
51
54
  {
52
55
  self = [super init];
53
56
  if (self) {
54
57
 
58
+ _bridge = bridge;
55
59
  _page = 1;
56
60
  _scale = 1;
57
61
  _minScale = MIN_SCALE;
@@ -114,14 +118,26 @@ const float MIN_SCALE = 1.0f;
114
118
 
115
119
  if ([changedProps containsObject:@"path"]) {
116
120
 
117
- NSURL *fileURL = [NSURL fileURLWithPath:_path];
118
121
 
119
122
  if (_pdfDocument != Nil) {
120
123
  //Release old doc
121
124
  _pdfDocument = Nil;
122
125
  }
123
-
124
- _pdfDocument = [[PDFDocument alloc] initWithURL:fileURL];
126
+
127
+ if ([_path hasPrefix:@"blob:"]) {
128
+ RCTBlobManager *blobManager = [_bridge moduleForName:@"BlobModule"];
129
+ NSURL *blobURL = [NSURL URLWithString:_path];
130
+ NSData *blobData = [blobManager resolveURL:blobURL];
131
+ if (blobData != nil) {
132
+ _pdfDocument = [[PDFDocument alloc] initWithData:blobData];
133
+ }
134
+ } else {
135
+
136
+ // decode file path
137
+ _path = (__bridge_transfer NSString *)CFURLCreateStringByReplacingPercentEscapes(NULL, (CFStringRef)_path, CFSTR(""));
138
+ NSURL *fileURL = [NSURL fileURLWithPath:_path];
139
+ _pdfDocument = [[PDFDocument alloc] initWithURL:fileURL];
140
+ }
125
141
 
126
142
  if (_pdfDocument) {
127
143
 
@@ -187,7 +203,7 @@ const float MIN_SCALE = 1.0f;
187
203
 
188
204
  if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"fitPolicy"] || [changedProps containsObject:@"minScale"] || [changedProps containsObject:@"maxScale"])) {
189
205
 
190
- PDFPage *pdfPage = [_pdfDocument pageAtIndex:_pdfDocument.pageCount-1];
206
+ PDFPage *pdfPage = _pdfView.currentPage ? _pdfView.currentPage : [_pdfDocument pageAtIndex:_pdfDocument.pageCount-1];
191
207
  CGRect pdfPageRect = [pdfPage boundsForBox:kPDFDisplayBoxCropBox];
192
208
 
193
209
  // some pdf with rotation, then adjust it
@@ -20,7 +20,7 @@ RCT_EXPORT_MODULE()
20
20
  {
21
21
  if([[[UIDevice currentDevice] systemVersion] compare:@"11.0" options:NSNumericSearch] == NSOrderedDescending
22
22
  || [[[UIDevice currentDevice] systemVersion] compare:@"11.0" options:NSNumericSearch] == NSOrderedSame) {
23
- return [[RCTPdfView alloc] init];
23
+ return [[RCTPdfView alloc] initWithBridge:self.bridge];
24
24
  } else {
25
25
  return NULL;
26
26
  }
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>RCTPdf.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>52</integer>
11
+ </dict>
12
+ </dict>
13
+ </dict>
14
+ </plist>
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "react-native-pdf",
3
- "version": "6.3.0",
3
+ "version": "6.6.0",
4
4
  "summary": "A react native PDF view component",
5
5
  "description": "A react native PDF view component, support ios and android platform",
6
- "main": "index.js",
7
- "typings": "./index.d.ts",
6
+ "main": "dist/index.js",
8
7
  "repository": {
9
8
  "type": "git",
10
9
  "url": "git+https://github.com/wonday/react-native-pdf.git"
@@ -29,8 +28,21 @@
29
28
  },
30
29
  "dependencies": {
31
30
  "crypto-js": "^3.2.0",
32
- "prop-types": "^15.7.2",
33
- "@react-native-community/progress-bar-android": "^1.0.4",
34
- "@react-native-community/progress-view": "^1.0.3"
31
+ "deprecated-react-native-prop-types": "^2.3.0"
32
+ },
33
+ "devDependencies": {
34
+ "@types/react-native": "^0.68.0",
35
+ "react-native": "^0.68.0",
36
+ "typescript": "^4.7.4"
37
+ },
38
+ "files": [
39
+ "android/",
40
+ "ios/",
41
+ "windows/",
42
+ "dist/",
43
+ "react-native-pdf.podspec"
44
+ ],
45
+ "scripts": {
46
+ "build": "rm -rf dist/ && tsc"
35
47
  }
36
48
  }
@@ -18,7 +18,6 @@
18
18
  UseSystemFocusVisuals="False"
19
19
  PointerWheelChanged="PagesContainer_PointerWheelChanged"
20
20
  Tapped="PagesContainer_Tapped"
21
- DoubleTapped="PagesContainer_DoubleTapped"
22
21
  ViewChanged="PagesContainer_ViewChanged"
23
22
  >
24
23
  <ItemsControl x:Name="Pages" HorizontalAlignment="Center"
package/windows/README.md CHANGED
@@ -1,18 +1,14 @@
1
1
  # react-native-pdf Windows Implementation
2
2
 
3
- Since the module uses react-native-progress-view, it also needs to be referenced in the App:
4
3
  - Open your solution in Visual Studio 2019 (eg. `windows\yourapp.sln`)
5
4
  - Right-click Solution icon in Solution Explorer > Add > Existing Project...
6
- - Add `node_modules\@react-native-community\progress-view\windows\progress-view\progress-view.vcxproj`
7
- - If running RNW 0.62: add `node_modules\react-native-pdf\windows\RCTPdf\RCTPdf.vcxproj`
8
- - If running RNW 0.62: add `node_modules\rn-fetch-blob\windows\RNFetchBlob\RNFetchBlob.vcxproj`
5
+ - If running RNW 0.62: add `node_modules\react-native-pdf\windows\RCTPdf\RCTPdf.vcxproj`
6
+ - If running RNW 0.62: add `node_modules\rn-fetch-blob\windows\RNFetchBlob\RNFetchBlob.vcxproj`
9
7
  - Right-click main application project > Add > Reference...
10
- - Select `progress-view` and in Solution Projects
11
8
  - If running 0.62, also select `RCTPdf` and `RNFetchBlob`
12
- - In app `pch.h` add `#include "winrt/progress_view.h"` and `#include "winrt/RCTPdf.h"`
9
+ - In app `pch.h` add `#include "winrt/RCTPdf.h"`
13
10
  - If running 0.62, also select `#include "winrt/RNFetchBlob.h"`
14
- - In `App.cpp` add `PackageProviders().Append(winrt::progress_view::ReactPackageProvider());` before `InitializeComponent();`
15
- - If running RNW 0.62, also add `PackageProviders().Append(winrt::RCTPdf::ReactPackageProvider());` and `PackageProviders().Append(winrt::RNFetchBlob::ReactPackageProvider());`
11
+ - If running RNW 0.62, add `PackageProviders().Append(winrt::RCTPdf::ReactPackageProvider());` and `PackageProviders().Append(winrt::RNFetchBlob::ReactPackageProvider());` before `InitializeComponent();`
16
12
 
17
13
 
18
14
  ## Bundling PDFs with the app
package/.babelrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "presets": ["react-native"]
3
- }
@@ -1,39 +0,0 @@
1
- name: Windows CI
2
- on: [pull_request]
3
-
4
- jobs:
5
- run-windows-tests:
6
- name: Build & run tests
7
- runs-on: windows-2019
8
-
9
- steps:
10
- - uses: actions/checkout@v2
11
- name: Checkout Code
12
-
13
- - name: Setup Node.js
14
- uses: actions/setup-node@v1
15
- with:
16
- node-version: '12.18.3'
17
-
18
- - name: Setup MSBuild
19
- uses: microsoft/setup-msbuild@v1
20
- with:
21
- vs-version: 16.5
22
-
23
- - name: Install example modules
24
- run: |
25
- cd example
26
- yarn --pure-lockfile
27
- - name: Build release
28
- run: |
29
- cd example
30
- npx react-native run-windows --release --no-packager --no-launch --logging
31
- - name: Start Appium server
32
- shell: powershell
33
- run: |
34
- cd example
35
- Start-Process PowerShell -ArgumentList "yarn appium"
36
- - name: Run tests
37
- run: |
38
- cd example
39
- yarn test:windows