react-native-pdf 6.7.7 → 7.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/README.md CHANGED
@@ -85,7 +85,7 @@ react-native link react-native-pdf
85
85
 
86
86
  ### Windows installation
87
87
  <details>
88
- <sumary>Windows details</summary>
88
+ <summary>Windows details</summary>
89
89
 
90
90
  - Open your solution in Visual Studio 2019 (eg. `windows\yourapp.sln`)
91
91
  - Right-click Solution icon in Solution Explorer > Add > Existing Project...
@@ -168,6 +168,13 @@ react-native run-ios
168
168
  ### ChangeLog
169
169
  <details>
170
170
  <summary>ChangeLog details</summary>
171
+ v7.0.1
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
+
171
178
  v6.7.7
172
179
  1. Added: add support for customizable scroll indicators in PdfView component (#904)
173
180
  2. Fixed: fix field values not being visible on android. issue #864 :bug: (#896)
@@ -328,7 +335,7 @@ const styles = StyleSheet.create({
328
335
  | style | object | {backgroundColor:"#eee"} | support normal view style, you can use this to set border/spacing color... | ✔ | ✔ | ✔ | <3.0
329
336
  | progressContainerStyle | object | {backgroundColor:"#eee"} | support normal view style, you can use this to set border/spacing color... | ✔ | ✔ | ✔ | 6.9.0 |
330
337
  | renderActivityIndicator | (progress) => Component | <ProgressBar/> | when loading show it as an indicator, you can use your component | ✔ | ✔ | ✖ | <3.0 |
331
- | enableAntialiasing | bool | true | improve rendering a little bit on low-res screens, but maybe course some problem on Android 4.4, so add a switch | ✖ | ✔ | ✖ | <3.0 |
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 |
332
339
  | enablePaging | bool | false | only show one page in screen | ✔ | ✔ | ✔ | 5.0.1 |
333
340
  | enableRTL | bool | false | scroll page as "page3, page2, page1" | ✔ | ✖ | ✔ | 5.0.1 |
334
341
  | enableAnnotationRendering | bool | true | enable rendering annotation, notice:iOS only support initial setting,not support realtime changing | ✔ | ✔ | ✖ | 5.0.3 |
@@ -391,4 +398,4 @@ Set the current page of the PDF component. pageNumber is a positive integer. If
391
398
  Example:
392
399
  ```
393
400
  this.pdf.setPage(42); // Display the answer to the Ultimate Question of Life, the Universe, and Everything
394
- ```
401
+ ```
@@ -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.24'
130
- implementation 'com.google.code.gson:gson:2.8.5'
129
+ implementation 'io.legere:pdfiumandroid:1.0.34'
130
+ implementation 'com.google.code.gson:gson:2.13.2'
131
131
  }
@@ -99,11 +99,16 @@ public class PdfManager extends SimpleViewManager<PdfView> implements RNPDFPdfVi
99
99
  // NOOP on Android
100
100
  }
101
101
 
102
- @Override
102
+ @Override
103
103
  public void setShowsVerticalScrollIndicator(PdfView view, boolean value) {
104
104
  // NOOP on Android
105
105
  }
106
106
 
107
+ @ReactProp(name = "enableRTL")
108
+ public void setEnableRTL(PdfView view, boolean enableRTL) {
109
+ pdfView.setEnableRTL(enableRTL);
110
+ }
111
+
107
112
  @ReactProp(name = "scrollEnabled")
108
113
  public void setScrollEnabled(PdfView view, boolean scrollEnabled) {
109
114
  pdfView.setScrollEnabled(scrollEnabled);
@@ -139,11 +144,6 @@ public class PdfManager extends SimpleViewManager<PdfView> implements RNPDFPdfVi
139
144
  pdfView.setEnablePaging(enablePaging);
140
145
  }
141
146
 
142
- @Override
143
- public void setEnableRTL(PdfView view, boolean value) {
144
- // NOOP on Android
145
- }
146
-
147
147
  @ReactProp(name = "fitPolicy")
148
148
  public void setFitPolicy(PdfView pdfView, int fitPolicy) {
149
149
  pdfView.setFitPolicy(fitPolicy);
@@ -9,9 +9,13 @@
9
9
  package org.wonday.pdf;
10
10
 
11
11
  import java.io.File;
12
+ import java.io.IOException;
12
13
 
13
14
  import android.content.ContentResolver;
14
15
  import android.content.Context;
16
+ import android.os.Handler;
17
+ import android.os.Looper;
18
+ import android.os.ParcelFileDescriptor;
15
19
  import android.util.SizeF;
16
20
  import android.view.View;
17
21
  import android.view.ViewGroup;
@@ -20,7 +24,7 @@ import android.net.Uri;
20
24
  import android.util.AttributeSet;
21
25
  import android.view.MotionEvent;
22
26
  import android.graphics.Canvas;
23
-
27
+ import android.graphics.pdf.PdfRenderer;
24
28
 
25
29
  import com.facebook.react.uimanager.ThemedReactContext;
26
30
  import com.facebook.react.uimanager.UIManagerHelper;
@@ -75,6 +79,7 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
75
79
  private FitPolicy fitPolicy = FitPolicy.WIDTH;
76
80
  private boolean singlePage = false;
77
81
  private boolean scrollEnabled = true;
82
+ private boolean enableRTL = false;
78
83
 
79
84
  private float originalWidth = 0;
80
85
  private float lastPageWidth = 0;
@@ -84,6 +89,10 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
84
89
  private int oldW = 0;
85
90
  private int oldH = 0;
86
91
 
92
+ private int totalPages = 0;
93
+ private int[] pagesArrays;
94
+ private int bookmarks = 0;
95
+
87
96
  public PdfView(Context context, AttributeSet set){
88
97
  super(context, set);
89
98
  }
@@ -105,7 +114,7 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
105
114
  TopChangeEvent tce = new TopChangeEvent(surfaceId, getId(), event);
106
115
 
107
116
  if (dispatcher != null) {
108
- dispatcher.dispatchEvent(tce);
117
+ new Handler(Looper.getMainLooper()).postDelayed(() -> dispatcher.dispatchEvent(tce), 10);
109
118
  }
110
119
 
111
120
  // ReactContext reactContext = (ReactContext)this.getContext();
@@ -280,7 +289,34 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
280
289
 
281
290
  public void drawPdf() {
282
291
  showLog(format("drawPdf path:%s %s", this.path, this.page));
283
-
292
+ File file = new File(this.path);
293
+
294
+ if (file.exists()) {
295
+ try {
296
+ ParcelFileDescriptor fileDescriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
297
+ PdfRenderer pdfRenderer = new PdfRenderer(fileDescriptor);
298
+ this.totalPages = pdfRenderer.getPageCount();
299
+ int[] pagesArrays = new int[this.totalPages];
300
+ if (this.enableRTL) {
301
+ if(this.page>0){
302
+ this.page= this.bookmarks-1;
303
+ }else{
304
+ this.page=this.totalPages;
305
+ }
306
+ for (int i = totalPages-1; i>=0; i--) {
307
+ pagesArrays[i] =totalPages-1- i;
308
+ }
309
+ this.pagesArrays = pagesArrays;
310
+
311
+ }else{
312
+ this.pagesArrays = null;
313
+ this.page=this.bookmarks-1;
314
+ }
315
+ } catch (IOException e) {
316
+ Log.e("error", "error read PDF", e);
317
+ }
318
+ }
319
+
284
320
  if (this.path != null){
285
321
 
286
322
  // set scale
@@ -306,7 +342,9 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
306
342
  configurator = this.fromUri(getURI(this.path));
307
343
  }
308
344
 
309
- configurator.defaultPage(this.page-1)
345
+ configurator
346
+ .pages(this.pagesArrays)
347
+ .defaultPage(this.page)
310
348
  .swipeHorizontal(this.horizontal)
311
349
  .onPageChange(this)
312
350
  .onLoad(this)
@@ -346,9 +384,15 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
346
384
 
347
385
  // page start from 1
348
386
  public void setPage(int page) {
349
- this.page = page>1?page:1;
387
+ this.page = page;
388
+ this.bookmarks = page;
350
389
  }
351
390
 
391
+ public void setEnableRTL(boolean enableRTL){
392
+ this.enableRTL= enableRTL;
393
+
394
+ }
395
+
352
396
  public void setScale(float scale) {
353
397
  this.scale = scale;
354
398
  }
@@ -502,4 +546,4 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
502
546
  }
503
547
  }
504
548
  }
505
- }
549
+ }
package/index.d.ts CHANGED
@@ -65,8 +65,6 @@ export interface PdfProps {
65
65
  onPressLink?: (url: string) => void,
66
66
  }
67
67
 
68
- declare class Pdf extends React.Component<PdfProps, any> {
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
- recognizer.enabled = NO;
295
+ UITapGestureRecognizer *tap = (UITapGestureRecognizer *)recognizer;
296
+ if (tap.numberOfTapsRequired == 2) {
297
+ recognizer.enabled = NO;
298
+ }
296
299
  }
297
300
  }
298
301
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-pdf",
3
- "version": "6.7.7",
3
+ "version": "7.0.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",
@@ -62,7 +62,12 @@
62
62
  "type": "components",
63
63
  "jsSrcsDir": "./fabric",
64
64
  "android": {
65
- "javaPackageName": "org.wonday.pdf"
65
+ "javaPackageName": "org.wonday.pdf"
66
+ },
67
+ "ios": {
68
+ "componentProvider": {
69
+ "RNPDFPdfView": "RNPDFPdfView"
70
+ }
66
71
  }
67
- }
72
+ }
68
73
  }