react-native-pdf 6.6.1 → 6.7.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 (31) hide show
  1. package/DoubleTapView.js +125 -0
  2. package/PdfManager.js +26 -0
  3. package/PdfPageView.js +53 -0
  4. package/PdfView.js +416 -0
  5. package/PdfViewFlatList.js +31 -0
  6. package/PinchZoomView.js +125 -0
  7. package/README.md +25 -46
  8. package/android/build.gradle +71 -13
  9. package/android/src/main/java/org/wonday/pdf/{RCTPdfManager.java → PdfManager.java} +57 -21
  10. package/android/src/main/java/org/wonday/pdf/PdfView.java +25 -0
  11. package/android/src/main/java/org/wonday/pdf/{RCTPdfView.java → RNPDFPackage.java} +2 -3
  12. package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.java +86 -0
  13. package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.java +33 -0
  14. package/fabric/RNPDFPdfNativeComponent.js +46 -0
  15. package/index.d.ts +11 -67
  16. package/index.js +464 -0
  17. package/index.js.flow +2 -0
  18. package/ios/{RCTPdf/PdfManager.m → RNPDFPdf/PdfManager.mm} +1 -1
  19. package/ios/{RCTPdf/RCTPdfPageView.h → RNPDFPdf/RNPDFPdfPageView.h} +1 -1
  20. package/ios/{RCTPdf/RCTPdfPageView.m → RNPDFPdf/RNPDFPdfPageView.mm} +5 -5
  21. package/ios/{RCTPdf/RCTPdfPageViewManager.h → RNPDFPdf/RNPDFPdfPageViewManager.h} +1 -1
  22. package/ios/{RCTPdf/RCTPdfPageViewManager.m → RNPDFPdf/RNPDFPdfPageViewManager.mm} +4 -4
  23. package/ios/{RCTPdf/RCTPdfView.h → RNPDFPdf/RNPDFPdfView.h} +15 -5
  24. package/ios/{RCTPdf/RCTPdfView.m → RNPDFPdf/RNPDFPdfView.mm} +321 -54
  25. package/ios/{RCTPdf/RCTPdfViewManager.h → RNPDFPdf/RNPDFPdfViewManager.h} +1 -1
  26. package/ios/{RCTPdf/RCTPdfViewManager.m → RNPDFPdf/RNPDFPdfViewManager.mm} +7 -5
  27. package/ios/{RCTPdf.xcodeproj → RNPDFPdf.xcodeproj}/project.pbxproj +38 -38
  28. package/package.json +22 -11
  29. package/react-native-pdf.podspec +28 -3
  30. package/windows/RCTPdf/pch.h +2 -0
  31. /package/ios/{RCTPdf → RNPDFPdf}/PdfManager.h +0 -0
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @flow
3
+ * @format
4
+ */
5
+ 'use strict';
6
+
7
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
8
+ import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
9
+
10
+ type ChangeEvent = $ReadOnly<{|
11
+ message: ?string,
12
+ |}>;
13
+
14
+ export type NativeProps = $ReadOnly<{|
15
+ ...ViewProps,
16
+ path: ?string,
17
+ page: ?Int32,
18
+ scale: ?Float,
19
+ minScale: ?Float,
20
+ maxScale: ?Float,
21
+ horizontal: ?boolean,
22
+ enablePaging: ?boolean,
23
+ enableRTL: ?boolean,
24
+ enableAnnotationRendering: ?boolean,
25
+ showsHorizontalScrollIndicator: ?boolean,
26
+ showsVerticalScrollIndicator: ?boolean,
27
+ enableAntialiasing: ?boolean,
28
+ fitPolicy: ?Int32,
29
+ spacing: ?Int32,
30
+ password: ?string,
31
+ onChange: ?BubblingEventHandler<ChangeEvent>,
32
+ singlePage: ?boolean,
33
+ |}>;
34
+
35
+ interface NativeCommands {
36
+ +setNativePage: (
37
+ viewRef: React.ElementRef<ComponentType>,
38
+ page: Int32,
39
+ ) => void;
40
+ }
41
+
42
+ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
43
+ supportedCommands: ['setNativePage'],
44
+ });
45
+
46
+ export default codegenNativeComponent<NativeProps>('RNPDFPdfView');
package/index.d.ts CHANGED
@@ -25,95 +25,39 @@ export type Source = {
25
25
  cacheFileName?: string;
26
26
  expiration?: number;
27
27
  method?: string;
28
- body?: any
29
28
  };
