react-native-pdf 7.0.3 → 7.0.4

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.
Files changed (26) hide show
  1. package/README.md +7 -0
  2. package/android/build/generated/source/buildConfig/debug/org/wonday/pdf/BuildConfig.java +12 -0
  3. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +7 -0
  4. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/output-metadata.json +18 -0
  5. package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +5 -0
  6. package/android/build/intermediates/aar_metadata/debug/writeDebugAarMetadata/aar-metadata.properties +6 -0
  7. package/android/build/intermediates/annotation_processor_list/debug/javaPreCompileDebug/annotationProcessors.json +1 -0
  8. package/android/build/intermediates/compile_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
  9. package/android/build/intermediates/compile_symbol_list/debug/generateDebugRFile/R.txt +0 -0
  10. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -0
  11. package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +2 -0
  12. package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +2 -0
  13. package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +2 -0
  14. package/android/build/intermediates/local_only_symbol_list/debug/parseDebugLocalResources/R-def.txt +2 -0
  15. package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +7 -0
  16. package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +7 -0
  17. package/android/build/intermediates/navigation_json/debug/extractDeepLinksDebug/navigation.json +1 -0
  18. package/android/build/intermediates/nested_resources_validation_report/debug/generateDebugResources/nestedResourcesValidationReport.txt +1 -0
  19. package/android/build/intermediates/symbol_list_with_package_name/debug/generateDebugRFile/package-aware-r.txt +1 -0
  20. package/android/build/outputs/logs/manifest-merger-debug-report.txt +16 -0
  21. package/android/src/main/java/org/wonday/pdf/PdfView.java +6 -0
  22. package/index.js +24 -0
  23. package/ios/RNPDFPdf/RNPDFPdfView.h +7 -0
  24. package/ios/RNPDFPdf/RNPDFPdfView.mm +41 -7
  25. package/ios/RNPDFPdf/RNPDFPdfViewManager.mm +2 -0
  26. package/package.json +1 -1
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
+
172
+ v7.0.4
173
+ 1. Fixed: Android PDF crash: IllegalStateException: Already closed (#989) (#999)
174
+ 2. Fixed: scrollTop on initial render on iOS (#1001)
175
+ 3. Feature(ios): add text selection support via PDFKit (#1003)
176
+
177
+
171
178
  v7.0.3
172
179
  1. Fixed: RefObject types, and setPage not working in android (#985)
173
180
 
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Automatically generated file. DO NOT MODIFY
3
+ */
4
+ package org.wonday.pdf;
5
+
6
+ public final class BuildConfig {
7
+ public static final boolean DEBUG = Boolean.parseBoolean("true");
8
+ public static final String LIBRARY_PACKAGE_NAME = "org.wonday.pdf";
9
+ public static final String BUILD_TYPE = "debug";
10
+ // Field from default config.
11
+ public static final boolean IS_NEW_ARCHITECTURE_ENABLED = false;
12
+ }
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+ package="org.wonday.pdf" >
4
+
5
+ <uses-sdk android:minSdkVersion="24" />
6
+
7
+ </manifest>
@@ -0,0 +1,18 @@
1
+ {
2
+ "version": 3,
3
+ "artifactType": {
4
+ "type": "AAPT_FRIENDLY_MERGED_MANIFESTS",
5
+ "kind": "Directory"
6
+ },
7
+ "applicationId": "org.wonday.pdf",
8
+ "variantName": "debug",
9
+ "elements": [
10
+ {
11
+ "type": "SINGLE",
12
+ "filters": [],
13
+ "attributes": [],
14
+ "outputFile": "AndroidManifest.xml"
15
+ }
16
+ ],
17
+ "elementType": "File"
18
+ }
@@ -0,0 +1,5 @@
1
+ aarFormatVersion=1.0
2
+ aarMetadataVersion=1.0
3
+ minCompileSdk=1
4
+ minCompileSdkExtension=0
5
+ minAndroidGradlePluginVersion=1.0.0
@@ -0,0 +1,6 @@
1
+ aarFormatVersion=1.0
2
+ aarMetadataVersion=1.0
3
+ minCompileSdk=1
4
+ minCompileSdkExtension=0
5
+ minAndroidGradlePluginVersion=1.0.0
6
+ coreLibraryDesugaringEnabled=false
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <merger version="3"><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\src\main\res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main" generated-set="main$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\src\main\res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\src\debug\res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug" generated-set="debug$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\src\debug\res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="generated$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\build\generated\res\resValues\debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="generated" generated-set="generated$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\build\generated\res\resValues\debug"/></dataSet><mergedItems/></merger>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\src\main\shaders"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\src\debug\shaders"/></dataSet></merger>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\src\main\assets"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\src\debug\assets"/></dataSet><dataSet config="generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\build\intermediates\shader_assets\debug\compileDebugShaders\out"/></dataSet></merger>
@@ -0,0 +1,2 @@
1
+ R_DEF: Internal format may change without notice
2
+ local
@@ -0,0 +1,7 @@
1
+ 1<?xml version="1.0" encoding="utf-8"?>
2
+ 2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+ 3 package="org.wonday.pdf" >
4
+ 4
5
+ 5 <uses-sdk android:minSdkVersion="24" />
6
+ 6
7
+ 7</manifest>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+ package="org.wonday.pdf" >
4
+
5
+ <uses-sdk android:minSdkVersion="24" />
6
+
7
+ </manifest>
@@ -0,0 +1,16 @@
1
+ -- Merging decision tree log ---
2
+ manifest
3
+ ADDED from W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\src\main\AndroidManifestNew.xml:1:1-4:12
4
+ INJECTED from W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\src\main\AndroidManifestNew.xml:1:1-4:12
5
+ package
6
+ INJECTED from W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\src\main\AndroidManifestNew.xml
7
+ xmlns:android
8
+ ADDED from W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\src\main\AndroidManifestNew.xml:1:11-69
9
+ uses-sdk
10
+ INJECTED from W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\src\main\AndroidManifestNew.xml reason: use-sdk injection requested
11
+ INJECTED from W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\src\main\AndroidManifestNew.xml
12
+ INJECTED from W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\src\main\AndroidManifestNew.xml
13
+ android:targetSdkVersion
14
+ INJECTED from W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\src\main\AndroidManifestNew.xml
15
+ android:minSdkVersion
16
+ INJECTED from W:\wonday\project\react-native-pdf\example\node_modules\react-native-pdf\android\src\main\AndroidManifestNew.xml
@@ -26,6 +26,11 @@ import android.view.MotionEvent;
26
26
  import android.graphics.Canvas;
27
27
  import android.graphics.pdf.PdfRenderer;
28
28
 
29
+ import io.legere.pdfiumandroid.util.Config;
30
+ import io.legere.pdfiumandroid.util.ConfigKt;
31
+ import io.legere.pdfiumandroid.util.AlreadyClosedBehavior;
32
+ import io.legere.pdfiumandroid.DefaultLogger;
33
+
29
34
  import com.facebook.react.uimanager.ThemedReactContext;
30
35
  import com.facebook.react.uimanager.UIManagerHelper;
31
36
  import com.github.barteksc.pdfviewer.PDFView;
@@ -91,6 +96,7 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
91
96
 
92
97
  public PdfView(Context context, AttributeSet set){
93
98
  super(context, set);
99
+ ConfigKt.setPdfiumConfig(new Config(new DefaultLogger(), AlreadyClosedBehavior.IGNORE));
94
100
  }
95
101
 
96
102
  @Override
package/index.js CHANGED
@@ -63,6 +63,8 @@ export default class Pdf extends Component {
63
63
  onPageSingleTap: PropTypes.func,
64
64
  onScaleChanged: PropTypes.func,
65
65
  onPressLink: PropTypes.func,
66
+ enableTextSelection: PropTypes.bool,
67
+ onTextSelectionChange: PropTypes.func,
66
68
 
67
69
  // Props that are not available in the earlier react native version, added to prevent crashed on android
68
70
  accessibilityLabel: PropTypes.string,
@@ -107,6 +109,9 @@ export default class Pdf extends Component {
107
109
  },
108
110
  onPressLink: (url) => {
109
111
  },
112
+ enableTextSelection: true,
113
+ onTextSelectionChange: (event) => {
114
+ },
110
115
  };
111
116
 
112
117
  constructor(props) {
@@ -364,10 +369,29 @@ export default class Pdf extends Component {
364
369
  }
365
370
 
366
371
  _onChange = (event) => {
372
+ // Handle direct events for text selection/highlight
373
+ if (event.nativeEvent.type) {
374
+ this.props.onTextSelectionChange && this.props.onTextSelectionChange(event);
375
+ return;
376
+ }
367
377
 
368
378
  let message = event.nativeEvent.message.split('|');
369
379
  //__DEV__ && console.log("onChange: " + message);
370
380
  if (message.length > 0) {
381
+
382
+ // Handle text selection messages
383
+ if (message[0] === 'textSelected') {
384
+ this.props.onTextSelectionChange && this.props.onTextSelectionChange({
385
+ nativeEvent: { type: 'selectionChanged', text: message.slice(1).join('|') }
386
+ });
387
+ return;
388
+ } else if (message[0] === 'textSelectionCleared') {
389
+ this.props.onTextSelectionChange && this.props.onTextSelectionChange({
390
+ nativeEvent: { type: 'selectionCleared' }
391
+ });
392
+ return;
393
+ }
394
+
371
395
  if (message.length > 5) {
372
396
  message[4] = message.splice(4).join('|');
373
397
  }
@@ -21,6 +21,8 @@
21
21
  #import <React/RCTViewComponentView.h>
22
22
  #endif
23
23
 
24
+ #import <PDFKit/PDFKit.h>
25
+
24
26
  @class RCTEventDispatcher;
25
27
 
26
28
  NS_CLASS_AVAILABLE_IOS(11_0) @interface RNPDFPdfView :
@@ -52,6 +54,11 @@ UIView
52
54
 
53
55
  @property(nonatomic, copy) RCTBubblingEventBlock onChange;
54
56
 
57
+ @property(nonatomic, strong) NSString *selectedText;
58
+ @property(nonatomic) BOOL enableTextSelection;
59
+ @property(nonatomic, strong) PDFSelection *currentPDFSelection;
60
+
61
+ @property(nonatomic, copy) RCTBubblingEventBlock onTextSelectionChange;
55
62
 
56
63
  @end
57
64
 
@@ -264,6 +264,9 @@ using namespace facebook::react;
264
264
  _showsHorizontalScrollIndicator = YES;
265
265
  _showsVerticalScrollIndicator = YES;
266
266
  _scrollEnabled = YES;
267
+ _enableTextSelection = YES;
268
+ _selectedText = nil;
269
+ _currentPDFSelection = nil;
267
270
 
268
271
  // init and config PDFView
269
272
  _pdfView = [[PDFView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
@@ -300,6 +303,12 @@ using namespace facebook::react;
300
303
  }
301
304
 
302
305
  [self bindTap];
306
+
307
+ // Register for selection change notifications
308
+ [[NSNotificationCenter defaultCenter] addObserver:self
309
+ selector:@selector(handleSelectionChanged:)
310
+ name:PDFViewSelectionChangedNotification
311
+ object:_pdfView];
303
312
  }
304
313
 
305
314
  - (void)PDFViewWillClickOnLink:(PDFView *)sender withURL:(NSURL *)url
@@ -311,6 +320,28 @@ using namespace facebook::react;
311
320
  @"linkPressed|%s", _url.UTF8String]]];
312
321
  }
313
322
 
323
+ - (void)handleSelectionChanged:(NSNotification *)notification
324
+ {
325
+ if (!_enableTextSelection || notification.object != _pdfView) return;
326
+
327
+ // Store a copy of the selection to avoid it being cleared
328
+ _currentPDFSelection = [_pdfView.currentSelection copy];
329
+
330
+ if (_currentPDFSelection && _currentPDFSelection.string.length > 0) {
331
+ _selectedText = _currentPDFSelection.string;
332
+
333
+ // Use the existing onChange callback with a message format
334
+ [self notifyOnChangeWithMessage:
335
+ [[NSString alloc] initWithString:
336
+ [NSString stringWithFormat:@"textSelected|%@", _selectedText]]];
337
+ } else {
338
+ _selectedText = nil;
339
+
340
+ // Use the existing onChange callback for clearing
341
+ [self notifyOnChangeWithMessage:@"textSelectionCleared"];
342
+ }
343
+ }
344
+
314
345
  - (void)didSetProps:(NSArray<NSString *> *)changedProps
315
346
  {
316
347
  if (!_initialed) {
@@ -508,13 +539,15 @@ using namespace facebook::react;
508
539
 
509
540
  PDFPage *pdfPage = [_pdfDocument pageAtIndex:_page-1];
510
541
  if (pdfPage && _page == 1) {
511
- // goToDestination() would be better. However, there is an
512
- // error in the pointLeftTop computation that often results in
513
- // scrolling to the middle of the page.
514
- // Special case workaround to make starting at the first page
515
- // align acceptably.
516
542
  dispatch_async(dispatch_get_main_queue(), ^{
517
- [self->_pdfView goToRect:CGRectMake(0, NSUIntegerMax, 1, 1) onPage:pdfPage];
543
+ [self->_pdfView goToFirstPage:nil];
544
+ for (UIView *subview in self->_pdfView.subviews) {
545
+ if ([subview isKindOfClass:[UIScrollView class]]) {
546
+ UIScrollView *scrollView = (UIScrollView *)subview;
547
+ [scrollView setContentOffset:CGPointMake(0, 0) animated:NO];
548
+ break;
549
+ }
550
+ }
518
551
  });
519
552
  } else if (pdfPage) {
520
553
  CGRect pdfPageRect = [pdfPage boundsForBox:kPDFDisplayBoxCropBox];
@@ -574,7 +607,8 @@ using namespace facebook::react;
574
607
  [[NSNotificationCenter defaultCenter] removeObserver:self name:@"PDFViewDocumentChangedNotification" object:nil];
575
608
  [[NSNotificationCenter defaultCenter] removeObserver:self name:@"PDFViewPageChangedNotification" object:nil];
576
609
  [[NSNotificationCenter defaultCenter] removeObserver:self name:@"PDFViewScaleChangedNotification" object:nil];
577
-
610
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:PDFViewSelectionChangedNotification object:nil];
611
+
578
612
  _doubleTapRecognizer = nil;
579
613
  _singleTapRecognizer = nil;
580
614
  _pinchRecognizer = nil;
@@ -45,6 +45,8 @@ RCT_EXPORT_VIEW_PROPERTY(spacing, int);
45
45
  RCT_EXPORT_VIEW_PROPERTY(password, NSString);
46
46
  RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock);
47
47
  RCT_EXPORT_VIEW_PROPERTY(singlePage, BOOL);
48
+ RCT_EXPORT_VIEW_PROPERTY(enableTextSelection, BOOL);
49
+ RCT_EXPORT_VIEW_PROPERTY(onTextSelectionChange, RCTBubblingEventBlock);
48
50
 
49
51
  RCT_EXPORT_METHOD(supportPDFKit:(RCTResponseSenderBlock)callback)
50
52
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-pdf",
3
- "version": "7.0.3",
3
+ "version": "7.0.4",
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",