react-native-pdf 6.4.0 → 6.6.1
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/README.md +18 -2
- package/android/build.gradle +3 -3
- package/index.d.ts +79 -10
- package/ios/RCTPdf/PdfManager.m +11 -1
- package/ios/RCTPdf/RCTPdfView.m +4 -1
- package/package.json +14 -8
- package/windows/RCTPdf/RCTPdfControl.xaml +0 -1
- package/DoubleTapView.js +0 -126
- package/PdfManager.js +0 -31
- package/PdfPageView.js +0 -54
- package/PdfView.js +0 -416
- package/PdfViewFlatList.js +0 -31
- package/PinchZoomView.js +0 -126
- package/index.js +0 -467
package/README.md
CHANGED
|
@@ -23,14 +23,17 @@ So you should install react-native-pdf and react-native-blob-util
|
|
|
23
23
|
| react-native-pdf | 4.x.x - 5.0.x | 5.0.9+ | 6.0.0+ | 6.2.0+ | 6.4.0+ |
|
|
24
24
|
| react-native-blob-util | | | | | 0.13.7+ |
|
|
25
25
|
|
|
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).
|
|
28
|
+
|
|
26
29
|
### Installation
|
|
27
30
|
|
|
28
31
|
```bash
|
|
29
32
|
# Using npm
|
|
30
|
-
npm install react-native-pdf react-native-blob-util
|
|
33
|
+
npm install react-native-pdf react-native-blob-util --save
|
|
31
34
|
|
|
32
35
|
# or using yarn:
|
|
33
|
-
yarn add react-native-pdf react-native-blob-util
|
|
36
|
+
yarn add react-native-pdf react-native-blob-util
|
|
34
37
|
```
|
|
35
38
|
|
|
36
39
|
Then follow the instructions for your platform to link react-native-pdf into your project:
|
|
@@ -166,6 +169,19 @@ react-native run-ios
|
|
|
166
169
|
<details>
|
|
167
170
|
<summary>ChangeLog details</summary>
|
|
168
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
|
+
|
|
169
185
|
v6.4.0
|
|
170
186
|
1. Remove sample for reducing NPM package size
|
|
171
187
|
2. Add support for setting a filename for the cached pdf file
|
package/android/build.gradle
CHANGED
|
@@ -2,7 +2,7 @@ description = 'react-native-pdf'
|
|
|
2
2
|
|
|
3
3
|
buildscript {
|
|
4
4
|
repositories {
|
|
5
|
-
|
|
5
|
+
mavenCentral()
|
|
6
6
|
google()
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -12,11 +12,11 @@ buildscript {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
repositories {
|
|
15
|
-
|
|
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
|
|
19
|
+
// Use Jitpack only for AndroidPdfViewer; the rest is hosted at mavenCentral.
|
|
20
20
|
includeGroup "com.github.TalbotGooday"
|
|
21
21
|
}
|
|
22
22
|
}
|
package/index.d.ts
CHANGED
|
@@ -16,9 +16,20 @@ export type TableContent = {
|
|
|
16
16
|
title: string,
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
export type Source = {
|
|
20
|
+
uri?: string;
|
|
21
|
+
headers?: {
|
|
22
|
+
[key: string]: string;
|
|
23
|
+
};
|
|
24
|
+
cache?: boolean;
|
|
25
|
+
cacheFileName?: string;
|
|
26
|
+
expiration?: number;
|
|
27
|
+
method?: string;
|
|
28
|
+
body?: any
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export interface PdfProps extends ReactNative.ViewProps {
|
|
32
|
+
source: Source | number,
|
|
22
33
|
page?: number,
|
|
23
34
|
scale?: number,
|
|
24
35
|
minScale?: number,
|
|
@@ -26,25 +37,83 @@ interface Props {
|
|
|
26
37
|
horizontal?: boolean,
|
|
27
38
|
spacing?: number,
|
|
28
39
|
password?: string,
|
|
29
|
-
renderActivityIndicator
|
|
40
|
+
renderActivityIndicator: (progress: number) => React.ReactElement,
|
|
30
41
|
enableAntialiasing?: boolean,
|
|
42
|
+
enableAnnotationRendering?: boolean,
|
|
31
43
|
enablePaging?: boolean,
|
|
32
44
|
enableRTL?: boolean,
|
|
33
|
-
enableAnnotationRendering?: boolean,
|
|
34
45
|
fitPolicy?: number,
|
|
35
46
|
trustAllCerts?: boolean,
|
|
36
47
|
singlePage?: boolean,
|
|
37
|
-
onLoadProgress?: (percent: number
|
|
48
|
+
onLoadProgress?: (percent: number) => void,
|
|
38
49
|
onLoadComplete?: (numberOfPages: number, path: string, size: {height: number, width: number}, tableContents?: TableContent[]) => void,
|
|
39
50
|
onPageChanged?: (page: number, numberOfPages: number) => void,
|
|
40
|
-
onError?: (error:
|
|
51
|
+
onError?: (error: any) => void,
|
|
41
52
|
onPageSingleTap?: (page: number, x: number, y: number) => void,
|
|
42
53
|
onScaleChanged?: (scale: number) => void,
|
|
43
54
|
onPressLink?: (url: string) => void,
|
|
55
|
+
setPage: (pageNumber: number) => void;
|
|
56
|
+
|
|
57
|
+
usePDFKit?: boolean
|
|
44
58
|
}
|
|
45
59
|
|
|
46
|
-
|
|
47
|
-
|
|
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
|
+
}
|
|
101
|
+
|
|
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
|
|
48
112
|
}
|
|
49
113
|
|
|
50
|
-
export
|
|
114
|
+
export interface DoubleTapViewProps extends ReactNative.ViewProps {
|
|
115
|
+
delay: number
|
|
116
|
+
radius: number
|
|
117
|
+
onSingleTap: PropTypes.func,
|
|
118
|
+
onDoubleTap: PropTypes.func,
|
|
119
|
+
}
|
package/ios/RCTPdf/PdfManager.m
CHANGED
|
@@ -50,7 +50,17 @@ RCT_EXPORT_METHOD(loadFile:(NSString *)path
|
|
|
50
50
|
|
|
51
51
|
if (path != nil && path.length != 0) {
|
|
52
52
|
|
|
53
|
-
|
|
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) {
|
package/ios/RCTPdf/RCTPdfView.m
CHANGED
|
@@ -132,6 +132,9 @@ const float MIN_SCALE = 1.0f;
|
|
|
132
132
|
_pdfDocument = [[PDFDocument alloc] initWithData:blobData];
|
|
133
133
|
}
|
|
134
134
|
} else {
|
|
135
|
+
|
|
136
|
+
// decode file path
|
|
137
|
+
_path = (__bridge_transfer NSString *)CFURLCreateStringByReplacingPercentEscapes(NULL, (CFStringRef)_path, CFSTR(""));
|
|
135
138
|
NSURL *fileURL = [NSURL fileURLWithPath:_path];
|
|
136
139
|
_pdfDocument = [[PDFDocument alloc] initWithURL:fileURL];
|
|
137
140
|
}
|
|
@@ -200,7 +203,7 @@ const float MIN_SCALE = 1.0f;
|
|
|
200
203
|
|
|
201
204
|
if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"fitPolicy"] || [changedProps containsObject:@"minScale"] || [changedProps containsObject:@"maxScale"])) {
|
|
202
205
|
|
|
203
|
-
PDFPage *pdfPage = [_pdfDocument pageAtIndex:_pdfDocument.pageCount-1];
|
|
206
|
+
PDFPage *pdfPage = _pdfView.currentPage ? _pdfView.currentPage : [_pdfDocument pageAtIndex:_pdfDocument.pageCount-1];
|
|
204
207
|
CGRect pdfPageRect = [pdfPage boundsForBox:kPDFDisplayBoxCropBox];
|
|
205
208
|
|
|
206
209
|
// some pdf with rotation, then adjust it
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-pdf",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.1",
|
|
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",
|
|
7
|
-
"typings": "./index.d.ts",
|
|
8
7
|
"repository": {
|
|
9
8
|
"type": "git",
|
|
10
9
|
"url": "git+https://github.com/wonday/react-native-pdf.git"
|
|
@@ -28,15 +27,20 @@
|
|
|
28
27
|
"url": "https://github.com/wonday/react-native-pdf/issues"
|
|
29
28
|
},
|
|
30
29
|
"dependencies": {
|
|
31
|
-
"crypto-js": "^3.2.0"
|
|
30
|
+
"crypto-js": "^3.2.0",
|
|
31
|
+
"deprecated-react-native-prop-types": "^2.3.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"
|
|
34
|
+
"@types/react-native": "^0.68.0",
|
|
35
|
+
"react-native": "^0.68.0",
|
|
36
|
+
"typescript": "^4.7.4"
|
|
35
37
|
},
|
|
36
38
|
"files": [
|
|
37
39
|
"android/",
|
|
38
40
|
"ios/",
|
|
39
41
|
"windows/",
|
|
42
|
+
"dist/",
|
|
43
|
+
"react-native-pdf.podspec",
|
|
40
44
|
"DoubleTapView.js",
|
|
41
45
|
"index.d.ts",
|
|
42
46
|
"index.js",
|
|
@@ -45,7 +49,9 @@
|
|
|
45
49
|
"PdfPageView.js",
|
|
46
50
|
"PdfView.js",
|
|
47
51
|
"PdfViewFlatList.js",
|
|
48
|
-
"PinchZoomView.js"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
"PinchZoomView.js"
|
|
53
|
+
],
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "rm -rf dist/ && tsc"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -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/DoubleTapView.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
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 {
|
|
12
|
-
View,
|
|
13
|
-
PanResponder,
|
|
14
|
-
ViewPropTypes,
|
|
15
|
-
} from 'react-native';
|
|
16
|
-
import PropTypes from 'prop-types';
|
|
17
|
-
|
|
18
|
-
export default class DoubleTapView extends Component {
|
|
19
|
-
|
|
20
|
-
static propTypes = {
|
|
21
|
-
...ViewPropTypes,
|
|
22
|
-
delay: PropTypes.number,
|
|
23
|
-
radius: PropTypes.number,
|
|
24
|
-
onSingleTap: PropTypes.func,
|
|
25
|
-
onDoubleTap: PropTypes.func,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
static defaultProps = {
|
|
29
|
-
delay: 300,
|
|
30
|
-
radius: 50,
|
|
31
|
-
onSingleTap: () => {
|
|
32
|
-
},
|
|
33
|
-
onDoubleTap: () => {
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
constructor() {
|
|
38
|
-
super();
|
|
39
|
-
|
|
40
|
-
this.gestureHandlers = PanResponder.create({
|
|
41
|
-
onStartShouldSetPanResponder: (evt, gestureState) => (gestureState.numberActiveTouches === 1),
|
|
42
|
-
onStartShouldSetResponderCapture: (evt, gestureState) => (gestureState.numberActiveTouches === 1),
|
|
43
|
-
onMoveShouldSetPanResponder: (evt, gestureState) => (false),
|
|
44
|
-
onMoveShouldSetResponderCapture: (evt, gestureState) => (false),
|
|
45
|
-
onPanResponderTerminationRequest: (evt, gestureState) => false,
|
|
46
|
-
onPanResponderRelease: this.handlePanResponderRelease,
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
this.prevTouchInfo = {
|
|
51
|
-
prevTouchX: 0,
|
|
52
|
-
prevTouchY: 0,
|
|
53
|
-
prevTouchTimeStamp: 0,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
this.timer = null;
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
distance = (x0, y0, x1, y1) => {
|
|
62
|
-
return Math.sqrt(Math.pow((x1 - x0), 2) + Math.pow((y1 - y0), 2)).toFixed(1);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
isDoubleTap = (currentTouchTimeStamp, {x0, y0}) => {
|
|
66
|
-
const {prevTouchX, prevTouchY, prevTouchTimeStamp} = this.prevTouchInfo;
|
|
67
|
-
const dt = currentTouchTimeStamp - prevTouchTimeStamp;
|
|
68
|
-
const {delay, radius} = this.props;
|
|
69
|
-
|
|
70
|
-
return (prevTouchTimeStamp > 0 && dt < delay && this.distance(prevTouchX, prevTouchY, x0, y0) < radius);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
handlePanResponderRelease = (evt, gestureState) => {
|
|
74
|
-
|
|
75
|
-
const currentTouchTimeStamp = Date.now();
|
|
76
|
-
const x = evt.nativeEvent.locationX;
|
|
77
|
-
const y = evt.nativeEvent.locationY;
|
|
78
|
-
|
|
79
|
-
if (this.timer) {
|
|
80
|
-
|
|
81
|
-
if (this.isDoubleTap(currentTouchTimeStamp, gestureState)) {
|
|
82
|
-
|
|
83
|
-
clearTimeout(this.timer);
|
|
84
|
-
this.timer = null;
|
|
85
|
-
this.props.onDoubleTap();
|
|
86
|
-
|
|
87
|
-
} else {
|
|
88
|
-
|
|
89
|
-
const {prevTouchX, prevTouchY, prevTouchTimeStamp} = this.prevTouchInfo;
|
|
90
|
-
const {radius} = this.props;
|
|
91
|
-
|
|
92
|
-
// if not in radius, it's a move
|
|
93
|
-
if (this.distance(prevTouchX, prevTouchY, gestureState.x0, gestureState.y0) < radius) {
|
|
94
|
-
this.timer = null;
|
|
95
|
-
this.props.onSingleTap(x, y);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
} else {
|
|
100
|
-
// do not count scroll gestures as taps
|
|
101
|
-
if (this.distance(0, gestureState.dx, 0, gestureState.dy) < 10) {
|
|
102
|
-
|
|
103
|
-
this.timer = setTimeout(() => {
|
|
104
|
-
this.props.onSingleTap(x, y);
|
|
105
|
-
this.timer = null;
|
|
106
|
-
}, this.props.delay);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
this.prevTouchInfo = {
|
|
112
|
-
prevTouchX: gestureState.x0,
|
|
113
|
-
prevTouchY: gestureState.y0,
|
|
114
|
-
prevTouchTimeStamp: currentTouchTimeStamp,
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
render() {
|
|
120
|
-
return (
|
|
121
|
-
<View {...this.props} {...this.gestureHandlers.panHandlers}>
|
|
122
|
-
{this.props.children}
|
|
123
|
-
</View>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
}
|
package/PdfManager.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
const invariant = require('fbjs/lib/invariant');
|
|
11
|
-
const PdfManagerNative = require('react-native').NativeModules.PdfManager;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export default class PdfManager {
|
|
15
|
-
|
|
16
|
-
static loadFile(path: string,
|
|
17
|
-
password?: string,): Promise<string> {
|
|
18
|
-
|
|
19
|
-
invariant(
|
|
20
|
-
typeof path === 'string',
|
|
21
|
-
'path must be a valid string.',
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
if (password === undefined) {
|
|
25
|
-
password = "";
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return PdfManagerNative.loadFile(path, password);
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
}
|
package/PdfPageView.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
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
|
-
|
|
10
|
-
'use strict';
|
|
11
|
-
import React, {PureComponent} from 'react';
|
|
12
|
-
import PropTypes from 'prop-types';
|
|
13
|
-
import {
|
|
14
|
-
ViewPropTypes,
|
|
15
|
-
requireNativeComponent,
|
|
16
|
-
} from 'react-native';
|
|
17
|
-
|
|
18
|
-
export default class PdfPageView extends PureComponent {
|
|
19
|
-
_getStylePropsProps = () => {
|
|
20
|
-
const {width, height} = this.props;
|
|
21
|
-
if (width || height) {
|
|
22
|
-
return {width, height};
|
|
23
|
-
}
|
|
24
|
-
return {};
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
render() {
|
|
28
|
-
const {
|
|
29
|
-
style,
|
|
30
|
-
...restProps
|
|
31
|
-
} = this.props;
|
|
32
|
-
return (
|
|
33
|
-
<PdfPageViewCustom
|
|
34
|
-
{...restProps}
|
|
35
|
-
style={[style, this._getStylePropsProps()]}
|
|
36
|
-
/>
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
PdfPageView.propTypes = {
|
|
43
|
-
...ViewPropTypes,
|
|
44
|
-
fileNo: PropTypes.number,
|
|
45
|
-
page: PropTypes.number,
|
|
46
|
-
width: PropTypes.number,
|
|
47
|
-
height: PropTypes.number
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
PdfPageView.defaultProps = {
|
|
51
|
-
style: {}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
let PdfPageViewCustom = requireNativeComponent('RCTPdfPageView', PdfPageView, {nativeOnly: {}});
|