30
29
 
31
- export interface PdfProps extends ReactNative.ViewProps {
30
+ interface Props {
31
+ style?: ReactNative.StyleProp<ReactNative.ViewStyle>,
32
32
  source: Source | number,
33
33
  page?: number,
34
34
  scale?: number,
35
35
  minScale?: number,
36
36
  maxScale?: number,
37
37
  horizontal?: boolean,
38
+ showsHorizontalScrollIndicator?: boolean,
39
+ showsVerticalScrollIndicator?: boolean,
38
40
  spacing?: number,
39
41
  password?: string,
40
- renderActivityIndicator: (progress: number) => React.ReactElement,
42
+ renderActivityIndicator?: (progress: number) => React.ReactElement,
41
43
  enableAntialiasing?: boolean,
42
- enableAnnotationRendering?: boolean,
43
44
  enablePaging?: boolean,
44
45
  enableRTL?: boolean,
46
+ enableAnnotationRendering?: boolean,
45
47
  fitPolicy?: number,
46
48
  trustAllCerts?: boolean,
47
49
  singlePage?: boolean,
48
- onLoadProgress?: (percent: number) => void,
50
+ onLoadProgress?: (percent: number,) => void,
49
51
  onLoadComplete?: (numberOfPages: number, path: string, size: {height: number, width: number}, tableContents?: TableContent[]) => void,
50
52
  onPageChanged?: (page: number, numberOfPages: number) => void,
51
- onError?: (error: any) => void,
53
+ onError?: (error: object) => void,
52
54
  onPageSingleTap?: (page: number, x: number, y: number) => void,
53
55
  onScaleChanged?: (scale: number) => void,
54
56
  onPressLink?: (url: string) => void,
55
- setPage: (pageNumber: number) => void;
56
-
57
- usePDFKit?: boolean
58
- }
59
-
60
- export type PdfState = {
61
- path: string
62
- isDownloaded: boolean
63
- progress: number
64
- isSupportPDFKit: number
65
- }
66
-
67
- export interface PdfViewProps extends ReactNative.ViewProps {
68
- path: string
69
- password?: string
70
- scale: number
71
- minScale: number
72
- maxScale: number
73
- spacing: number
74
- fitPolicy?: number
75
- horizontal?: boolean
76
- page: number
77
- currentPage: number
78
- singlePage: boolean
79
- enablePaging: boolean
80
- onPageSingleTap: PdfProps['onPageSingleTap']
81
- onScaleChanged: PdfProps['onScaleChanged']
82
- onLoadComplete: PdfProps['onLoadComplete']
83
- onError: PdfProps['onError']
84
- onPageChanged: PdfProps['onPageChanged']
85
- }
86
-
87
- export type PdfViewState = {
88
- pdfLoaded: boolean
89
- fileNo: number
90
- numberOfPages:number
91
- page: number
92
- currentPage: number
93
- pageAspectRate: number
94
- pdfPageSize: {width: number, height: number}
95
- contentContainerSize: {width: number, height: number}
96
- scale: number
97
- contentOffset: {x: number, y: number}
98
- newContentOffset: {x: number, y: number}
99
- centerContent: boolean
100
57
  }
101
58
 
102
- export interface PdfPageViewProps extends ReactNative.ViewProps {
103
- fileNo: number
104
- page: number
105
- width: number
106
- height: number
107
- }
108
-
109
- export interface PinchZoomViewProps extends ReactNative.ViewProps {
110
- scalable: boolean
111
- onScaleChanged: (scaled: {pageX: number; pageY: number; scale: number}) => void
59
+ declare class Pdf extends React.Component<Props, any> {
60
+ setPage: (pageNumber: number) => void;
112
61
  }
113
62
 
114
- export interface DoubleTapViewProps extends ReactNative.ViewProps {
115
- delay: number
116
- radius: number
117
- onSingleTap: PropTypes.func,
118
- onDoubleTap: PropTypes.func,
119
- }
63
+ export default Pdf;
package/index.js ADDED
@@ -0,0 +1,464 @@
1
+ /**
2
+ * Copyright (c) 2017-present, Wonday (@wonday.org)
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the MIT-style license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ 'use strict';
10
+ import React, {Component} from 'react';
11
+ import PropTypes from 'prop-types';
12
+ import {
13
+ View,
14
+ Platform,
15
+ StyleSheet,
16
+ Image,
17
+ Text
18
+ } from 'react-native';
19
+ import PdfViewNativeComponent, {
20
+ Commands as PdfViewCommands,
21
+ } from './fabric/RNPDFPdfNativeComponent';
22
+ import ReactNativeBlobUtil from 'react-native-blob-util'
23
+ import {ViewPropTypes} from 'deprecated-react-native-prop-types';
24
+ const SHA1 = require('crypto-js/sha1');
25
+ import PdfView from './PdfView';
26
+
27
+ export default class Pdf extends Component {
28
+
29
+ static propTypes = {
30
+ ...ViewPropTypes,
31
+ source: PropTypes.oneOfType([
32
+ PropTypes.shape({
33
+ uri: PropTypes.string,
34
+ cache: PropTypes.bool,
35
+ cacheFileName: PropTypes.string,
36
+ expiration: PropTypes.number,
37
+ }),
38
+ // Opaque type returned by require('./test.pdf')
39
+ PropTypes.number,
40
+ ]).isRequired,
41
+ page: PropTypes.number,
42
+ scale: PropTypes.number,
43
+ minScale: PropTypes.number,
44
+ maxScale: PropTypes.number,
45
+ horizontal: PropTypes.bool,
46
+ spacing: PropTypes.number,
47
+ password: PropTypes.string,
48
+ renderActivityIndicator: PropTypes.func,
49
+ enableAntialiasing: PropTypes.bool,
50
+ enableAnnotationRendering: PropTypes.bool,
51
+ showsHorizontalScrollIndicator: PropTypes.bool,
52
+ showsVerticalScrollIndicator: PropTypes.bool,
53
+ enablePaging: PropTypes.bool,
54
+ enableRTL: PropTypes.bool,
55
+ fitPolicy: PropTypes.number,
56
+ trustAllCerts: PropTypes.bool,
57
+ singlePage: PropTypes.bool,
58
+ onLoadComplete: PropTypes.func,
59
+ onPageChanged: PropTypes.func,
60
+ onError: PropTypes.func,
61
+ onPageSingleTap: PropTypes.func,
62
+ onScaleChanged: PropTypes.func,
63
+ onPressLink: PropTypes.func,
64
+
65
+ // Props that are not available in the earlier react native version, added to prevent crashed on android
66
+ accessibilityLabel: PropTypes.string,
67
+ importantForAccessibility: PropTypes.string,
68
+ renderToHardwareTextureAndroid: PropTypes.string,
69
+ testID: PropTypes.string,
70
+ onLayout: PropTypes.bool,
71
+ accessibilityLiveRegion: PropTypes.string,
72
+ accessibilityComponentType: PropTypes.string,
73
+ };
74
+
75
+ static defaultProps = {
76
+ password: "",
77
+ scale: 1,
78
+ minScale: 1,
79
+ maxScale: 3,
80
+ spacing: 10,
81
+ fitPolicy: 2, //fit both
82
+ horizontal: false,
83
+ page: 1,
84
+ enableAntialiasing: true,
85
+ enableAnnotationRendering: true,
86
+ showsHorizontalScrollIndicator: true,
87
+ showsVerticalScrollIndicator: true,
88
+ enablePaging: false,
89
+ enableRTL: false,
90
+ trustAllCerts: true,
91
+ usePDFKit: true,
92
+ singlePage: false,
93
+ onLoadProgress: (percent) => {
94
+ },
95
+ onLoadComplete: (numberOfPages, path) => {
96
+ },
97
+ onPageChanged: (page, numberOfPages) => {
98
+ },
99
+ onError: (error) => {
100
+ },
101
+ onPageSingleTap: (page, x, y) => {
102
+ },
103
+ onScaleChanged: (scale) => {
104
+ },
105
+ onPressLink: (url) => {
106
+ },
107
+ };
108
+
109
+ constructor(props) {
110
+
111
+ super(props);
112
+ this.state = {
113
+ path: '',
114
+ isDownloaded: false,
115
+ progress: 0,
116
+ };
117
+
118
+ this.lastRNBFTask = null;
119
+
120
+ }
121
+
122
+ componentDidUpdate(prevProps) {
123
+
124
+ const nextSource = Image.resolveAssetSource(this.props.source);
125
+ const curSource = Image.resolveAssetSource(prevProps.source);
126
+
127
+ if ((nextSource.uri !== curSource.uri)) {
128
+ // if has download task, then cancel it.
129
+ if (this.lastRNBFTask) {
130
+ this.lastRNBFTask.cancel(err => {
131
+ this._loadFromSource(this.props.source);
132
+ });
133
+ this.lastRNBFTask = null;
134
+ } else {
135
+ this._loadFromSource(this.props.source);
136
+ }
137
+ }
138
+ }
139
+
140
+ componentDidMount() {
141
+ this._mounted = true;
142
+ this._loadFromSource(this.props.source);
143
+ }
144
+
145
+ componentWillUnmount() {
146
+ this._mounted = false;
147
+ if (this.lastRNBFTask) {
148
+ this.lastRNBFTask.cancel(err => {
149
+ });
150
+ this.lastRNBFTask = null;
151
+ }
152
+
153
+ }
154
+
155
+ _loadFromSource = (newSource) => {
156
+
157
+ const source = Image.resolveAssetSource(newSource) || {};
158
+
159
+ let uri = source.uri || '';
160
+ // first set to initial state
161
+ if (this._mounted) {
162
+ this.setState({isDownloaded: false, path: '', progress: 0});
163
+ }
164
+ const filename = source.cacheFileName || SHA1(uri) + '.pdf';
165
+ const cacheFile = ReactNativeBlobUtil.fs.dirs.CacheDir + '/' + filename;
166
+
167
+ if (source.cache) {
168
+ ReactNativeBlobUtil.fs
169
+ .stat(cacheFile)
170
+ .then(stats => {
171
+ if (!Boolean(source.expiration) || (source.expiration * 1000 + stats.lastModified) > (new Date().getTime())) {
172
+ if (this._mounted) {
173
+ this.setState({path: cacheFile, isDownloaded: true});
174
+ }
175
+ } else {
176
+ // cache expirated then reload it
177
+ this._prepareFile(source);
178
+ }
179
+ })
180
+ .catch(() => {
181
+ this._prepareFile(source);
182
+ })
183
+
184
+ } else {
185
+ this._prepareFile(source);
186
+ }
187
+ };
188
+
189
+ _prepareFile = async (source) => {
190
+
191
+ try {
192
+ if (source.uri) {
193
+ let uri = source.uri || '';
194
+
195
+ const isNetwork = !!(uri && uri.match(/^https?:\/\//));
196
+ const isAsset = !!(uri && uri.match(/^bundle-assets:\/\//));
197
+ const isBase64 = !!(uri && uri.match(/^data:application\/pdf;base64/));
198
+
199
+ const filename = source.cacheFileName || SHA1(uri) + '.pdf';
200
+ const cacheFile = ReactNativeBlobUtil.fs.dirs.CacheDir + '/' + filename;
201
+
202
+ // delete old cache file
203
+ this._unlinkFile(cacheFile);
204
+
205
+ if (isNetwork) {
206
+ this._downloadFile(source, cacheFile);
207
+ } else if (isAsset) {
208
+ ReactNativeBlobUtil.fs
209
+ .cp(uri, cacheFile)
210
+ .then(() => {
211
+ if (this._mounted) {
212
+ this.setState({path: cacheFile, isDownloaded: true, progress: 1});
213
+ }
214
+ })
215
+ .catch(async (error) => {
216
+ this._unlinkFile(cacheFile);
217
+ this._onError(error);
218
+ })
219
+ } else if (isBase64) {
220
+ let data = uri.replace(/data:application\/pdf;base64,/i, '');
221
+ ReactNativeBlobUtil.fs
222
+ .writeFile(cacheFile, data, 'base64')
223
+ .then(() => {
224
+ if (this._mounted) {
225
+ this.setState({path: cacheFile, isDownloaded: true, progress: 1});
226
+ }
227
+ })
228
+ .catch(async (error) => {
229
+ this._unlinkFile(cacheFile);
230
+ this._onError(error)
231
+ });
232
+ } else {
233
+ if (this._mounted) {
234
+ this.setState({
235
+ path: unescape(uri.replace(/file:\/\//i, '')),
236
+ isDownloaded: true,
237
+ });
238
+ }
239
+ }
240
+ } else {
241
+ this._onError(new Error('no pdf source!'));
242
+ }
243
+ } catch (e) {
244
+ this._onError(e)
245
+ }
246
+
247
+
248
+ };
249
+
250
+ _downloadFile = async (source, cacheFile) => {
251
+
252
+ if (this.lastRNBFTask) {
253
+ this.lastRNBFTask.cancel(err => {
254
+ });
255
+ this.lastRNBFTask = null;
256
+ }
257
+
258
+ const tempCacheFile = cacheFile + '.tmp';
259
+ this._unlinkFile(tempCacheFile);
260
+
261
+ this.lastRNBFTask = ReactNativeBlobUtil.config({
262
+ // response data will be saved to this path if it has access right.
263
+ path: tempCacheFile,
264
+ trusty: this.props.trustAllCerts,
265
+ })
266
+ .fetch(
267
+ source.method ? source.method : 'GET',
268
+ source.uri,
269
+ source.headers ? source.headers : {},
270
+ source.body ? source.body : ""
271
+ )
272
+ // listen to download progress event
273
+ .progress((received, total) => {
274
+ this.props.onLoadProgress && this.props.onLoadProgress(received / total);
275
+ if (this._mounted) {
276
+ this.setState({progress: received / total});
277
+ }
278
+ });
279
+
280
+ this.lastRNBFTask
281
+ .then(async (res) => {
282
+
283
+ this.lastRNBFTask = null;
284
+
285
+ if (res && res.respInfo && res.respInfo.headers && !res.respInfo.headers["Content-Encoding"] && !res.respInfo.headers["Transfer-Encoding"] && res.respInfo.headers["Content-Length"]) {
286
+ const expectedContentLength = res.respInfo.headers["Content-Length"];
287
+ let actualContentLength;
288
+
289
+ try {
290
+ const fileStats = await ReactNativeBlobUtil.fs.stat(res.path());
291
+
292
+ if (!fileStats || !fileStats.size) {
293
+ throw new Error("FileNotFound:" + source.uri);
294
+ }
295
+
296
+ actualContentLength = fileStats.size;
297
+ } catch (error) {
298
+ throw new Error("DownloadFailed:" + source.uri);
299
+ }
300
+
301
+ if (expectedContentLength != actualContentLength) {
302
+ throw new Error("DownloadFailed:" + source.uri);
303
+ }
304
+ }
305
+
306
+ this._unlinkFile(cacheFile);
307
+ ReactNativeBlobUtil.fs
308
+ .cp(tempCacheFile, cacheFile)
309
+ .then(() => {
310
+ if (this._mounted) {
311
+ this.setState({path: cacheFile, isDownloaded: true, progress: 1});
312
+ }
313
+ this._unlinkFile(tempCacheFile);
314
+ })
315
+ .catch(async (error) => {
316
+ throw error;
317
+ });
318
+ })
319
+ .catch(async (error) => {
320
+ this._unlinkFile(tempCacheFile);
321
+ this._unlinkFile(cacheFile);
322
+ this._onError(error);
323
+ });
324
+
325
+ };
326
+
327
+ _unlinkFile = async (file) => {
328
+ try {
329
+ await ReactNativeBlobUtil.fs.unlink(file);
330
+ } catch (e) {
331
+
332
+ }
333
+ }
334
+
335
+ setNativeProps = nativeProps => {
336
+ if (this._root){
337
+ this._root.setNativeProps(nativeProps);
338
+ }
339
+ };
340
+
341
+ setPage( pageNumber ) {
342
+ if ( (pageNumber === null) || (isNaN(pageNumber)) ) {
343
+ throw new Error('Specified pageNumber is not a number');
344
+ }
345
+ if (!!global?.nativeFabricUIManager ) {
346
+ if (this._root) {
347
+ PdfViewCommands.setNativePage(
348
+ this._root,
349
+ pageNumber,
350
+ );
351
+ }
352
+ } else {
353
+ this.setNativeProps({
354
+ page: pageNumber
355
+ });
356
+ }
357
+
358
+ }
359
+
360
+ _onChange = (event) => {
361
+
362
+ let message = event.nativeEvent.message.split('|');
363
+ //__DEV__ && console.log("onChange: " + message);
364
+ if (message.length > 0) {
365
+ if (message.length > 5) {
366
+ message[4] = message.splice(4).join('|');
367
+ }
368
+ if (message[0] === 'loadComplete') {
369
+ this.props.onLoadComplete && this.props.onLoadComplete(Number(message[1]), this.state.path, {
370
+ width: Number(message[2]),
371
+ height: Number(message[3]),
372
+ },
373
+ message[4]&&JSON.parse(message[4]));
374
+ } else if (message[0] === 'pageChanged') {
375
+ this.props.onPageChanged && this.props.onPageChanged(Number(message[1]), Number(message[2]));
376
+ } else if (message[0] === 'error') {
377
+ this._onError(new Error(message[1]));
378
+ } else if (message[0] === 'pageSingleTap') {
379
+ this.props.onPageSingleTap && this.props.onPageSingleTap(Number(message[1]), Number(message[2]), Number(message[3]));
380
+ } else if (message[0] === 'scaleChanged') {
381
+ this.props.onScaleChanged && this.props.onScaleChanged(Number(message[1]));
382
+ } else if (message[0] === 'linkPressed') {
383
+ this.props.onPressLink && this.props.onPressLink(message[1]);
384
+ }
385
+ }
386
+
387
+ };
388
+
389
+ _onError = (error) => {
390
+
391
+ this.props.onError && this.props.onError(error);
392
+
393
+ };
394
+
395
+ render() {
396
+ if (Platform.OS === "android" || Platform.OS === "ios" || Platform.OS === "windows") {
397
+ return (
398
+ <View style={[this.props.style,{overflow: 'hidden'}]}>
399
+ {!this.state.isDownloaded?
400
+ (<View
401
+ style={styles.progressContainer}
402
+ >
403
+ {this.props.renderActivityIndicator
404
+ ? this.props.renderActivityIndicator(this.state.progress)
405
+ : <Text>{`${(this.state.progress * 100).toFixed(2)}%`}</Text>}
406
+ </View>):(
407
+ Platform.OS === "android" || Platform.OS === "windows"?(
408
+ <PdfCustom
409
+ ref={component => (this._root = component)}
410
+ {...this.props}
411
+ style={[{flex:1,backgroundColor: '#EEE'}, this.props.style]}
412
+ path={this.state.path}
413
+ onChange={this._onChange}
414
+ />
415
+ ):(
416
+ this.props.usePDFKit ?(
417
+ <PdfCustom
418
+ ref={component => (this._root = component)}
419
+ {...this.props}
420
+ style={[{backgroundColor: '#EEE',overflow: 'hidden'}, this.props.style]}
421
+ path={this.state.path}
422
+ onChange={this._onChange}
423
+ />
424
+ ):(<PdfView
425
+ {...this.props}
426
+ style={[{backgroundColor: '#EEE',overflow: 'hidden'}, this.props.style]}
427
+ path={this.state.path}
428
+ onLoadComplete={this.props.onLoadComplete}
429
+ onPageChanged={this.props.onPageChanged}
430
+ onError={this._onError}
431
+ onPageSingleTap={this.props.onPageSingleTap}
432
+ onScaleChanged={this.props.onScaleChanged}
433
+ onPressLink={this.props.onPressLink}
434
+ />)
435
+ )
436
+ )}
437
+ </View>);
438
+ } else {
439
+ return (null);
440
+ }
441
+
442
+
443
+ }
444
+ }
445
+
446
+ if (Platform.OS === "android" || Platform.OS === "ios") {
447
+ var PdfCustom = PdfViewNativeComponent;
448
+ } else if (Platform.OS === "windows") {
449
+ var PdfCustom = requireNativeComponent('RCTPdf', Pdf, {
450
+ nativeOnly: {path: true, onChange: true},
451
+ })
452
+ }
453
+
454
+ const styles = StyleSheet.create({
455
+ progressContainer: {
456
+ flex: 1,
457
+ justifyContent: 'center',
458
+ alignItems: 'center'
459
+ },
460
+ progressBar: {
461
+ width: 200,
462
+ height: 2
463
+ }
464
+ });
package/index.js.flow CHANGED
@@ -39,6 +39,8 @@ export type Props = {
39
39
  enableRTL?: boolean,
40
40
  fitPolicy?: FitWidth | FitHeight | FitBoth,
41
41
  horizontal?: boolean,
42
+ showsHorizontalScrollIndicator?: boolean,
43
+ showsVerticalScrollIndicator?: boolean,
42
44
  maxScale?: number,
43
45
  minScale?: number,
44
46
  singlePage?: boolean,
@@ -136,7 +136,7 @@ RCT_EXPORT_METHOD(loadFile:(NSString *)path
136
136
  {
137
137
  // release pdf docs
138
138
  for(NSValue *item in pdfDocRefs) {
139
- CGPDFDocumentRef pdfItem = [item pointerValue];
139
+ CGPDFDocumentRef pdfItem = (CGPDFDocumentRef)[item pointerValue];
140
140
  if (pdfItem != NULL) {
141
141
 
142
142
  CGPDFDocumentRelease(pdfItem);
@@ -13,7 +13,7 @@
13
13
  #endif
14
14
 
15
15
 
16
- @interface RCTPdfPageView : UIView
16
+ @interface RNPDFPdfPageView : UIView
17
17
 
18
18
  @property(nonatomic) int fileNo;
19
19
  @property(nonatomic) int page;
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  #import "PdfManager.h"
10
- #import "RCTPdfPageView.h"
10
+ #import "RNPDFPdfPageView.h"
11
11
 
12
12
 
13
13
 
@@ -37,15 +37,15 @@
37
37
  #define RLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
38
38
 
39
39
  @interface CAPdfLayer : CALayer
40
- -(void) setParentView:(RCTPdfPageView *)parentView;
40
+ -(void) setParentView:(RNPDFPdfPageView *)parentView;
41
41
  @end
42
42
 
43
43
  @implementation CAPdfLayer
44
44
  {
45
- RCTPdfPageView *_parentView;
45
+ RNPDFPdfPageView *_parentView;
46
46
  }
47
47
 
48
- -(void) setParentView:(RCTPdfPageView *)parentView
48
+ -(void) setParentView:(RNPDFPdfPageView *)parentView
49
49
  {
50
50
  _parentView = parentView;
51
51
  }
@@ -134,7 +134,7 @@
134
134
  }
135
135
  @end
136
136
 
137
- @implementation RCTPdfPageView {
137
+ @implementation RNPDFPdfPageView {
138
138
 
139
139
  CAPdfLayer *_layer;
140
140
  }
@@ -13,6 +13,6 @@
13
13
  #endif
14
14
 
15
15
 
16
- @interface RCTPdfPageViewManager : RCTViewManager
16
+ @interface RNPDFPdfPageViewManager : RCTViewManager
17
17
 
18
18
  @end