react-native-pdf 6.6.2 → 6.7.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 +17 -41
- package/android/build.gradle +71 -13
- package/android/src/main/java/org/wonday/pdf/{RCTPdfManager.java → PdfManager.java} +57 -21
- package/android/src/main/java/org/wonday/pdf/PdfView.java +25 -0
- package/android/src/main/java/org/wonday/pdf/{RCTPdfView.java → RNPDFPackage.java} +2 -3
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.java +86 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.java +33 -0
- package/fabric/RNPDFPdfNativeComponent.js +46 -0
- package/index.d.ts +2 -0
- package/index.js +25 -27
- package/index.js.flow +2 -0
- package/ios/{RCTPdf/PdfManager.m → RNPDFPdf/PdfManager.mm} +1 -1
- package/ios/{RCTPdf/RCTPdfPageView.h → RNPDFPdf/RNPDFPdfPageView.h} +1 -1
- package/ios/{RCTPdf/RCTPdfPageView.m → RNPDFPdf/RNPDFPdfPageView.mm} +5 -5
- package/ios/{RCTPdf/RCTPdfPageViewManager.h → RNPDFPdf/RNPDFPdfPageViewManager.h} +1 -1
- package/ios/{RCTPdf/RCTPdfPageViewManager.m → RNPDFPdf/RNPDFPdfPageViewManager.mm} +4 -4
- package/ios/{RCTPdf/RCTPdfView.h → RNPDFPdf/RNPDFPdfView.h} +15 -5
- package/ios/{RCTPdf/RCTPdfView.m → RNPDFPdf/RNPDFPdfView.mm} +321 -54
- package/ios/{RCTPdf/RCTPdfViewManager.h → RNPDFPdf/RNPDFPdfViewManager.h} +1 -1
- package/ios/{RCTPdf/RCTPdfViewManager.m → RNPDFPdf/RNPDFPdfViewManager.mm} +7 -5
- package/ios/{RCTPdf.xcodeproj → RNPDFPdf.xcodeproj}/project.pbxproj +42 -42
- package/package.json +19 -3
- package/react-native-pdf.podspec +28 -3
- package/windows/RCTPdf/pch.h +2 -0
- package/ios/RCTPdf.xcodeproj/xcuserdata/wonday.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- /package/ios/{RCTPdf → RNPDFPdf}/PdfManager.h +0 -0
package/index.js
CHANGED
|
@@ -10,14 +10,15 @@
|
|
|
10
10
|
import React, {Component} from 'react';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
12
|
import {
|
|
13
|
-
requireNativeComponent,
|
|
14
13
|
View,
|
|
15
14
|
Platform,
|
|
16
15
|
StyleSheet,
|
|
17
16
|
Image,
|
|
18
17
|
Text
|
|
19
18
|
} from 'react-native';
|
|
20
|
-
|
|
19
|
+
import PdfViewNativeComponent, {
|
|
20
|
+
Commands as PdfViewCommands,
|
|
21
|
+
} from './fabric/RNPDFPdfNativeComponent';
|
|
21
22
|
import ReactNativeBlobUtil from 'react-native-blob-util'
|
|
22
23
|
import {ViewPropTypes} from 'deprecated-react-native-prop-types';
|
|
23
24
|
const SHA1 = require('crypto-js/sha1');
|
|
@@ -47,6 +48,8 @@ export default class Pdf extends Component {
|
|
|
47
48
|
renderActivityIndicator: PropTypes.func,
|
|
48
49
|
enableAntialiasing: PropTypes.bool,
|
|
49
50
|
enableAnnotationRendering: PropTypes.bool,
|
|
51
|
+
showsHorizontalScrollIndicator: PropTypes.bool,
|
|
52
|
+
showsVerticalScrollIndicator: PropTypes.bool,
|
|
50
53
|
enablePaging: PropTypes.bool,
|
|
51
54
|
enableRTL: PropTypes.bool,
|
|
52
55
|
fitPolicy: PropTypes.number,
|
|
@@ -80,6 +83,8 @@ export default class Pdf extends Component {
|
|
|
80
83
|
page: 1,
|
|
81
84
|
enableAntialiasing: true,
|
|
82
85
|
enableAnnotationRendering: true,
|
|
86
|
+
showsHorizontalScrollIndicator: true,
|
|
87
|
+
showsVerticalScrollIndicator: true,
|
|
83
88
|
enablePaging: false,
|
|
84
89
|
enableRTL: false,
|
|
85
90
|
trustAllCerts: true,
|
|
@@ -108,7 +113,6 @@ export default class Pdf extends Component {
|
|
|
108
113
|
path: '',
|
|
109
114
|
isDownloaded: false,
|
|
110
115
|
progress: 0,
|
|
111
|
-
isSupportPDFKit: -1
|
|
112
116
|
};
|
|
113
117
|
|
|
114
118
|
this.lastRNBFTask = null;
|
|
@@ -135,14 +139,6 @@ export default class Pdf extends Component {
|
|
|
135
139
|
|
|
136
140
|
componentDidMount() {
|
|
137
141
|
this._mounted = true;
|
|
138
|
-
if (Platform.OS === "ios") {
|
|
139
|
-
const PdfViewManagerNative = require('react-native').NativeModules.PdfViewManager;
|
|
140
|
-
PdfViewManagerNative.supportPDFKit((isSupportPDFKit) => {
|
|
141
|
-
if (this._mounted) {
|
|
142
|
-
this.setState({isSupportPDFKit: isSupportPDFKit ? 1 : 0});
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
142
|
this._loadFromSource(this.props.source);
|
|
147
143
|
}
|
|
148
144
|
|
|
@@ -236,7 +232,7 @@ export default class Pdf extends Component {
|
|
|
236
232
|
} else {
|
|
237
233
|
if (this._mounted) {
|
|
238
234
|
this.setState({
|
|
239
|
-
path: uri.replace(/file:\/\//i, ''),
|
|
235
|
+
path: unescape(uri.replace(/file:\/\//i, '')),
|
|
240
236
|
isDownloaded: true,
|
|
241
237
|
});
|
|
242
238
|
}
|
|
@@ -346,9 +342,19 @@ export default class Pdf extends Component {
|
|
|
346
342
|
if ( (pageNumber === null) || (isNaN(pageNumber)) ) {
|
|
347
343
|
throw new Error('Specified pageNumber is not a number');
|
|
348
344
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
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
|
+
|
|
352
358
|
}
|
|
353
359
|
|
|
354
360
|
_onChange = (event) => {
|
|
@@ -407,7 +413,7 @@ export default class Pdf extends Component {
|
|
|
407
413
|
onChange={this._onChange}
|
|
408
414
|
/>
|
|
409
415
|
):(
|
|
410
|
-
this.props.usePDFKit
|
|
416
|
+
this.props.usePDFKit ?(
|
|
411
417
|
<PdfCustom
|
|
412
418
|
ref={component => (this._root = component)}
|
|
413
419
|
{...this.props}
|
|
@@ -437,22 +443,14 @@ export default class Pdf extends Component {
|
|
|
437
443
|
}
|
|
438
444
|
}
|
|
439
445
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
nativeOnly: {path: true, onChange: true},
|
|
444
|
-
})
|
|
445
|
-
} else if (Platform.OS === "ios") {
|
|
446
|
-
var PdfCustom = requireNativeComponent('RCTPdfView', Pdf, {
|
|
447
|
-
nativeOnly: {path: true, onChange: true},
|
|
448
|
-
})
|
|
449
|
-
} else if (Platform.OS === "windows") {
|
|
446
|
+
if (Platform.OS === "android" || Platform.OS === "ios") {
|
|
447
|
+
var PdfCustom = PdfViewNativeComponent;
|
|
448
|
+
} else if (Platform.OS === "windows") {
|
|
450
449
|
var PdfCustom = requireNativeComponent('RCTPdf', Pdf, {
|
|
451
450
|
nativeOnly: {path: true, onChange: true},
|
|
452
451
|
})
|
|
453
452
|
}
|
|
454
453
|
|
|
455
|
-
|
|
456
454
|
const styles = StyleSheet.create({
|
|
457
455
|
progressContainer: {
|
|
458
456
|
flex: 1,
|
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);
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
#import "PdfManager.h"
|
|
10
|
-
#import "
|
|
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:(
|
|
40
|
+
-(void) setParentView:(RNPDFPdfPageView *)parentView;
|
|
41
41
|
@end
|
|
42
42
|
|
|
43
43
|
@implementation CAPdfLayer
|
|
44
44
|
{
|
|
45
|
-
|
|
45
|
+
RNPDFPdfPageView *_parentView;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
-(void) setParentView:(
|
|
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
|
|
137
|
+
@implementation RNPDFPdfPageView {
|
|
138
138
|
|
|
139
139
|
CAPdfLayer *_layer;
|
|
140
140
|
}
|
|
@@ -8,17 +8,17 @@
|
|
|
8
8
|
|
|
9
9
|
#import <Foundation/Foundation.h>
|
|
10
10
|
|
|
11
|
-
#import "
|
|
12
|
-
#import "
|
|
11
|
+
#import "RNPDFPdfPageViewManager.h"
|
|
12
|
+
#import "RNPDFPdfPageView.h"
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
@implementation
|
|
15
|
+
@implementation RNPDFPdfPageViewManager
|
|
16
16
|
|
|
17
17
|
RCT_EXPORT_MODULE()
|
|
18
18
|
|
|
19
19
|
- (UIView *)view
|
|
20
20
|
{
|
|
21
|
-
return [[
|
|
21
|
+
return [[RNPDFPdfPageView alloc] init];
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
RCT_EXPORT_VIEW_PROPERTY(fileNo, int);
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
#ifndef
|
|
10
|
-
#define
|
|
9
|
+
#ifndef RNPDFPdfView_h
|
|
10
|
+
#define RNPDFPdfView_h
|
|
11
11
|
|
|
12
12
|
#if __has_include(<React/RCTAssert.h>)
|
|
13
13
|
#import <React/RCTEventDispatcher.h>
|
|
@@ -17,11 +17,19 @@
|
|
|
17
17
|
#import "UIView+React.h"
|
|
18
18
|
#endif
|
|
19
19
|
|
|
20
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
21
|
+
#import <React/RCTViewComponentView.h>
|
|
22
|
+
#endif
|
|
20
23
|
|
|
21
24
|
@class RCTEventDispatcher;
|
|
22
25
|
|
|
23
|
-
NS_CLASS_AVAILABLE_IOS(11_0) @interface
|
|
24
|
-
|
|
26
|
+
NS_CLASS_AVAILABLE_IOS(11_0) @interface RNPDFPdfView :
|
|
27
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
28
|
+
RCTViewComponentView
|
|
29
|
+
#else
|
|
30
|
+
UIView
|
|
31
|
+
#endif
|
|
32
|
+
<UIGestureRecognizerDelegate>
|
|
25
33
|
- (instancetype)initWithBridge:(RCTBridge *)bridge;
|
|
26
34
|
|
|
27
35
|
@property(nonatomic, strong) NSString *path;
|
|
@@ -30,6 +38,8 @@ NS_CLASS_AVAILABLE_IOS(11_0) @interface RCTPdfView : UIView <UIGestureRecognizer
|
|
|
30
38
|
@property(nonatomic) float minScale;
|
|
31
39
|
@property(nonatomic) float maxScale;
|
|
32
40
|
@property(nonatomic) BOOL horizontal;
|
|
41
|
+
@property(nonatomic) BOOL showsVerticalScrollIndicator;
|
|
42
|
+
@property(nonatomic) BOOL showsHorizontalScrollIndicator;
|
|
33
43
|
@property(nonatomic) BOOL enablePaging;
|
|
34
44
|
@property(nonatomic) BOOL enableRTL;
|
|
35
45
|
@property(nonatomic) BOOL enableAnnotationRendering;
|
|
@@ -43,4 +53,4 @@ NS_CLASS_AVAILABLE_IOS(11_0) @interface RCTPdfView : UIView <UIGestureRecognizer
|
|
|
43
53
|
|
|
44
54
|
@end
|
|
45
55
|
|
|
46
|
-
#endif /*
|
|
56
|
+
#endif /* RNPDFPdfView_h */
|