react-native-pdf 6.7.7 → 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/README.md CHANGED
@@ -168,6 +168,13 @@ 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
+
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,9 +99,9 @@ public class PdfManager extends SimpleViewManager<PdfView> implements RNPDFPdfVi
99
99
  // NOOP on Android
100
100
  }
101
101
 
102
- @Override
103
- public void setShowsVerticalScrollIndicator(PdfView view, boolean value) {
104
- // NOOP on Android
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.defaultPage(this.page-1)
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>1?page:1;
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/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.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
- "javaPackageName": "org.wonday.pdf"
65
+ "javaPackageName": "org.wonday.pdf"
66
+ },
67
+ "ios": {
68
+ "componentProvider": {
69
+ "RNPDFPdfView": "RNPDFPdfView"
70
+ }
66
71
  }
67
- }
72
+ }
68
73
  }