react-native-pdf 6.7.6 → 7.0.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/PdfView.js +4 -0
- package/README.md +12 -2
- package/android/build.gradle +2 -2
- package/android/src/main/java/org/wonday/pdf/PdfManager.java +3 -3
- package/android/src/main/java/org/wonday/pdf/PdfView.java +47 -5
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.java +3 -2
- package/index.d.ts +1 -3
- package/ios/RNPDFPdf/RNPDFPdfView.mm +23 -35
- package/package.json +8 -3
package/PdfView.js
CHANGED
|
@@ -40,6 +40,8 @@ export default class PdfView extends Component {
|
|
|
40
40
|
singlePage: PropTypes.bool,
|
|
41
41
|
onPageSingleTap: PropTypes.func,
|
|
42
42
|
onScaleChanged: PropTypes.func,
|
|
43
|
+
showsHorizontalScrollIndicator: PropTypes.bool,
|
|
44
|
+
showsVerticalScrollIndicator: PropTypes.bool,
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
static defaultProps = {
|
|
@@ -62,6 +64,8 @@ export default class PdfView extends Component {
|
|
|
62
64
|
},
|
|
63
65
|
onScaleChanged: (scale) => {
|
|
64
66
|
},
|
|
67
|
+
showsHorizontalScrollIndicator: true,
|
|
68
|
+
showsVerticalScrollIndicator: true,
|
|
65
69
|
};
|
|
66
70
|
|
|
67
71
|
constructor(props) {
|
package/README.md
CHANGED
|
@@ -168,6 +168,17 @@ react-native run-ios
|
|
|
168
168
|
### ChangeLog
|
|
169
169
|
<details>
|
|
170
170
|
<summary>ChangeLog details</summary>
|
|
171
|
+
v7.0.0
|
|
172
|
+
1. Fixed: not rendering on iOS
|
|
173
|
+
2. Added: Android 16 KB Page Size support
|
|
174
|
+
3. Fixed: crash issue in io.legere:pdfiumandroid that occurred due to multithreading
|
|
175
|
+
4. Added: Upgrade Fabric Example to Latest React Native 0.81.0
|
|
176
|
+
5. Added: support RTL android
|
|
177
|
+
|
|
178
|
+
v6.7.7
|
|
179
|
+
1. Added: add support for customizable scroll indicators in PdfView component (#904)
|
|
180
|
+
2. Fixed: fix field values not being visible on android. issue #864 :bug: (#896)
|
|
181
|
+
|
|
171
182
|
v6.7.6
|
|
172
183
|
1. Fixed: Add missing 'enableDoubleTapZoom' to fabric codegen source (#832)
|
|
173
184
|
2. Fixed: added missing 'scrollEnabled' prop (#842)
|
|
@@ -324,7 +335,7 @@ const styles = StyleSheet.create({
|
|
|
324
335
|
| style | object | {backgroundColor:"#eee"} | support normal view style, you can use this to set border/spacing color... | ✔ | ✔ | ✔ | <3.0
|
|
325
336
|
| progressContainerStyle | object | {backgroundColor:"#eee"} | support normal view style, you can use this to set border/spacing color... | ✔ | ✔ | ✔ | 6.9.0 |
|
|
326
337
|
| renderActivityIndicator | (progress) => Component | <ProgressBar/> | when loading show it as an indicator, you can use your component | ✔ | ✔ | ✖ | <3.0 |
|
|
327
|
-
| enableAntialiasing | bool | true | improve rendering a little bit on low-res screens, but maybe
|
|
338
|
+
| enableAntialiasing | bool | true | improve rendering a little bit on low-res screens, but maybe cause some problem on Android 4.4, so add a switch | ✖ | ✔ | ✖ | <3.0 |
|
|
328
339
|
| enablePaging | bool | false | only show one page in screen | ✔ | ✔ | ✔ | 5.0.1 |
|
|
329
340
|
| enableRTL | bool | false | scroll page as "page3, page2, page1" | ✔ | ✖ | ✔ | 5.0.1 |
|
|
330
341
|
| enableAnnotationRendering | bool | true | enable rendering annotation, notice:iOS only support initial setting,not support realtime changing | ✔ | ✔ | ✖ | 5.0.3 |
|
|
@@ -388,4 +399,3 @@ Example:
|
|
|
388
399
|
```
|
|
389
400
|
this.pdf.setPage(42); // Display the answer to the Ultimate Question of Life, the Universe, and Everything
|
|
390
401
|
```
|
|
391
|
-
|
package/android/build.gradle
CHANGED
|
@@ -126,6 +126,6 @@ dependencies {
|
|
|
126
126
|
// The repo from zacharee is based on PdfiumAndroidKt, a much newer fork of PdfiumAndroid, with better maintenance and updated native libraries.
|
|
127
127
|
implementation 'com.github.zacharee:AndroidPdfViewer:4.0.1'
|
|
128
128
|
// Depend on PdfiumAndroidKt directly so this can be updated independently of AndroidPdfViewer as updates are provided.
|
|
129
|
-
implementation 'io.legere:pdfiumandroid:1.0.
|
|
130
|
-
implementation 'com.google.code.gson:gson:2.
|
|
129
|
+
implementation 'io.legere:pdfiumandroid:1.0.34'
|
|
130
|
+
implementation 'com.google.code.gson:gson:2.13.2'
|
|
131
131
|
}
|
|
@@ -99,9 +99,9 @@ public class PdfManager extends SimpleViewManager<PdfView> implements RNPDFPdfVi
|
|
|
99
99
|
// NOOP on Android
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
@
|
|
103
|
-
public void
|
|
104
|
-
|
|
102
|
+
@ReactProp(name = "enableRTL")
|
|
103
|
+
public void setEnableRTL(PdfView view, boolean enableRTL) {
|
|
104
|
+
pdfView.setEnableRTL(enableRTL);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
@ReactProp(name = "scrollEnabled")
|
|
@@ -12,6 +12,8 @@ import java.io.File;
|
|
|
12
12
|
|
|
13
13
|
import android.content.ContentResolver;
|
|
14
14
|
import android.content.Context;
|
|
15
|
+
import android.os.Handler;
|
|
16
|
+
import android.os.Looper;
|
|
15
17
|
import android.util.SizeF;
|
|
16
18
|
import android.view.View;
|
|
17
19
|
import android.view.ViewGroup;
|
|
@@ -75,6 +77,7 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
75
77
|
private FitPolicy fitPolicy = FitPolicy.WIDTH;
|
|
76
78
|
private boolean singlePage = false;
|
|
77
79
|
private boolean scrollEnabled = true;
|
|
80
|
+
private boolean enableRTL = false;
|
|
78
81
|
|
|
79
82
|
private float originalWidth = 0;
|
|
80
83
|
private float lastPageWidth = 0;
|
|
@@ -84,6 +87,10 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
84
87
|
private int oldW = 0;
|
|
85
88
|
private int oldH = 0;
|
|
86
89
|
|
|
90
|
+
private int totalPages = 0;
|
|
91
|
+
private int[] pagesArrays;
|
|
92
|
+
private int bookmarks = 0;
|
|
93
|
+
|
|
87
94
|
public PdfView(Context context, AttributeSet set){
|
|
88
95
|
super(context, set);
|
|
89
96
|
}
|
|
@@ -105,7 +112,7 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
105
112
|
TopChangeEvent tce = new TopChangeEvent(surfaceId, getId(), event);
|
|
106
113
|
|
|
107
114
|
if (dispatcher != null) {
|
|
108
|
-
dispatcher.dispatchEvent(tce);
|
|
115
|
+
new Handler(Looper.getMainLooper()).postDelayed(() -> dispatcher.dispatchEvent(tce), 10);
|
|
109
116
|
}
|
|
110
117
|
|
|
111
118
|
// ReactContext reactContext = (ReactContext)this.getContext();
|
|
@@ -280,7 +287,34 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
280
287
|
|
|
281
288
|
public void drawPdf() {
|
|
282
289
|
showLog(format("drawPdf path:%s %s", this.path, this.page));
|
|
283
|
-
|
|
290
|
+
File file = new File(this.path);
|
|
291
|
+
|
|
292
|
+
if (file.exists()) {
|
|
293
|
+
try {
|
|
294
|
+
ParcelFileDescriptor fileDescriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
|
|
295
|
+
PdfRenderer pdfRenderer = new PdfRenderer(fileDescriptor);
|
|
296
|
+
this.totalPages = pdfRenderer.getPageCount();
|
|
297
|
+
int[] pagesArrays = new int[this.totalPages];
|
|
298
|
+
if (this.enableRTL) {
|
|
299
|
+
if(this.page>0){
|
|
300
|
+
this.page= this.bookmarks-1;
|
|
301
|
+
}else{
|
|
302
|
+
this.page=this.totalPages;
|
|
303
|
+
}
|
|
304
|
+
for (int i = totalPages-1; i>=0; i--) {
|
|
305
|
+
pagesArrays[i] =totalPages-1- i;
|
|
306
|
+
}
|
|
307
|
+
this.pagesArrays = pagesArrays;
|
|
308
|
+
|
|
309
|
+
}else{
|
|
310
|
+
this.pagesArrays = null;
|
|
311
|
+
this.page=this.bookmarks-1;
|
|
312
|
+
}
|
|
313
|
+
} catch (IOException e) {
|
|
314
|
+
Log.e("error", "error read PDF", e);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
284
318
|
if (this.path != null){
|
|
285
319
|
|
|
286
320
|
// set scale
|
|
@@ -306,7 +340,9 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
306
340
|
configurator = this.fromUri(getURI(this.path));
|
|
307
341
|
}
|
|
308
342
|
|
|
309
|
-
configurator
|
|
343
|
+
configurator
|
|
344
|
+
.pages(this.pagesArrays)
|
|
345
|
+
.defaultPage(this.page)
|
|
310
346
|
.swipeHorizontal(this.horizontal)
|
|
311
347
|
.onPageChange(this)
|
|
312
348
|
.onLoad(this)
|
|
@@ -346,9 +382,15 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
346
382
|
|
|
347
383
|
// page start from 1
|
|
348
384
|
public void setPage(int page) {
|
|
349
|
-
this.page = page
|
|
385
|
+
this.page = page;
|
|
386
|
+
this.bookmarks = page;
|
|
350
387
|
}
|
|
351
388
|
|
|
389
|
+
public void setEnableRTL(boolean enableRTL){
|
|
390
|
+
this.enableRTL= enableRTL;
|
|
391
|
+
|
|
392
|
+
}
|
|
393
|
+
|
|
352
394
|
public void setScale(float scale) {
|
|
353
395
|
this.scale = scale;
|
|
354
396
|
}
|
|
@@ -502,4 +544,4 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
502
544
|
}
|
|
503
545
|
}
|
|
504
546
|
}
|
|
505
|
-
}
|
|
547
|
+
}
|
package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.java
CHANGED
|
@@ -13,9 +13,10 @@ import android.view.View;
|
|
|
13
13
|
import androidx.annotation.Nullable;
|
|
14
14
|
import com.facebook.react.bridge.ReadableArray;
|
|
15
15
|
import com.facebook.react.uimanager.BaseViewManagerDelegate;
|
|
16
|
-
import com.facebook.react.uimanager.
|
|
16
|
+
import com.facebook.react.uimanager.BaseViewManager;
|
|
17
|
+
import com.facebook.react.uimanager.LayoutShadowNode;
|
|
17
18
|
|
|
18
|
-
public class RNPDFPdfViewManagerDelegate<T extends View, U extends
|
|
19
|
+
public class RNPDFPdfViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNPDFPdfViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
|
|
19
20
|
public RNPDFPdfViewManagerDelegate(U viewManager) {
|
|
20
21
|
super(viewManager);
|
|
21
22
|
}
|
package/index.d.ts
CHANGED
|
@@ -65,8 +65,6 @@ export interface PdfProps {
|
|
|
65
65
|
onPressLink?: (url: string) => void,
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
declare
|
|
69
|
-
setPage: (pageNumber: number) => void;
|
|
70
|
-
}
|
|
68
|
+
declare const Pdf: React.ComponentType<PdfProps> & { setPage(pageNumber: number): void };
|
|
71
69
|
|
|
72
70
|
export default Pdf;
|
|
@@ -292,7 +292,10 @@ using namespace facebook::react;
|
|
|
292
292
|
// Disable built-in double tap, so as not to conflict with custom recognizers.
|
|
293
293
|
for (UIGestureRecognizer *recognizer in _pdfView.gestureRecognizers) {
|
|
294
294
|
if ([recognizer isKindOfClass:[UITapGestureRecognizer class]]) {
|
|
295
|
-
|
|
295
|
+
UITapGestureRecognizer *tap = (UITapGestureRecognizer *)recognizer;
|
|
296
|
+
if (tap.numberOfTapsRequired == 2) {
|
|
297
|
+
recognizer.enabled = NO;
|
|
298
|
+
}
|
|
296
299
|
}
|
|
297
300
|
}
|
|
298
301
|
|
|
@@ -479,40 +482,8 @@ using namespace facebook::react;
|
|
|
479
482
|
}
|
|
480
483
|
}
|
|
481
484
|
|
|
482
|
-
if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"showsHorizontalScrollIndicator"])) {
|
|
483
|
-
|
|
484
|
-
for (UIView *subview in _pdfView.subviews) {
|
|
485
|
-
if ([subview isKindOfClass:[UIScrollView class]]) {
|
|
486
|
-
UIScrollView *scrollView = (UIScrollView *)subview;
|
|
487
|
-
scrollView.showsHorizontalScrollIndicator = YES;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
} else {
|
|
491
|
-
for (UIView *subview in _pdfView.subviews) {
|
|
492
|
-
if ([subview isKindOfClass:[UIScrollView class]]) {
|
|
493
|
-
UIScrollView *scrollView = (UIScrollView *)subview;
|
|
494
|
-
scrollView.showsHorizontalScrollIndicator = NO;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"showsVerticalScrollIndicator"])) {
|
|
501
|
-
if (_showsVerticalScrollIndicator) {
|
|
502
|
-
for (UIView *subview in _pdfView.subviews) {
|
|
503
|
-
if ([subview isKindOfClass:[UIScrollView class]]) {
|
|
504
|
-
UIScrollView *scrollView = (UIScrollView *)subview;
|
|
505
|
-
scrollView.showsVerticalScrollIndicator = YES;
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
} else {
|
|
509
|
-
for (UIView *subview in _pdfView.subviews) {
|
|
510
|
-
if ([subview isKindOfClass:[UIScrollView class]]) {
|
|
511
|
-
UIScrollView *scrollView = (UIScrollView *)subview;
|
|
512
|
-
scrollView.showsVerticalScrollIndicator = NO;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
}
|
|
485
|
+
if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"showsHorizontalScrollIndicator"] || [changedProps containsObject:@"showsVerticalScrollIndicator"])) {
|
|
486
|
+
[self setScrollIndicators:self horizontal:_showsHorizontalScrollIndicator vertical:_showsVerticalScrollIndicator depth:0];
|
|
516
487
|
}
|
|
517
488
|
|
|
518
489
|
if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"scrollEnabled"])) {
|
|
@@ -928,6 +899,23 @@ using namespace facebook::react;
|
|
|
928
899
|
return !_singlePage;
|
|
929
900
|
}
|
|
930
901
|
|
|
902
|
+
- (void)setScrollIndicators:(UIView *)view horizontal:(BOOL)horizontal vertical:(BOOL)vertical depth:(int)depth {
|
|
903
|
+
// max depth, prevent infinite loop
|
|
904
|
+
if (depth > 10) {
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
if ([view isKindOfClass:[UIScrollView class]]) {
|
|
909
|
+
UIScrollView *scrollView = (UIScrollView *)view;
|
|
910
|
+
scrollView.showsHorizontalScrollIndicator = horizontal;
|
|
911
|
+
scrollView.showsVerticalScrollIndicator = vertical;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
for (UIView *subview in view.subviews) {
|
|
915
|
+
[self setScrollIndicators:subview horizontal:horizontal vertical:vertical depth:depth + 1];
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
|
|
931
919
|
@end
|
|
932
920
|
|
|
933
921
|
#ifdef RCT_NEW_ARCH_ENABLED
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-pdf",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.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",
|
|
@@ -62,7 +62,12 @@
|
|
|
62
62
|
"type": "components",
|
|
63
63
|
"jsSrcsDir": "./fabric",
|
|
64
64
|
"android": {
|
|
65
|
-
|
|
65
|
+
"javaPackageName": "org.wonday.pdf"
|
|
66
|
+
},
|
|
67
|
+
"ios": {
|
|
68
|
+
"componentProvider": {
|
|
69
|
+
"RNPDFPdfView": "RNPDFPdfView"
|
|
70
|
+
}
|
|
66
71
|
}
|
|
67
|
-
|
|
72
|
+
}
|
|
68
73
|
}
|