react-native-pdf-jsi 1.0.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/DoubleTapView.js +125 -0
- package/INTEGRATION_GUIDE.md +419 -0
- package/LICENSE +21 -0
- package/PdfManager.js +26 -0
- package/PdfPageView.js +53 -0
- package/PdfView.js +421 -0
- package/PdfViewFlatList.js +30 -0
- package/PinchZoomView.js +125 -0
- package/README.md +693 -0
- package/README_JSI.md +348 -0
- package/android/.gradle/5.6.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/5.6.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/5.6.1/gc.properties +0 -0
- package/android/.gradle/8.5/checksums/checksums.lock +0 -0
- package/android/.gradle/8.5/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.5/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.5/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/8.5/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.5/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.5/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.5/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.5/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +198 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/android/gradle.properties +2 -0
- package/android/gradlew +249 -0
- package/android/gradlew.bat +92 -0
- package/android/project.properties +12 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/cpp/Android.mk +50 -0
- package/android/src/main/cpp/CMakeLists.txt +76 -0
- package/android/src/main/cpp/PDFJSI.cpp +190 -0
- package/android/src/main/cpp/PDFJSI.h +95 -0
- package/android/src/main/cpp/PDFJSIBridge.cpp +32 -0
- package/android/src/main/cpp/PDFJSIModule.cpp +31 -0
- package/android/src/main/java/org/wonday/pdf/EnhancedPdfJSIBridge.java +281 -0
- package/android/src/main/java/org/wonday/pdf/PDFJSIManager.java +317 -0
- package/android/src/main/java/org/wonday/pdf/PDFJSIModule.java +189 -0
- package/android/src/main/java/org/wonday/pdf/PdfManager.java +180 -0
- package/android/src/main/java/org/wonday/pdf/PdfView.java +505 -0
- package/android/src/main/java/org/wonday/pdf/RNPDFPackage.java +43 -0
- package/android/src/main/java/org/wonday/pdf/events/TopChangeEvent.java +26 -0
- package/android/src/main/jniLibs/arm64-v8a/libpdfjsi.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libpdfjsi.so +0 -0
- package/android/src/main/jniLibs/x86/libpdfjsi.so +0 -0
- package/android/src/main/jniLibs/x86_64/libpdfjsi.so +0 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.java +92 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.java +35 -0
- package/fabric/RNPDFPdfNativeComponent.js +48 -0
- package/index.d.ts +72 -0
- package/index.js +603 -0
- package/index.js.flow +67 -0
- package/ios/RNPDFPdf/PdfManager.h +23 -0
- package/ios/RNPDFPdf/PdfManager.mm +152 -0
- package/ios/RNPDFPdf/RNPDFPdfPageView.h +21 -0
- package/ios/RNPDFPdf/RNPDFPdfPageView.mm +185 -0
- package/ios/RNPDFPdf/RNPDFPdfPageViewManager.h +18 -0
- package/ios/RNPDFPdf/RNPDFPdfPageViewManager.mm +30 -0
- package/ios/RNPDFPdf/RNPDFPdfView.h +63 -0
- package/ios/RNPDFPdf/RNPDFPdfView.mm +1092 -0
- package/ios/RNPDFPdf/RNPDFPdfViewManager.h +18 -0
- package/ios/RNPDFPdf/RNPDFPdfViewManager.mm +68 -0
- package/ios/RNPDFPdf.xcodeproj/project.pbxproj +321 -0
- package/package.json +78 -0
- package/react-native-pdf.podspec +31 -0
- package/src/EnhancedPdfView.js +362 -0
- package/src/PDFJSI.js +519 -0
- package/src/examples/PDFJSIExample.js +296 -0
- package/src/hooks/usePDFJSI.js +346 -0
- package/src/index.js +32 -0
- package/windows/RCTPdf/PropertySheet.props +16 -0
- package/windows/RCTPdf/RCTPdf.def +3 -0
- package/windows/RCTPdf/RCTPdf.vcxproj +180 -0
- package/windows/RCTPdf/RCTPdf.vcxproj.filters +38 -0
- package/windows/RCTPdf/RCTPdfControl.cpp +667 -0
- package/windows/RCTPdf/RCTPdfControl.h +119 -0
- package/windows/RCTPdf/RCTPdfControl.idl +10 -0
- package/windows/RCTPdf/RCTPdfControl.xaml +33 -0
- package/windows/RCTPdf/RCTPdfViewManager.cpp +69 -0
- package/windows/RCTPdf/RCTPdfViewManager.h +51 -0
- package/windows/RCTPdf/ReactPackageProvider.cpp +15 -0
- package/windows/RCTPdf/ReactPackageProvider.h +16 -0
- package/windows/RCTPdf/ReactPackageProvider.idl +9 -0
- package/windows/RCTPdf/packages.config +4 -0
- package/windows/RCTPdf/pch.cpp +1 -0
- package/windows/RCTPdf/pch.h +31 -0
- package/windows/README.md +21 -0
|
@@ -0,0 +1,152 @@
|
|
|
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
|
+
|
|
11
|
+
#import "PdfManager.h"
|
|
12
|
+
|
|
13
|
+
#if __has_include(<React/RCTAssert.h>)
|
|
14
|
+
#import <React/RCTUtils.h>
|
|
15
|
+
#else
|
|
16
|
+
#import "React/RCTUtils.h"
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
static NSMutableArray *pdfDocRefs = Nil;
|
|
21
|
+
|
|
22
|
+
@implementation PdfManager
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
#ifndef __OPTIMIZE__
|
|
26
|
+
// only output log when debug
|
|
27
|
+
#define DLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
|
|
28
|
+
#else
|
|
29
|
+
#define DLog( s, ... )
|
|
30
|
+
#endif
|
|
31
|
+
|
|
32
|
+
// output log both debug and release
|
|
33
|
+
#define RLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
|
|
34
|
+
|
|
35
|
+
RCT_EXPORT_MODULE();
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
RCT_EXPORT_METHOD(loadFile:(NSString *)path
|
|
39
|
+
password:(NSString *)password
|
|
40
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
41
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
42
|
+
)
|
|
43
|
+
{
|
|
44
|
+
|
|
45
|
+
if (pdfDocRefs==Nil) {
|
|
46
|
+
pdfDocRefs = [NSMutableArray arrayWithCapacity:1];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
int numberOfPages = 0;
|
|
50
|
+
|
|
51
|
+
if (path != nil && path.length != 0) {
|
|
52
|
+
|
|
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];
|
|
64
|
+
CGPDFDocumentRef pdfRef = CGPDFDocumentCreateWithURL((__bridge CFURLRef) pdfURL);
|
|
65
|
+
|
|
66
|
+
if (pdfRef == NULL) {
|
|
67
|
+
reject(RCTErrorUnspecified, [NSString stringWithFormat:@"Load pdf failed. path=%s",path.UTF8String], nil);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (CGPDFDocumentIsEncrypted(pdfRef)) {
|
|
72
|
+
|
|
73
|
+
bool isUnlocked = CGPDFDocumentUnlockWithPassword(pdfRef, [password UTF8String]);
|
|
74
|
+
if (!isUnlocked) {
|
|
75
|
+
reject(RCTErrorUnspecified, @"Password required or incorrect password.", nil);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
[pdfDocRefs addObject:[NSValue valueWithPointer:pdfRef]];
|
|
82
|
+
|
|
83
|
+
numberOfPages = (int)CGPDFDocumentGetNumberOfPages(pdfRef);
|
|
84
|
+
CGPDFPageRef pdfPage = CGPDFDocumentGetPage(pdfRef, 1);
|
|
85
|
+
CGRect pdfPageRect = CGPDFPageGetBoxRect(pdfPage, kCGPDFMediaBox);
|
|
86
|
+
int rotation = CGPDFPageGetRotationAngle(pdfPage);
|
|
87
|
+
|
|
88
|
+
NSArray *params;
|
|
89
|
+
|
|
90
|
+
if (rotation == 90 || rotation==270) {
|
|
91
|
+
params =@[[NSNumber numberWithUnsignedLong:([pdfDocRefs count]-1)], [NSNumber numberWithInt:numberOfPages], [NSNumber numberWithFloat:pdfPageRect.size.height], [NSNumber numberWithFloat:pdfPageRect.size.width]];
|
|
92
|
+
RLog(@"Pdf loaded numberOfPages=%d, fileNo=%lu, pageWidth=%f, pageHeight=%f", numberOfPages, [pdfDocRefs count]-1, pdfPageRect.size.height, pdfPageRect.size.width);
|
|
93
|
+
|
|
94
|
+
} else {
|
|
95
|
+
params =@[[NSNumber numberWithUnsignedLong:([pdfDocRefs count]-1)], [NSNumber numberWithInt:numberOfPages], [NSNumber numberWithFloat:pdfPageRect.size.width], [NSNumber numberWithFloat:pdfPageRect.size.height]];
|
|
96
|
+
RLog(@"Pdf loaded numberOfPages=%d, fileNo=%lu, pageWidth=%f, pageHeight=%f", numberOfPages, [pdfDocRefs count]-1, pdfPageRect.size.width, pdfPageRect.size.height);
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
resolve(params);
|
|
101
|
+
return;
|
|
102
|
+
} else {
|
|
103
|
+
reject(RCTErrorUnspecified, @"Load pdf failed. path=null", nil);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
+ (CGPDFDocumentRef) getPdf:(NSUInteger) index
|
|
109
|
+
{
|
|
110
|
+
if (pdfDocRefs && [pdfDocRefs count]>index){
|
|
111
|
+
|
|
112
|
+
return (CGPDFDocumentRef)[(NSValue *)[pdfDocRefs objectAtIndex:index] pointerValue];
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return NULL;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
- (instancetype)init
|
|
120
|
+
{
|
|
121
|
+
|
|
122
|
+
if ((self = [super init])) {
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
return self;
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
+ (BOOL)requiresMainQueueSetup
|
|
130
|
+
{
|
|
131
|
+
return YES;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
- (void)dealloc
|
|
136
|
+
{
|
|
137
|
+
// release pdf docs
|
|
138
|
+
for(NSValue *item in pdfDocRefs) {
|
|
139
|
+
CGPDFDocumentRef pdfItem = (CGPDFDocumentRef)[item pointerValue];
|
|
140
|
+
if (pdfItem != NULL) {
|
|
141
|
+
|
|
142
|
+
CGPDFDocumentRelease(pdfItem);
|
|
143
|
+
pdfItem = NULL;
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
pdfDocRefs = Nil;
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
@end
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
#if __has_include(<React/RCTAssert.h>)
|
|
10
|
+
#import <React/UIView+React.h>
|
|
11
|
+
#else
|
|
12
|
+
#import "UIView+React.h"
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@interface RNPDFPdfPageView : UIView
|
|
17
|
+
|
|
18
|
+
@property(nonatomic) int fileNo;
|
|
19
|
+
@property(nonatomic) int page;
|
|
20
|
+
|
|
21
|
+
@end
|
|
@@ -0,0 +1,185 @@
|
|
|
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
|
+
#import "PdfManager.h"
|
|
10
|
+
#import "RNPDFPdfPageView.h"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
#import <Foundation/Foundation.h>
|
|
15
|
+
#import <QuartzCore/QuartzCore.h>
|
|
16
|
+
|
|
17
|
+
#if __has_include(<React/RCTAssert.h>)
|
|
18
|
+
#import <React/RCTBridgeModule.h>
|
|
19
|
+
#import <React/RCTEventDispatcher.h>
|
|
20
|
+
#import <React/UIView+React.h>
|
|
21
|
+
#import <React/RCTLog.h>
|
|
22
|
+
#else
|
|
23
|
+
#import "RCTBridgeModule.h"
|
|
24
|
+
#import "RCTEventDispatcher.h"
|
|
25
|
+
#import "UIView+React.h"
|
|
26
|
+
#import "RCTLog.h"
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
#ifndef __OPTIMIZE__
|
|
30
|
+
// only output log when debug
|
|
31
|
+
#define DLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
|
|
32
|
+
#else
|
|
33
|
+
#define DLog( s, ... )
|
|
34
|
+
#endif
|
|
35
|
+
|
|
36
|
+
// output log both debug and release
|
|
37
|
+
#define RLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
|
|
38
|
+
|
|
39
|
+
@interface CAPdfLayer : CALayer
|
|
40
|
+
-(void) setParentView:(RNPDFPdfPageView *)parentView;
|
|
41
|
+
@end
|
|
42
|
+
|
|
43
|
+
@implementation CAPdfLayer
|
|
44
|
+
{
|
|
45
|
+
RNPDFPdfPageView *_parentView;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
-(void) setParentView:(RNPDFPdfPageView *)parentView
|
|
49
|
+
{
|
|
50
|
+
_parentView = parentView;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
- (void)drawInContext:(CGContextRef)context
|
|
54
|
+
{
|
|
55
|
+
|
|
56
|
+
CGRect _viewFrame = _parentView.frame;
|
|
57
|
+
CGPDFDocumentRef pdfRef= [PdfManager getPdf:_parentView.fileNo];
|
|
58
|
+
if (pdfRef!=NULL)
|
|
59
|
+
{
|
|
60
|
+
|
|
61
|
+
CGPDFPageRef pdfPage = CGPDFDocumentGetPage(pdfRef, _parentView.page);
|
|
62
|
+
|
|
63
|
+
if (pdfPage != NULL) {
|
|
64
|
+
|
|
65
|
+
// Fill the background with white.
|
|
66
|
+
CGContextSetRGBFillColor(context, 1.0,1.0,1.0,1.0);
|
|
67
|
+
CGContextFillRect(context, _viewFrame);
|
|
68
|
+
|
|
69
|
+
// PDF page drawing expects a Lower-Left coordinate system, so we flip the coordinate system before drawing.
|
|
70
|
+
CGContextScaleCTM(context, 1.0, -1.0);
|
|
71
|
+
CGContextTranslateCTM(context, 0, -_viewFrame.size.height);
|
|
72
|
+
|
|
73
|
+
CGRect pdfPageRect = CGPDFPageGetBoxRect(pdfPage, kCGPDFMediaBox);
|
|
74
|
+
|
|
75
|
+
int rotation = CGPDFPageGetRotationAngle(pdfPage);
|
|
76
|
+
if (rotation == 90 || rotation == 270) {
|
|
77
|
+
pdfPageRect = CGRectMake(0, 0, pdfPageRect.size.height, pdfPageRect.size.width);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
CGFloat scale = 1.0f;
|
|
81
|
+
if (_viewFrame.size.width/_viewFrame.size.height>=pdfPageRect.size.width/pdfPageRect.size.height) {
|
|
82
|
+
scale = _viewFrame.size.height/pdfPageRect.size.height;
|
|
83
|
+
|
|
84
|
+
} else {
|
|
85
|
+
scale = _viewFrame.size.width/pdfPageRect.size.width;
|
|
86
|
+
}
|
|
87
|
+
CGContextScaleCTM(context, scale, scale);
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
switch (rotation) {
|
|
92
|
+
case 0:
|
|
93
|
+
if (_viewFrame.size.width/_viewFrame.size.height>=pdfPageRect.size.width/pdfPageRect.size.height) {
|
|
94
|
+
CGContextTranslateCTM(context, (_viewFrame.size.width-pdfPageRect.size.width*scale)/2, 0);
|
|
95
|
+
} else {
|
|
96
|
+
CGContextTranslateCTM(context, 0, (_viewFrame.size.height-pdfPageRect.size.height*scale)/2);
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
case 90:
|
|
100
|
+
CGContextRotateCTM(context, -rotation*M_PI/180);
|
|
101
|
+
CGContextTranslateCTM(context, -pdfPageRect.size.height, 0);
|
|
102
|
+
if (_viewFrame.size.width/_viewFrame.size.height>=pdfPageRect.size.width/pdfPageRect.size.height) {
|
|
103
|
+
CGContextTranslateCTM(context, 0, -(_viewFrame.size.height-pdfPageRect.size.height*scale)/2);
|
|
104
|
+
} else {
|
|
105
|
+
CGContextTranslateCTM(context, -(_viewFrame.size.height/scale-pdfPageRect.size.height)/2, 0);
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
case 180:
|
|
109
|
+
CGContextRotateCTM(context, -rotation*M_PI/180);
|
|
110
|
+
CGContextTranslateCTM(context, -pdfPageRect.size.height, -pdfPageRect.size.width);
|
|
111
|
+
if (_viewFrame.size.width/_viewFrame.size.height>=pdfPageRect.size.width/pdfPageRect.size.height) {
|
|
112
|
+
CGContextTranslateCTM(context, (_viewFrame.size.width-pdfPageRect.size.width*scale)/2, 0);
|
|
113
|
+
} else {
|
|
114
|
+
CGContextTranslateCTM(context, 0, (_viewFrame.size.height-pdfPageRect.size.height*scale)/2);
|
|
115
|
+
}
|
|
116
|
+
case 270:
|
|
117
|
+
CGContextRotateCTM(context, -rotation*M_PI/180);
|
|
118
|
+
CGContextTranslateCTM(context, 0, -pdfPageRect.size.width);
|
|
119
|
+
if (_viewFrame.size.width/_viewFrame.size.height>=pdfPageRect.size.width/pdfPageRect.size.height) {
|
|
120
|
+
CGContextTranslateCTM(context, 0, -(_viewFrame.size.height-pdfPageRect.size.height*scale)/2);
|
|
121
|
+
} else {
|
|
122
|
+
CGContextTranslateCTM(context, -(_viewFrame.size.height/scale-pdfPageRect.size.height)/2, 0);
|
|
123
|
+
}
|
|
124
|
+
default:
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
// draw the content to context
|
|
130
|
+
CGContextDrawPDFPage(context, pdfPage);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
@end
|
|
136
|
+
|
|
137
|
+
@implementation RNPDFPdfPageView {
|
|
138
|
+
|
|
139
|
+
CAPdfLayer *_layer;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// The layer's class
|
|
143
|
+
+ (Class)layerClass
|
|
144
|
+
{
|
|
145
|
+
return [CAPdfLayer class];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
- (instancetype)init
|
|
149
|
+
{
|
|
150
|
+
self = [super init];
|
|
151
|
+
if (self) {
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return self;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
- (void)didSetProps:(NSArray<NSString *> *)changedProps
|
|
159
|
+
{
|
|
160
|
+
long int count = [changedProps count];
|
|
161
|
+
for (int i = 0 ; i < count; i++) {
|
|
162
|
+
if ([[changedProps objectAtIndex:i] isEqualToString:@"page"]) {
|
|
163
|
+
// do something
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
[self.layer setNeedsDisplay];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
- (void)reactSetFrame:(CGRect)frame
|
|
172
|
+
{
|
|
173
|
+
[super reactSetFrame:frame];
|
|
174
|
+
|
|
175
|
+
self.layer.backgroundColor= [UIColor whiteColor].CGColor;
|
|
176
|
+
self.layer.contentsScale = [[UIScreen mainScreen] scale];
|
|
177
|
+
[(CAPdfLayer *)self.layer setParentView:self];
|
|
178
|
+
[self.layer setNeedsDisplay];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
- (void)dealloc{
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
@end
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
#if __has_include(<React/RCTAssert.h>)
|
|
10
|
+
#import <React/RCTViewManager.h>
|
|
11
|
+
#else
|
|
12
|
+
#import "RCTViewManager.h"
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@interface RNPDFPdfPageViewManager : RCTViewManager
|
|
17
|
+
|
|
18
|
+
@end
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
#import <Foundation/Foundation.h>
|
|
10
|
+
|
|
11
|
+
#import "RNPDFPdfPageViewManager.h"
|
|
12
|
+
#import "RNPDFPdfPageView.h"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@implementation RNPDFPdfPageViewManager
|
|
16
|
+
|
|
17
|
+
RCT_EXPORT_MODULE()
|
|
18
|
+
|
|
19
|
+
- (UIView *)view
|
|
20
|
+
{
|
|
21
|
+
return [[RNPDFPdfPageView alloc] init];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
RCT_EXPORT_VIEW_PROPERTY(fileNo, int);
|
|
25
|
+
RCT_EXPORT_VIEW_PROPERTY(page, int);
|
|
26
|
+
|
|
27
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
28
|
+
return YES;
|
|
29
|
+
}
|
|
30
|
+
@end
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
#ifndef RNPDFPdfView_h
|
|
10
|
+
#define RNPDFPdfView_h
|
|
11
|
+
|
|
12
|
+
#if __has_include(<React/RCTAssert.h>)
|
|
13
|
+
#import <React/RCTEventDispatcher.h>
|
|
14
|
+
#import <React/UIView+React.h>
|
|
15
|
+
#else
|
|
16
|
+
#import "RCTEventDispatcher.h"
|
|
17
|
+
#import "UIView+React.h"
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
21
|
+
#import <React/RCTViewComponentView.h>
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
@class RCTEventDispatcher;
|
|
25
|
+
|
|
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>
|
|
33
|
+
- (instancetype)initWithBridge:(RCTBridge *)bridge;
|
|
34
|
+
|
|
35
|
+
@property(nonatomic, strong) NSString *path;
|
|
36
|
+
@property(nonatomic) int page;
|
|
37
|
+
@property(nonatomic) float scale;
|
|
38
|
+
@property(nonatomic) float minScale;
|
|
39
|
+
@property(nonatomic) float maxScale;
|
|
40
|
+
@property(nonatomic) BOOL horizontal;
|
|
41
|
+
@property(nonatomic) BOOL showsVerticalScrollIndicator;
|
|
42
|
+
@property(nonatomic) BOOL showsHorizontalScrollIndicator;
|
|
43
|
+
@property(nonatomic) BOOL scrollEnabled;
|
|
44
|
+
@property(nonatomic) BOOL enablePaging;
|
|
45
|
+
@property(nonatomic) BOOL enableRTL;
|
|
46
|
+
@property(nonatomic) BOOL enableAnnotationRendering;
|
|
47
|
+
@property(nonatomic) BOOL enableDoubleTapZoom;
|
|
48
|
+
@property(nonatomic) int fitPolicy;
|
|
49
|
+
@property(nonatomic) int spacing;
|
|
50
|
+
@property(nonatomic, strong) NSString *password;
|
|
51
|
+
@property(nonatomic) BOOL singlePage;
|
|
52
|
+
|
|
53
|
+
@property(nonatomic, copy) RCTBubblingEventBlock onChange;
|
|
54
|
+
|
|
55
|
+
// Enhanced progressive loading method declarations
|
|
56
|
+
- (NSDictionary *)getPerformanceMetrics;
|
|
57
|
+
- (void)clearCache;
|
|
58
|
+
- (void)preloadPagesFrom:(int)startPage to:(int)endPage;
|
|
59
|
+
- (NSDictionary *)searchText:(NSString *)searchTerm;
|
|
60
|
+
|
|
61
|
+
@end
|
|
62
|
+
|
|
63
|
+
#endif /* RNPDFPdfView_h */
|