react-native-pdf 6.2.2 → 6.5.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.
- package/PdfManager.js +6 -11
- package/PinchZoomView.js +1 -1
- package/README.md +120 -94
- 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/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 +3 -3
- package/android/src/main/java/org/wonday/pdf/PdfView.java +21 -2
- package/index.d.ts +13 -3
- package/index.js +25 -37
- package/index.js.flow +3 -3
- package/ios/RCTPdf/RCTPdfView.h +2 -0
- package/ios/RCTPdf/RCTPdfView.m +111 -94
- package/ios/RCTPdf/RCTPdfViewManager.m +1 -1
- package/ios/RCTPdf.xcodeproj/xcuserdata/wonday.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/package.json +21 -6
- 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 +29 -0
- package/windows/README.md +21 -0
- package/.babelrc +0 -3
- package/example/.eslintrc.js +0 -4
- package/example/PDFExample.js +0 -176
- package/example/android/app/BUCK +0 -55
- package/example/android/app/build.gradle +0 -210
- package/example/android/app/build_defs.bzl +0 -19
- package/example/android/app/proguard-rules.pro +0 -10
- package/example/android/app/src/debug/AndroidManifest.xml +0 -8
- package/example/android/app/src/main/AndroidManifest.xml +0 -26
- package/example/android/app/src/main/assets/test.pdf +0 -0
- package/example/android/app/src/main/java/com/pdfexample/MainActivity.java +0 -15
- package/example/android/app/src/main/java/com/pdfexample/MainApplication.java +0 -49
- package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/values/strings.xml +0 -3
- package/example/android/app/src/main/res/values/styles.xml +0 -9
- package/example/android/build.gradle +0 -38
- package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/example/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/example/android/gradle.properties +0 -21
- package/example/android/gradlew +0 -188
- package/example/android/gradlew.bat +0 -100
- package/example/android/settings.gradle +0 -3
- package/example/app.json +0 -4
- package/example/babel.config.js +0 -3
- package/example/index.js +0 -9
- package/example/ios/PDFExample/AppDelegate.h +0 -15
- package/example/ios/PDFExample/AppDelegate.m +0 -42
- package/example/ios/PDFExample/Base.lproj/LaunchScreen.xib +0 -42
- package/example/ios/PDFExample/Images.xcassets/AppIcon.appiconset/Contents.json +0 -38
- package/example/ios/PDFExample/Images.xcassets/Contents.json +0 -6
- package/example/ios/PDFExample/Info.plist +0 -57
- package/example/ios/PDFExample/main.m +0 -16
- package/example/ios/PDFExample-tvOS/Info.plist +0 -53
- package/example/ios/PDFExample-tvOSTests/Info.plist +0 -24
- package/example/ios/PDFExample.xcodeproj/project.pbxproj +0 -923
- package/example/ios/PDFExample.xcodeproj/xcshareddata/xcschemes/PDFExample-tvOS.xcscheme +0 -129
- package/example/ios/PDFExample.xcodeproj/xcshareddata/xcschemes/PDFExample.xcscheme +0 -129
- package/example/ios/PDFExample.xcworkspace/contents.xcworkspacedata +0 -10
- package/example/ios/PDFExampleTests/Info.plist +0 -24
- package/example/ios/PDFExampleTests/PDFExampleTests.m +0 -68
- package/example/ios/Podfile +0 -47
- package/example/ios/Podfile.lock +0 -205
- package/example/metro.config.js +0 -17
- package/example/package.json +0 -42
- package/example/test.pdf +0 -0
- package/issue_template.md +0 -13
package/index.js.flow
CHANGED
|
@@ -17,6 +17,7 @@ export type FitBoth = 2;
|
|
|
17
17
|
export type Source = {
|
|
18
18
|
body?: string | FormField[],
|
|
19
19
|
cache?: boolean,
|
|
20
|
+
cacheFileName?: string,
|
|
20
21
|
expiration?: number,
|
|
21
22
|
headers?: { [key: string]: string },
|
|
22
23
|
method?: Methods,
|
|
@@ -31,8 +32,7 @@ export type TableContent = {
|
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
export type Props = {
|
|
34
|
-
|
|
35
|
-
activityIndicatorProps?: { [prop: string]: mixed },
|
|
35
|
+
renderActivityIndicator?: (progress: number) => Node,
|
|
36
36
|
enableAnnotationRendering?: boolean,
|
|
37
37
|
enableAntialiasing?: boolean,
|
|
38
38
|
enablePaging?: boolean,
|
|
@@ -41,7 +41,7 @@ export type Props = {
|
|
|
41
41
|
horizontal?: boolean,
|
|
42
42
|
maxScale?: number,
|
|
43
43
|
minScale?: number,
|
|
44
|
-
singlePage
|
|
44
|
+
singlePage?: boolean,
|
|
45
45
|
onError?: (error: Error) => void,
|
|
46
46
|
onLoadComplete?: (numberOfPages: number, path: string, size: { height: number, width: number }, tableContents: ?TableContent[]) => void,
|
|
47
47
|
onLoadProgress?: (percent: number) => void,
|
package/ios/RCTPdf/RCTPdfView.h
CHANGED
|
@@ -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;
|
package/ios/RCTPdf/RCTPdfView.m
CHANGED
|
@@ -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)
|
|
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;
|
|
@@ -63,7 +67,7 @@ const float MIN_SCALE = 1.0f;
|
|
|
63
67
|
_fitPolicy = 2;
|
|
64
68
|
_spacing = 10;
|
|
65
69
|
_singlePage = NO;
|
|
66
|
-
|
|
70
|
+
|
|
67
71
|
// init and config PDFView
|
|
68
72
|
_pdfView = [[PDFView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
|
|
69
73
|
_pdfView.displayMode = kPDFDisplaySinglePageContinuous;
|
|
@@ -75,23 +79,23 @@ const float MIN_SCALE = 1.0f;
|
|
|
75
79
|
_fixScaleFactor = -1.0f;
|
|
76
80
|
_initialed = NO;
|
|
77
81
|
_changedProps = NULL;
|
|
78
|
-
|
|
82
|
+
|
|
79
83
|
[self addSubview:_pdfView];
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
|
|
85
|
+
|
|
82
86
|
// register notification
|
|
83
87
|
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
|
84
88
|
[center addObserver:self selector:@selector(onDocumentChanged:) name:PDFViewDocumentChangedNotification object:_pdfView];
|
|
85
89
|
[center addObserver:self selector:@selector(onPageChanged:) name:PDFViewPageChangedNotification object:_pdfView];
|
|
86
90
|
[center addObserver:self selector:@selector(onScaleChanged:) name:PDFViewScaleChangedNotification object:_pdfView];
|
|
87
|
-
|
|
91
|
+
|
|
88
92
|
[[_pdfView document] setDelegate: self];
|
|
89
93
|
[_pdfView setDelegate: self];
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
|
|
95
|
+
|
|
92
96
|
[self bindTap];
|
|
93
97
|
}
|
|
94
|
-
|
|
98
|
+
|
|
95
99
|
return self;
|
|
96
100
|
}
|
|
97
101
|
|
|
@@ -107,43 +111,52 @@ const float MIN_SCALE = 1.0f;
|
|
|
107
111
|
- (void)didSetProps:(NSArray<NSString *> *)changedProps
|
|
108
112
|
{
|
|
109
113
|
if (!_initialed) {
|
|
110
|
-
|
|
114
|
+
|
|
111
115
|
_changedProps = changedProps;
|
|
112
|
-
|
|
116
|
+
|
|
113
117
|
} else {
|
|
114
|
-
|
|
118
|
+
|
|
115
119
|
if ([changedProps containsObject:@"path"]) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
120
|
+
|
|
121
|
+
|
|
119
122
|
if (_pdfDocument != Nil) {
|
|
120
123
|
//Release old doc
|
|
121
124
|
_pdfDocument = Nil;
|
|
122
125
|
}
|
|
123
126
|
|
|
124
|
-
|
|
125
|
-
|
|
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
|
+
NSURL *fileURL = [NSURL fileURLWithPath:_path];
|
|
136
|
+
_pdfDocument = [[PDFDocument alloc] initWithURL:fileURL];
|
|
137
|
+
}
|
|
138
|
+
|
|
126
139
|
if (_pdfDocument) {
|
|
127
|
-
|
|
140
|
+
|
|
128
141
|
//check need password or not
|
|
129
142
|
if (_pdfDocument.isLocked && ![_pdfDocument unlockWithPassword:_password]) {
|
|
130
|
-
|
|
143
|
+
|
|
131
144
|
_onChange(@{ @"message": @"error|Password required or incorrect password."});
|
|
132
|
-
|
|
145
|
+
|
|
133
146
|
_pdfDocument = Nil;
|
|
134
147
|
return;
|
|
135
148
|
}
|
|
136
|
-
|
|
149
|
+
|
|
137
150
|
_pdfView.document = _pdfDocument;
|
|
138
151
|
} else {
|
|
139
|
-
|
|
152
|
+
|
|
140
153
|
_onChange(@{ @"message": [[NSString alloc] initWithString:[NSString stringWithFormat:@"error|Load pdf failed. path=%s",_path.UTF8String]]});
|
|
141
|
-
|
|
154
|
+
|
|
142
155
|
_pdfDocument = Nil;
|
|
143
156
|
return;
|
|
144
157
|
}
|
|
145
158
|
}
|
|
146
|
-
|
|
159
|
+
|
|
147
160
|
if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"spacing"])) {
|
|
148
161
|
if (_horizontal) {
|
|
149
162
|
_pdfView.pageBreakMargins = UIEdgeInsetsMake(0,_spacing,0,0);
|
|
@@ -169,11 +182,11 @@ const float MIN_SCALE = 1.0f;
|
|
|
169
182
|
}
|
|
170
183
|
}
|
|
171
184
|
}
|
|
172
|
-
|
|
185
|
+
|
|
173
186
|
if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"enableRTL"])) {
|
|
174
187
|
_pdfView.displaysRTL = _enableRTL;
|
|
175
188
|
}
|
|
176
|
-
|
|
189
|
+
|
|
177
190
|
if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"enableAnnotationRendering"])) {
|
|
178
191
|
if (!_enableAnnotationRendering) {
|
|
179
192
|
for (unsigned long i=0; i<_pdfView.document.pageCount; i++) {
|
|
@@ -184,17 +197,17 @@ const float MIN_SCALE = 1.0f;
|
|
|
184
197
|
}
|
|
185
198
|
}
|
|
186
199
|
}
|
|
187
|
-
|
|
200
|
+
|
|
188
201
|
if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"fitPolicy"] || [changedProps containsObject:@"minScale"] || [changedProps containsObject:@"maxScale"])) {
|
|
189
|
-
|
|
202
|
+
|
|
190
203
|
PDFPage *pdfPage = [_pdfDocument pageAtIndex:_pdfDocument.pageCount-1];
|
|
191
204
|
CGRect pdfPageRect = [pdfPage boundsForBox:kPDFDisplayBoxCropBox];
|
|
192
|
-
|
|
205
|
+
|
|
193
206
|
// some pdf with rotation, then adjust it
|
|
194
207
|
if (pdfPage.rotation == 90 || pdfPage.rotation == 270) {
|
|
195
208
|
pdfPageRect = CGRectMake(0, 0, pdfPageRect.size.height, pdfPageRect.size.width);
|
|
196
209
|
}
|
|
197
|
-
|
|
210
|
+
|
|
198
211
|
if (_fitPolicy == 0) {
|
|
199
212
|
_fixScaleFactor = self.frame.size.width/pdfPageRect.size.width;
|
|
200
213
|
_pdfView.scaleFactor = _scale * _fixScaleFactor;
|
|
@@ -220,15 +233,15 @@ const float MIN_SCALE = 1.0f;
|
|
|
220
233
|
_pdfView.maxScaleFactor = _fixScaleFactor*_maxScale;
|
|
221
234
|
}
|
|
222
235
|
}
|
|
223
|
-
|
|
236
|
+
|
|
224
237
|
}
|
|
225
|
-
|
|
238
|
+
|
|
226
239
|
if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"scale"])) {
|
|
227
240
|
_pdfView.scaleFactor = _scale * _fixScaleFactor;
|
|
228
241
|
if (_pdfView.scaleFactor>_pdfView.maxScaleFactor) _pdfView.scaleFactor = _pdfView.maxScaleFactor;
|
|
229
242
|
if (_pdfView.scaleFactor<_pdfView.minScaleFactor) _pdfView.scaleFactor = _pdfView.minScaleFactor;
|
|
230
243
|
}
|
|
231
|
-
|
|
244
|
+
|
|
232
245
|
if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"horizontal"])) {
|
|
233
246
|
if (_horizontal) {
|
|
234
247
|
_pdfView.displayDirection = kPDFDisplayDirectionHorizontal;
|
|
@@ -238,7 +251,7 @@ const float MIN_SCALE = 1.0f;
|
|
|
238
251
|
_pdfView.pageBreakMargins = UIEdgeInsetsMake(0,0,_spacing,0);
|
|
239
252
|
}
|
|
240
253
|
}
|
|
241
|
-
|
|
254
|
+
|
|
242
255
|
if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"enablePaging"])) {
|
|
243
256
|
if (_enablePaging) {
|
|
244
257
|
[_pdfView usePageViewController:YES withViewOptions:@{UIPageViewControllerOptionSpineLocationKey:@(UIPageViewControllerSpineLocationMin),UIPageViewControllerOptionInterPageSpacingKey:@(_spacing)}];
|
|
@@ -256,26 +269,26 @@ const float MIN_SCALE = 1.0f;
|
|
|
256
269
|
_pdfView.userInteractionEnabled = YES;
|
|
257
270
|
}
|
|
258
271
|
}
|
|
259
|
-
|
|
272
|
+
|
|
260
273
|
if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"enablePaging"] || [changedProps containsObject:@"horizontal"] || [changedProps containsObject:@"page"])) {
|
|
261
|
-
|
|
274
|
+
|
|
262
275
|
PDFPage *pdfPage = [_pdfDocument pageAtIndex:_page-1];
|
|
263
276
|
if (pdfPage) {
|
|
264
277
|
CGRect pdfPageRect = [pdfPage boundsForBox:kPDFDisplayBoxCropBox];
|
|
265
|
-
|
|
278
|
+
|
|
266
279
|
// some pdf with rotation, then adjust it
|
|
267
280
|
if (pdfPage.rotation == 90 || pdfPage.rotation == 270) {
|
|
268
281
|
pdfPageRect = CGRectMake(0, 0, pdfPageRect.size.height, pdfPageRect.size.width);
|
|
269
282
|
}
|
|
270
|
-
|
|
283
|
+
|
|
271
284
|
CGPoint pointLeftTop = CGPointMake(0, pdfPageRect.size.height);
|
|
272
285
|
PDFDestination *pdfDest = [[PDFDestination alloc] initWithPage:pdfPage atPoint:pointLeftTop];
|
|
273
286
|
[_pdfView goToDestination:pdfDest];
|
|
274
287
|
_pdfView.scaleFactor = _fixScaleFactor*_scale;
|
|
275
288
|
}
|
|
276
289
|
}
|
|
277
|
-
|
|
278
|
-
|
|
290
|
+
|
|
291
|
+
_pdfView.backgroundColor = [UIColor clearColor];
|
|
279
292
|
[_pdfView layoutDocumentView];
|
|
280
293
|
[self setNeedsDisplay];
|
|
281
294
|
}
|
|
@@ -286,129 +299,133 @@ const float MIN_SCALE = 1.0f;
|
|
|
286
299
|
{
|
|
287
300
|
[super reactSetFrame:frame];
|
|
288
301
|
_pdfView.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
|
|
289
|
-
|
|
302
|
+
|
|
303
|
+
NSMutableArray *mProps = [_changedProps mutableCopy];
|
|
304
|
+
if (_initialed) {
|
|
305
|
+
[mProps removeObject:@"path"];
|
|
306
|
+
}
|
|
290
307
|
_initialed = YES;
|
|
291
|
-
|
|
292
|
-
[self didSetProps:
|
|
308
|
+
|
|
309
|
+
[self didSetProps:mProps];
|
|
293
310
|
}
|
|
294
311
|
|
|
295
312
|
- (void)dealloc{
|
|
296
|
-
|
|
313
|
+
|
|
297
314
|
_pdfDocument = Nil;
|
|
298
315
|
_pdfView = Nil;
|
|
299
|
-
|
|
316
|
+
|
|
300
317
|
//Remove notifications
|
|
301
318
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"PDFViewDocumentChangedNotification" object:nil];
|
|
302
319
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"PDFViewPageChangedNotification" object:nil];
|
|
303
320
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"PDFViewScaleChangedNotification" object:nil];
|
|
304
|
-
|
|
321
|
+
|
|
305
322
|
}
|
|
306
323
|
|
|
307
324
|
#pragma mark notification process
|
|
308
325
|
- (void)onDocumentChanged:(NSNotification *)noti
|
|
309
326
|
{
|
|
310
|
-
|
|
327
|
+
|
|
311
328
|
if (_pdfDocument) {
|
|
312
|
-
|
|
329
|
+
|
|
313
330
|
unsigned long numberOfPages = _pdfDocument.pageCount;
|
|
314
331
|
PDFPage *page = [_pdfDocument pageAtIndex:_pdfDocument.pageCount-1];
|
|
315
332
|
CGSize pageSize = [_pdfView rowSizeForPage:page];
|
|
316
333
|
NSString *jsonString = [self getTableContents];
|
|
317
|
-
|
|
334
|
+
|
|
318
335
|
_onChange(@{ @"message": [[NSString alloc] initWithString:[NSString stringWithFormat:@"loadComplete|%lu|%f|%f|%@", numberOfPages, pageSize.width, pageSize.height,jsonString]]});
|
|
319
336
|
}
|
|
320
|
-
|
|
337
|
+
|
|
321
338
|
}
|
|
322
339
|
|
|
323
340
|
-(NSString *) getTableContents
|
|
324
341
|
{
|
|
325
|
-
|
|
342
|
+
|
|
326
343
|
NSMutableArray<PDFOutline *> *arrTableOfContents = [[NSMutableArray alloc] init];
|
|
327
|
-
|
|
344
|
+
|
|
328
345
|
if (_pdfDocument.outlineRoot) {
|
|
329
|
-
|
|
346
|
+
|
|
330
347
|
PDFOutline *currentRoot = _pdfDocument.outlineRoot;
|
|
331
348
|
NSMutableArray<PDFOutline *> *stack = [[NSMutableArray alloc] init];
|
|
332
|
-
|
|
349
|
+
|
|
333
350
|
[stack addObject:currentRoot];
|
|
334
|
-
|
|
351
|
+
|
|
335
352
|
while (stack.count > 0) {
|
|
336
|
-
|
|
353
|
+
|
|
337
354
|
PDFOutline *currentOutline = stack.lastObject;
|
|
338
355
|
[stack removeLastObject];
|
|
339
|
-
|
|
356
|
+
|
|
340
357
|
if (currentOutline.label.length > 0){
|
|
341
358
|
[arrTableOfContents addObject:currentOutline];
|
|
342
359
|
}
|
|
343
|
-
|
|
360
|
+
|
|
344
361
|
for ( NSInteger i= currentOutline.numberOfChildren; i > 0; i-- )
|
|
345
362
|
{
|
|
346
363
|
[stack addObject:[currentOutline childAtIndex:i-1]];
|
|
347
364
|
}
|
|
348
365
|
}
|
|
349
366
|
}
|
|
350
|
-
|
|
367
|
+
|
|
351
368
|
NSMutableArray *arrParentsContents = [[NSMutableArray alloc] init];
|
|
352
|
-
|
|
369
|
+
|
|
353
370
|
for ( NSInteger i= 0; i < arrTableOfContents.count; i++ )
|
|
354
371
|
{
|
|
355
372
|
PDFOutline *currentOutline = [arrTableOfContents objectAtIndex:i];
|
|
356
|
-
|
|
373
|
+
|
|
357
374
|
NSInteger indentationLevel = -1;
|
|
358
|
-
|
|
375
|
+
|
|
359
376
|
PDFOutline *parentOutline = currentOutline.parent;
|
|
360
|
-
|
|
377
|
+
|
|
361
378
|
while (parentOutline != nil) {
|
|
362
379
|
indentationLevel += 1;
|
|
363
380
|
parentOutline = parentOutline.parent;
|
|
364
381
|
}
|
|
365
|
-
|
|
382
|
+
|
|
366
383
|
if (indentationLevel == 0) {
|
|
367
|
-
|
|
384
|
+
|
|
368
385
|
NSMutableDictionary *DXParentsContent = [[NSMutableDictionary alloc] init];
|
|
369
|
-
|
|
386
|
+
|
|
370
387
|
[DXParentsContent setObject:[[NSMutableArray alloc] init] forKey:@"children"];
|
|
371
388
|
[DXParentsContent setObject:@"" forKey:@"mNativePtr"];
|
|
372
389
|
[DXParentsContent setObject:[NSString stringWithFormat:@"%lu", [_pdfDocument indexForPage:currentOutline.destination.page]] forKey:@"pageIdx"];
|
|
373
390
|
[DXParentsContent setObject:currentOutline.label forKey:@"title"];
|
|
374
|
-
|
|
391
|
+
|
|
375
392
|
//currentOutlin
|
|
376
393
|
//mNativePtr
|
|
377
394
|
[arrParentsContents addObject:DXParentsContent];
|
|
378
395
|
}
|
|
379
396
|
else {
|
|
380
397
|
NSMutableDictionary *DXParentsContent = [arrParentsContents lastObject];
|
|
381
|
-
|
|
398
|
+
|
|
382
399
|
NSMutableArray *arrChildren = [DXParentsContent valueForKey:@"children"];
|
|
383
|
-
|
|
400
|
+
|
|
384
401
|
while (indentationLevel > 1) {
|
|
385
402
|
NSMutableDictionary *DXchild = [arrChildren lastObject];
|
|
386
403
|
arrChildren = [DXchild valueForKey:@"children"];
|
|
387
404
|
indentationLevel--;
|
|
388
405
|
}
|
|
389
|
-
|
|
406
|
+
|
|
390
407
|
NSMutableDictionary *DXChildContent = [[NSMutableDictionary alloc] init];
|
|
391
408
|
[DXChildContent setObject:[[NSMutableArray alloc] init] forKey:@"children"];
|
|
392
409
|
[DXChildContent setObject:@"" forKey:@"mNativePtr"];
|
|
393
410
|
[DXChildContent setObject:[NSString stringWithFormat:@"%lu", [_pdfDocument indexForPage:currentOutline.destination.page]] forKey:@"pageIdx"];
|
|
394
411
|
[DXChildContent setObject:currentOutline.label forKey:@"title"];
|
|
395
412
|
[arrChildren addObject:DXChildContent];
|
|
396
|
-
|
|
413
|
+
|
|
397
414
|
}
|
|
398
415
|
}
|
|
399
|
-
|
|
416
|
+
|
|
400
417
|
NSError *error;
|
|
401
418
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:arrParentsContents options:NSJSONWritingPrettyPrinted error:&error];
|
|
402
|
-
|
|
419
|
+
|
|
403
420
|
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
404
|
-
|
|
421
|
+
|
|
405
422
|
return jsonString;
|
|
406
|
-
|
|
423
|
+
|
|
407
424
|
}
|
|
408
425
|
|
|
409
426
|
- (void)onPageChanged:(NSNotification *)noti
|
|
410
427
|
{
|
|
411
|
-
|
|
428
|
+
|
|
412
429
|
if (_pdfDocument) {
|
|
413
430
|
PDFPage *currentPage = _pdfView.currentPage;
|
|
414
431
|
unsigned long page = [_pdfDocument indexForPage:currentPage];
|
|
@@ -416,12 +433,12 @@ const float MIN_SCALE = 1.0f;
|
|
|
416
433
|
|
|
417
434
|
_onChange(@{ @"message": [[NSString alloc] initWithString:[NSString stringWithFormat:@"pageChanged|%lu|%lu", page+1, numberOfPages]]});
|
|
418
435
|
}
|
|
419
|
-
|
|
436
|
+
|
|
420
437
|
}
|
|
421
438
|
|
|
422
439
|
- (void)onScaleChanged:(NSNotification *)noti
|
|
423
440
|
{
|
|
424
|
-
|
|
441
|
+
|
|
425
442
|
if (_initialed && _fixScaleFactor>0) {
|
|
426
443
|
if (_scale != _pdfView.scaleFactor/_fixScaleFactor) {
|
|
427
444
|
_scale = _pdfView.scaleFactor/_fixScaleFactor;
|
|
@@ -452,7 +469,7 @@ const float MIN_SCALE = 1.0f;
|
|
|
452
469
|
} else {
|
|
453
470
|
scale = min;
|
|
454
471
|
}
|
|
455
|
-
|
|
472
|
+
|
|
456
473
|
CGFloat newScale = scale * self->_fixScaleFactor;
|
|
457
474
|
CGPoint tapPoint = [recognizer locationInView:self->_pdfView];
|
|
458
475
|
tapPoint = [self->_pdfView convertPoint:tapPoint toPage:self->_pdfView.currentPage];
|
|
@@ -461,12 +478,12 @@ const float MIN_SCALE = 1.0f;
|
|
|
461
478
|
zoomRect.size.height = self->_pdfView.frame.size.height * newScale;
|
|
462
479
|
zoomRect.origin.x = tapPoint.x - zoomRect.size.width / 2;
|
|
463
480
|
zoomRect.origin.y = tapPoint.y - zoomRect.size.height / 2;
|
|
464
|
-
|
|
481
|
+
|
|
465
482
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
466
483
|
[UIView animateWithDuration:0.3 animations:^{
|
|
467
484
|
[self->_pdfView setScaleFactor:newScale];
|
|
468
485
|
[self->_pdfView goToRect:zoomRect onPage:self->_pdfView.currentPage];
|
|
469
|
-
|
|
486
|
+
|
|
470
487
|
[self setNeedsDisplay];
|
|
471
488
|
[self onScaleChanged:Nil];
|
|
472
489
|
}];
|
|
@@ -482,18 +499,18 @@ const float MIN_SCALE = 1.0f;
|
|
|
482
499
|
- (void)handleSingleTap:(UITapGestureRecognizer *)sender
|
|
483
500
|
{
|
|
484
501
|
//_pdfView.scaleFactor = _pdfView.minScaleFactor;
|
|
485
|
-
|
|
502
|
+
|
|
486
503
|
CGPoint point = [sender locationInView:self];
|
|
487
504
|
PDFPage *pdfPage = [_pdfView pageForPoint:point nearest:NO];
|
|
488
505
|
if (pdfPage) {
|
|
489
506
|
unsigned long page = [_pdfDocument indexForPage:pdfPage];
|
|
490
507
|
_onChange(@{ @"message": [[NSString alloc] initWithString:[NSString stringWithFormat:@"pageSingleTap|%lu|%f|%f", page+1, point.x, point.y]]});
|
|
491
508
|
}
|
|
492
|
-
|
|
509
|
+
|
|
493
510
|
//[self setNeedsDisplay];
|
|
494
511
|
//[self onScaleChanged:Nil];
|
|
495
|
-
|
|
496
|
-
|
|
512
|
+
|
|
513
|
+
|
|
497
514
|
}
|
|
498
515
|
|
|
499
516
|
/**
|
|
@@ -512,7 +529,7 @@ const float MIN_SCALE = 1.0f;
|
|
|
512
529
|
*
|
|
513
530
|
*/
|
|
514
531
|
- (void)handleLongPress:(UILongPressGestureRecognizer *)sender{
|
|
515
|
-
|
|
532
|
+
|
|
516
533
|
}
|
|
517
534
|
|
|
518
535
|
/**
|
|
@@ -528,33 +545,33 @@ const float MIN_SCALE = 1.0f;
|
|
|
528
545
|
doubleTapRecognizer.numberOfTapsRequired = 2;
|
|
529
546
|
doubleTapRecognizer.numberOfTouchesRequired = 1;
|
|
530
547
|
doubleTapRecognizer.delegate = self;
|
|
531
|
-
|
|
548
|
+
|
|
532
549
|
[self addGestureRecognizer:doubleTapRecognizer];
|
|
533
|
-
|
|
550
|
+
|
|
534
551
|
UITapGestureRecognizer *singleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self
|
|
535
552
|
action:@selector(handleSingleTap:)];
|
|
536
553
|
//trigger by one finger and one touch
|
|
537
554
|
singleTapRecognizer.numberOfTapsRequired = 1;
|
|
538
555
|
singleTapRecognizer.numberOfTouchesRequired = 1;
|
|
539
556
|
singleTapRecognizer.delegate = self;
|
|
540
|
-
|
|
557
|
+
|
|
541
558
|
[self addGestureRecognizer:singleTapRecognizer];
|
|
542
559
|
[singleTapRecognizer requireGestureRecognizerToFail:doubleTapRecognizer];
|
|
543
|
-
|
|
560
|
+
|
|
544
561
|
UIPinchGestureRecognizer *pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self
|
|
545
562
|
action:@selector(handlePinch:)];
|
|
546
563
|
[self addGestureRecognizer:pinchRecognizer];
|
|
547
564
|
pinchRecognizer.delegate = self;
|
|
548
|
-
|
|
565
|
+
|
|
549
566
|
UILongPressGestureRecognizer *longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self
|
|
550
567
|
action:@selector(handleLongPress:)];
|
|
551
568
|
// Making sure the allowable movement isn not too narrow
|
|
552
569
|
longPressRecognizer.allowableMovement=100;
|
|
553
570
|
// Important: The duration must be long enough to allow taps but not longer than the period in which view opens the magnifying glass
|
|
554
571
|
longPressRecognizer.minimumPressDuration=0.3;
|
|
555
|
-
|
|
572
|
+
|
|
556
573
|
[self addGestureRecognizer:longPressRecognizer];
|
|
557
|
-
|
|
574
|
+
|
|
558
575
|
}
|
|
559
576
|
|
|
560
577
|
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
|
|
@@ -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]
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-pdf",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.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
6
|
"main": "index.js",
|
|
@@ -28,9 +28,24 @@
|
|
|
28
28
|
"url": "https://github.com/wonday/react-native-pdf/issues"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"crypto-js": "^3.2.0"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
}
|
|
31
|
+
"crypto-js": "^3.2.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"prop-types": "^15.7.2"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"android/",
|
|
38
|
+
"ios/",
|
|
39
|
+
"windows/",
|
|
40
|
+
"DoubleTapView.js",
|
|
41
|
+
"index.d.ts",
|
|
42
|
+
"index.js",
|
|
43
|
+
"index.js.flow",
|
|
44
|
+
"PdfManager.js",
|
|
45
|
+
"PdfPageView.js",
|
|
46
|
+
"PdfView.js",
|
|
47
|
+
"PdfViewFlatList.js",
|
|
48
|
+
"PinchZoomView.js",
|
|
49
|
+
"react-native-pdf.podspec"
|
|
50
|
+
]
|
|
36
51
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<ImportGroup Label="PropertySheets" />
|
|
4
|
+
<PropertyGroup Label="UserMacros" />
|
|
5
|
+
<!--
|
|
6
|
+
To customize common C++/WinRT project properties:
|
|
7
|
+
* right-click the project node
|
|
8
|
+
* expand the Common Properties item
|
|
9
|
+
* select the C++/WinRT property page
|
|
10
|
+
|
|
11
|
+
For more advanced scenarios, and complete documentation, please see:
|
|
12
|
+
https://github.com/Microsoft/xlang/tree/master/src/package/cppwinrt/nuget
|
|
13
|
+
-->
|
|
14
|
+
<PropertyGroup />
|
|
15
|
+
<ItemDefinitionGroup />
|
|
16
|
+
</Project>
|