@amafil/react-native-pdf-toolkit 1.1.17 → 1.1.18

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 (134) hide show
  1. package/README.md +57 -0
  2. package/android/.gradle/8.5/executionHistory/executionHistory.bin +0 -0
  3. package/android/.gradle/8.5/executionHistory/executionHistory.lock +0 -0
  4. package/android/.gradle/8.5/fileHashes/fileHashes.bin +0 -0
  5. package/android/.gradle/8.5/fileHashes/fileHashes.lock +0 -0
  6. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  7. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  8. package/android/.gradle/file-system.probe +0 -0
  9. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.dex +0 -0
  10. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.dex +0 -0
  11. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfManager.dex +0 -0
  12. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$1.dex +0 -0
  13. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$2.dex +0 -0
  14. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$3.dex +0 -0
  15. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$AnnotationOverlayView$1.dex +0 -0
  16. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$AnnotationOverlayView$AnnotationHit.dex +0 -0
  17. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$AnnotationOverlayView$AnnotationSelectionHit.dex +0 -0
  18. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$AnnotationOverlayView.dex +0 -0
  19. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$PageRenderInfo.dex +0 -0
  20. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView.dex +0 -0
  21. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
  22. package/android/build/.transforms/e40f3b884607647e8beb6dabe8165962/transformed/classes/classes_dex/classes.dex +0 -0
  23. package/android/build/generated/source/codegen/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.java +30 -0
  24. package/android/build/generated/source/codegen/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.java +10 -0
  25. package/android/build/generated/source/codegen/jni/react/renderer/components/rnpdf/Props.cpp +35 -0
  26. package/android/build/generated/source/codegen/jni/react/renderer/components/rnpdf/Props.h +7 -0
  27. package/android/build/generated/source/codegen/schema.json +1 -1
  28. package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
  29. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
  30. package/android/build/intermediates/incremental/mergeDebugAssets/merger.xml +1 -1
  31. package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +1 -1
  32. package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +1 -1
  33. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.class +0 -0
  34. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.class +0 -0
  35. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfManager.class +0 -0
  36. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$1.class +0 -0
  37. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$2.class +0 -0
  38. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$3.class +0 -0
  39. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$AnnotationOverlayView$1.class +0 -0
  40. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$AnnotationOverlayView$AnnotationHit.class +0 -0
  41. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$AnnotationOverlayView$AnnotationSelectionHit.class +0 -0
  42. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$AnnotationOverlayView.class +0 -0
  43. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$PageRenderInfo.class +0 -0
  44. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView.class +0 -0
  45. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.class +0 -0
  46. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.class +0 -0
  47. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfManager.class +0 -0
  48. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$1.class +0 -0
  49. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$2.class +0 -0
  50. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$3.class +0 -0
  51. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$AnnotationOverlayView$1.class +0 -0
  52. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$AnnotationOverlayView$AnnotationHit.class +0 -0
  53. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$AnnotationOverlayView$AnnotationSelectionHit.class +0 -0
  54. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$AnnotationOverlayView.class +0 -0
  55. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$PageRenderInfo.class +0 -0
  56. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView.class +0 -0
  57. package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
  58. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfManager.class.uniqueId7 +0 -0
  59. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/{PdfView$1.class.uniqueId0 → PdfView$1.class.uniqueId3} +0 -0
  60. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$2.class.uniqueId5 +0 -0
  61. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$AnnotationOverlayView$1.class.uniqueId6 +0 -0
  62. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$AnnotationOverlayView$AnnotationHit.class.uniqueId1 +0 -0
  63. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$AnnotationOverlayView$AnnotationSelectionHit.class.uniqueId9 +0 -0
  64. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$AnnotationOverlayView.class.uniqueId8 +0 -0
  65. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$PageRenderInfo.class.uniqueId0 +0 -0
  66. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView.class.uniqueId2 +0 -0
  67. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  68. package/android/src/main/java/org/wonday/pdf/PdfManager.java +56 -0
  69. package/android/src/main/java/org/wonday/pdf/PdfView.java +1249 -0
  70. package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.java +30 -0
  71. package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.java +10 -0
  72. package/annotationDocumentUtils.js +74 -0
  73. package/fabric/RNPDFPdfNativeComponent.js +18 -3
  74. package/index.d.ts +103 -1
  75. package/index.js +112 -0
  76. package/index.js.flow +73 -0
  77. package/ios/RNPDFPdf/RNPDFPdfView.h +11 -0
  78. package/ios/RNPDFPdf/RNPDFPdfView.mm +1414 -55
  79. package/ios/RNPDFPdf/RNPDFPdfViewManager.mm +37 -0
  80. package/package.json +6 -5
  81. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/results.bin +0 -1
  82. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.dex +0 -0
  83. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.dex +0 -0
  84. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/BuildConfig.dex +0 -0
  85. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfManager.dex +0 -0
  86. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$1.dex +0 -0
  87. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$2.dex +0 -0
  88. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$3.dex +0 -0
  89. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView.dex +0 -0
  90. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/RNPDFPackage.dex +0 -0
  91. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/events/TopChangeEvent.dex +0 -0
  92. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
  93. package/android/build/.transforms/787b9137f14dcc9eebbb21ac62a7be22/results.bin +0 -1
  94. package/android/build/.transforms/787b9137f14dcc9eebbb21ac62a7be22/transformed/classes/classes_dex/classes.dex +0 -0
  95. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/results.bin +0 -1
  96. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.dex +0 -0
  97. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.dex +0 -0
  98. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/BuildConfig.dex +0 -0
  99. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfManager.dex +0 -0
  100. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$1.dex +0 -0
  101. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$2.dex +0 -0
  102. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$3.dex +0 -0
  103. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView.dex +0 -0
  104. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/RNPDFPackage.dex +0 -0
  105. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/events/TopChangeEvent.dex +0 -0
  106. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
  107. package/android/build/.transforms/c29f40a753b0ae1d85db8c8c5812fc85/results.bin +0 -1
  108. package/android/build/.transforms/c29f40a753b0ae1d85db8c8c5812fc85/transformed/classes/classes_dex/classes.dex +0 -0
  109. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -7
  110. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +0 -18
  111. package/android/build/intermediates/aar_main_jar/debug/syncDebugLibJars/classes.jar +0 -0
  112. package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +0 -5
  113. package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
  114. package/android/build/intermediates/annotation_processor_list/debugAndroidTest/annotationProcessors.json +0 -1
  115. package/android/build/intermediates/annotation_processor_list/debugUnitTest/annotationProcessors.json +0 -1
  116. package/android/build/intermediates/annotations_typedef_file/debug/extractDebugAnnotations/typedefs.txt +0 -0
  117. package/android/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
  118. package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +0 -2
  119. package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +0 -8
  120. package/android/build/intermediates/merged_java_res/debug/mergeDebugJavaResource/feature-react-native-pdf.jar +0 -0
  121. package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +0 -7
  122. package/android/build/intermediates/navigation_json/debug/navigation.json +0 -1
  123. package/android/build/intermediates/packaged_manifests/debug/output-metadata.json +0 -18
  124. package/android/build/outputs/aar/react-native-pdf-debug.aar +0 -0
  125. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfManager.class.uniqueId3 +0 -0
  126. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfManager.class.uniqueId4 +0 -0
  127. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$2.class.uniqueId6 +0 -0
  128. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$3.class.uniqueId4 +0 -0
  129. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$3.class.uniqueId5 +0 -0
  130. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView.class.uniqueId3 +0 -0
  131. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNPDFPackage.class.uniqueId2 +0 -0
  132. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNPDFPdfViewManagerDelegate.class.uniqueId7 +0 -0
  133. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNPDFPdfViewManagerInterface.class.uniqueId1 +0 -0
  134. /package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/{RNPDFPackage.class.uniqueId1 → RNPDFPackage.class.uniqueId4} +0 -0
@@ -62,6 +62,27 @@ public class RNPDFPdfViewManagerDelegate<T extends View, U extends BaseViewManag
62
62
  case "enableDoubleTapZoom":
63
63
  mViewManager.setEnableDoubleTapZoom(view, value == null ? false : (boolean) value);
64
64
  break;
65
+ case "annotations":
66
+ mViewManager.setAnnotations(view, value == null ? null : (String) value);
67
+ break;
68
+ case "annotationMode":
69
+ mViewManager.setAnnotationMode(view, value == null ? false : (boolean) value);
70
+ break;
71
+ case "annotationTool":
72
+ mViewManager.setAnnotationTool(view, value == null ? null : (String) value);
73
+ break;
74
+ case "annotationEditable":
75
+ mViewManager.setAnnotationEditable(view, value == null ? false : (boolean) value);
76
+ break;
77
+ case "annotationIdMode":
78
+ mViewManager.setAnnotationIdMode(view, value == null ? null : (String) value);
79
+ break;
80
+ case "annotationInkColor":
81
+ mViewManager.setAnnotationInkColor(view, value == null ? null : (String) value);
82
+ break;
83
+ case "annotationInkThickness":
84
+ mViewManager.setAnnotationInkThickness(view, value == null ? 0f : ((Double) value).floatValue());
85
+ break;
65
86
  case "enableAntialiasing":
66
87
  mViewManager.setEnableAntialiasing(view, value == null ? false : (boolean) value);
67
88
  break;
@@ -87,6 +108,15 @@ public class RNPDFPdfViewManagerDelegate<T extends View, U extends BaseViewManag
87
108
  case "setNativePage":
88
109
  mViewManager.setNativePage(view, args.getInt(0));
89
110
  break;
111
+ case "saveAnnotations":
112
+ mViewManager.saveAnnotations(view);
113
+ break;
114
+ case "deleteSelectedAnnotation":
115
+ mViewManager.deleteSelectedAnnotation(view);
116
+ break;
117
+ case "deleteAllAnnotations":
118
+ mViewManager.deleteAllAnnotations(view);
119
+ break;
90
120
  }
91
121
  }
92
122
  }
@@ -26,10 +26,20 @@ public interface RNPDFPdfViewManagerInterface<T extends View> {
26
26
  void setEnableRTL(T view, boolean value);
27
27
  void setEnableAnnotationRendering(T view, boolean value);
28
28
  void setEnableDoubleTapZoom(T view, boolean value);
29
+ void setAnnotations(T view, @Nullable String value);
30
+ void setAnnotationMode(T view, boolean value);
31
+ void setAnnotationTool(T view, @Nullable String value);
32
+ void setAnnotationEditable(T view, boolean value);
33
+ void setAnnotationIdMode(T view, @Nullable String value);
34
+ void setAnnotationInkColor(T view, @Nullable String value);
35
+ void setAnnotationInkThickness(T view, float value);
29
36
  void setEnableAntialiasing(T view, boolean value);
30
37
  void setFitPolicy(T view, int value);
31
38
  void setSpacing(T view, int value);
32
39
  void setPassword(T view, @Nullable String value);
33
40
  void setSinglePage(T view, boolean value);
34
41
  void setNativePage(T view, int page);
42
+ void saveAnnotations(T view);
43
+ void deleteSelectedAnnotation(T view);
44
+ void deleteAllAnnotations(T view);
35
45
  }
@@ -0,0 +1,74 @@
1
+ 'use strict';
2
+
3
+ const LEGACY_MARKUP_TYPES = new Set(['underline', 'strikeout']);
4
+
5
+ export function normalizeAnnotation(annotation) {
6
+ if (!annotation || typeof annotation !== 'object' || Array.isArray(annotation)) {
7
+ return annotation;
8
+ }
9
+
10
+ if (!LEGACY_MARKUP_TYPES.has(annotation.type)) {
11
+ return annotation;
12
+ }
13
+
14
+ return {
15
+ ...annotation,
16
+ type: 'highlight',
17
+ };
18
+ }
19
+
20
+ export function normalizeAnnotationPayload(payload) {
21
+ if (!payload || typeof payload !== 'object') {
22
+ return payload;
23
+ }
24
+
25
+ if (Array.isArray(payload)) {
26
+ return payload.map(normalizeAnnotation);
27
+ }
28
+
29
+ if (!Array.isArray(payload.annotations)) {
30
+ return payload;
31
+ }
32
+
33
+ return {
34
+ ...payload,
35
+ annotations: payload.annotations.map(normalizeAnnotation),
36
+ };
37
+ }
38
+
39
+ export function joinAnnotationMessagePayload(messageParts, startIndex = 1) {
40
+ if (!Array.isArray(messageParts) || messageParts.length <= startIndex) {
41
+ return '';
42
+ }
43
+
44
+ return messageParts.slice(startIndex).join('|');
45
+ }
46
+
47
+ export function parseAnnotationMessagePayload(messageParts, startIndex = 1) {
48
+ const payload = joinAnnotationMessagePayload(messageParts, startIndex);
49
+
50
+ if (!payload) {
51
+ return null;
52
+ }
53
+
54
+ try {
55
+ return normalizeAnnotationPayload(JSON.parse(payload));
56
+ } catch (error) {
57
+ return payload;
58
+ }
59
+ }
60
+
61
+ export function stringifyAnnotationDocument(document, onError) {
62
+ if (!document) {
63
+ return null;
64
+ }
65
+
66
+ try {
67
+ return JSON.stringify(normalizeAnnotationPayload(document));
68
+ } catch (error) {
69
+ if (onError) {
70
+ onError(error);
71
+ }
72
+ return null;
73
+ }
74
+ }
@@ -4,8 +4,7 @@
4
4
  */
5
5
  'use strict';
6
6
 
7
- import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
8
- import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
7
+ import {codegenNativeComponent, codegenNativeCommands} from 'react-native';
9
8
 
10
9
  type ChangeEvent = $ReadOnly<{|
11
10
  message: ?string,
@@ -30,6 +29,13 @@
30
29
  fitPolicy: ?Int32,
31
30
  spacing: ?Int32,
32
31
  password: ?string,
32
+ annotations: ?string,
33
+ annotationMode: ?boolean,
34
+ annotationTool: ?string,
35
+ annotationEditable: ?boolean,
36
+ annotationIdMode: ?string,
37
+ annotationInkColor: ?string,
38
+ annotationInkThickness: ?Float,
33
39
  onChange: ?BubblingEventHandler<ChangeEvent>,
34
40
  singlePage: ?boolean,
35
41
  |}>;
@@ -47,10 +53,19 @@
47
53
  +stopNativeAutoScroll: (
48
54
  viewRef: React.ElementRef<ComponentType>,
49
55
  ) => void;
56
+ +saveAnnotations: (
57
+ viewRef: React.ElementRef<ComponentType>,
58
+ ) => void;
59
+ +deleteSelectedAnnotation: (
60
+ viewRef: React.ElementRef<ComponentType>,
61
+ ) => void;
62
+ +deleteAllAnnotations: (
63
+ viewRef: React.ElementRef<ComponentType>,
64
+ ) => void;
50
65
  }
51
66
 
52
67
  export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
53
- supportedCommands: ['setNativePage', 'startNativeAutoScroll', 'stopNativeAutoScroll'],
68
+ supportedCommands: ['setNativePage', 'startNativeAutoScroll', 'stopNativeAutoScroll', 'saveAnnotations', 'deleteSelectedAnnotation', 'deleteAllAnnotations'],
54
69
  });
55
70
 
56
71
  export default codegenNativeComponent<NativeProps>('RNPDFPdfView');
package/index.d.ts CHANGED
@@ -27,6 +27,68 @@ export type Source = {
27
27
  method?: string;
28
28
  };
29
29
 
30
+ export type AnnotationRotation = 0 | 90 | 180 | 270;
31
+ export type AnnotationIdMode = 'auto' | 'manual';
32
+ export type AnnotationTool = 'select' | 'ink' | 'text';
33
+ export type AnnotationTextAlign = 'left' | 'center' | 'right';
34
+
35
+ export type AnnotationPoint = {
36
+ x: number,
37
+ y: number,
38
+ pressure?: number,
39
+ };
40
+
41
+ export type AnnotationBounds = {
42
+ x: number,
43
+ y: number,
44
+ width: number,
45
+ height: number,
46
+ };
47
+
48
+ export type AnnotationStyle = {
49
+ color?: string,
50
+ thickness?: number,
51
+ fontFamily?: string,
52
+ fontSize?: number,
53
+ textAlign?: AnnotationTextAlign,
54
+ rotation?: AnnotationRotation,
55
+ };
56
+
57
+ export type AnnotationBase = {
58
+ id: string,
59
+ page: number,
60
+ locked?: boolean,
61
+ createdAt?: number,
62
+ updatedAt?: number,
63
+ };
64
+
65
+ export type InkAnnotation = AnnotationBase & {
66
+ type: 'ink',
67
+ points: AnnotationPoint[],
68
+ style?: AnnotationStyle,
69
+ };
70
+
71
+ export type TextAnnotation = AnnotationBase & {
72
+ type: 'text',
73
+ bounds: AnnotationBounds,
74
+ text: string,
75
+ style?: AnnotationStyle,
76
+ };
77
+
78
+ export type MarkupAnnotation = AnnotationBase & {
79
+ type: 'highlight',
80
+ bounds: AnnotationBounds,
81
+ style?: AnnotationStyle,
82
+ };
83
+
84
+ export type Annotation = InkAnnotation | TextAnnotation | MarkupAnnotation;
85
+
86
+ export type AnnotationDocument = {
87
+ editable?: boolean,
88
+ idMode?: AnnotationIdMode,
89
+ annotations: Annotation[],
90
+ };
91
+
30
92
  export type TextSelectionChangeEvent = {
31
93
  nativeEvent:
32
94
  | {
@@ -58,6 +120,34 @@ export interface PdfProps {
58
120
  enableRTL?: boolean,
59
121
  enableAnnotationRendering?: boolean,
60
122
  enableDoubleTapZoom?: boolean;
123
+ /**
124
+ * Initial annotation document to render in the overlay.
125
+ */
126
+ annotations?: AnnotationDocument,
127
+ /**
128
+ * Enable annotation editing mode.
129
+ */
130
+ annotationMode?: boolean,
131
+ /**
132
+ * Active tool used while annotation editing is enabled.
133
+ */
134
+ annotationTool?: AnnotationTool,
135
+ /**
136
+ * Allow in-place annotation edits.
137
+ */
138
+ annotationEditable?: boolean,
139
+ /**
140
+ * Controls how annotation IDs are generated and preserved.
141
+ */
142
+ annotationIdMode?: AnnotationIdMode,
143
+ /**
144
+ * Default color applied to newly created ink annotations.
145
+ */
146
+ annotationInkColor?: string,
147
+ /**
148
+ * Default thickness applied to newly created ink annotations.
149
+ */
150
+ annotationInkThickness?: number,
61
151
  /**
62
152
  * Only works on iOS. Defaults to `true`.
63
153
  */
@@ -79,12 +169,24 @@ export interface PdfProps {
79
169
  onScaleChanged?: (scale: number) => void,
80
170
  onPressLink?: (url: string) => void,
81
171
  onAutoScrollEnd?: () => void,
172
+ onAnnotationStrokeEnd?: () => void,
82
173
  onTextSelectionChange?: (event: TextSelectionChangeEvent) => void,
83
- onAutoScrollEnd?: () => void,
84
174
  }
85
175
 
86
176
  export interface PdfRef {
87
177
  setPage(pageNumber: number): void
178
+ /**
179
+ * Resolves with the current annotation document serialized by native code.
180
+ */
181
+ saveAnnotations(): Promise<AnnotationDocument>
182
+ /**
183
+ * Deletes the currently selected custom annotation.
184
+ */
185
+ deleteSelectedAnnotation(): void
186
+ /**
187
+ * Deletes all custom annotations in the current overlay draft.
188
+ */
189
+ deleteAllAnnotations(): void
88
190
  /**
89
191
  * Start smooth automatic vertical scrolling using the display refresh rate.
90
192
  * @param dpPerSecond - Scroll speed in density-independent pixels (dp) per second (default: 15). Produces consistent physical speed across screen densities.
package/index.js CHANGED
@@ -23,6 +23,11 @@ import PdfViewNativeComponent, {
23
23
  import ReactNativeBlobUtil from 'react-native-blob-util'
24
24
  import {ViewPropTypes} from 'deprecated-react-native-prop-types';
25
25
  const SHA1 = require('crypto-js/sha1');
26
+ import {
27
+ joinAnnotationMessagePayload,
28
+ parseAnnotationMessagePayload,
29
+ stringifyAnnotationDocument,
30
+ } from './annotationDocumentUtils';
26
31
  import PdfView from './PdfView';
27
32
 
28
33
  export default class Pdf extends Component {
@@ -57,6 +62,13 @@ export default class Pdf extends Component {
57
62
  fitPolicy: PropTypes.number,
58
63
  trustAllCerts: PropTypes.bool,
59
64
  singlePage: PropTypes.bool,
65
+ annotations: PropTypes.object,
66
+ annotationMode: PropTypes.bool,
67
+ annotationTool: PropTypes.oneOf(['select', 'ink', 'text', 'highlight']),
68
+ annotationEditable: PropTypes.bool,
69
+ annotationIdMode: PropTypes.oneOf(['auto', 'manual']),
70
+ annotationInkColor: PropTypes.string,
71
+ annotationInkThickness: PropTypes.number,
60
72
  onLoadComplete: PropTypes.func,
61
73
  onPageChanged: PropTypes.func,
62
74
  onError: PropTypes.func,
@@ -96,6 +108,13 @@ export default class Pdf extends Component {
96
108
  trustAllCerts: true,
97
109
  usePDFKit: true,
98
110
  singlePage: false,
111
+ annotations: null,
112
+ annotationMode: false,
113
+ annotationTool: 'select',
114
+ annotationEditable: true,
115
+ annotationIdMode: 'auto',
116
+ annotationInkColor: '#111111',
117
+ annotationInkThickness: 2,
99
118
  onLoadProgress: (percent) => {
100
119
  },
101
120
  onLoadComplete: (numberOfPages, path) => {
@@ -127,6 +146,7 @@ export default class Pdf extends Component {
127
146
  };
128
147
 
129
148
  this.lastRNBFTask = null;
149
+ this._annotationSavePromise = null;
130
150
 
131
151
  }
132
152
 
@@ -156,6 +176,10 @@ export default class Pdf extends Component {
156
176
  componentWillUnmount() {
157
177
  this._mounted = false;
158
178
  this.stopAutoScroll();
179
+ if (this._annotationSavePromise) {
180
+ this._annotationSavePromise.reject(new Error('Pdf unmounted before annotation save completed'));
181
+ this._annotationSavePromise = null;
182
+ }
159
183
  if (this.lastRNBFTask) {
160
184
  // this.lastRNBFTask.cancel(err => {
161
185
  // });
@@ -372,6 +396,70 @@ export default class Pdf extends Component {
372
396
 
373
397
  }
374
398
 
399
+ saveAnnotations() {
400
+ if (this._annotationSavePromise) {
401
+ return Promise.reject(new Error('An annotation save is already in progress'));
402
+ }
403
+
404
+ return new Promise((resolve, reject) => {
405
+ if (!this._root) {
406
+ reject(new Error('Pdf is not mounted'));
407
+ return;
408
+ }
409
+
410
+ this._annotationSavePromise = {resolve, reject};
411
+
412
+ if (!!global?.nativeFabricUIManager) {
413
+ if (PdfViewCommands.saveAnnotations) {
414
+ PdfViewCommands.saveAnnotations(this._root);
415
+ } else {
416
+ this._annotationSavePromise = null;
417
+ reject(new Error('Annotation save command is not available'));
418
+ }
419
+ } else {
420
+ const ReactNative = require('react-native');
421
+ try {
422
+ ReactNative.UIManager.dispatchViewManagerCommand(
423
+ ReactNative.findNodeHandle(this._root),
424
+ 'saveAnnotations',
425
+ [],
426
+ );
427
+ } catch (error) {
428
+ this._annotationSavePromise = null;
429
+ reject(error);
430
+ }
431
+ }
432
+ });
433
+ }
434
+
435
+ deleteSelectedAnnotation() {
436
+ this._dispatchAnnotationCommand('deleteSelectedAnnotation', PdfViewCommands.deleteSelectedAnnotation);
437
+ }
438
+
439
+ deleteAllAnnotations() {
440
+ this._dispatchAnnotationCommand('deleteAllAnnotations', PdfViewCommands.deleteAllAnnotations);
441
+ }
442
+
443
+ _dispatchAnnotationCommand(commandName, fabricCommand) {
444
+ if (!this._root) {
445
+ return;
446
+ }
447
+
448
+ if (!!global?.nativeFabricUIManager) {
449
+ if (fabricCommand) {
450
+ fabricCommand(this._root);
451
+ }
452
+ return;
453
+ }
454
+
455
+ const ReactNative = require('react-native');
456
+ ReactNative.UIManager.dispatchViewManagerCommand(
457
+ ReactNative.findNodeHandle(this._root),
458
+ commandName,
459
+ [],
460
+ );
461
+ }
462
+
375
463
  startAutoScroll( dpPerSecond = 15, resumeDelay = 3000 ) {
376
464
  this._isAutoScrollActive = true;
377
465
  if (!!global?.nativeFabricUIManager) {
@@ -465,6 +553,22 @@ export default class Pdf extends Component {
465
553
  } else if (message[0] === 'autoScrollEnd') {
466
554
  this._isAutoScrollActive = false;
467
555
  this.props.onAutoScrollEnd && this.props.onAutoScrollEnd();
556
+ } else if (message[0] === 'annotationSaveComplete') {
557
+ const annotationDocument = parseAnnotationMessagePayload(message);
558
+
559
+ if (this._annotationSavePromise) {
560
+ this._annotationSavePromise.resolve(annotationDocument);
561
+ this._annotationSavePromise = null;
562
+ }
563
+ } else if (message[0] === 'annotationSaveError') {
564
+ const annotationError = joinAnnotationMessagePayload(message);
565
+
566
+ if (this._annotationSavePromise) {
567
+ this._annotationSavePromise.reject(new Error(annotationError || 'Annotation save failed'));
568
+ this._annotationSavePromise = null;
569
+ }
570
+ } else if (message[0] === 'strokeEnd') {
571
+ this.props.onAnnotationStrokeEnd && this.props.onAnnotationStrokeEnd();
468
572
  }
469
573
  }
470
574
 
@@ -476,7 +580,13 @@ export default class Pdf extends Component {
476
580
 
477
581
  };
478
582
 
583
+ _getNativeAnnotations = () => {
584
+ return stringifyAnnotationDocument(this.props.annotations, this._onError);
585
+ };
586
+
479
587
  render() {
588
+ const nativeAnnotations = this._getNativeAnnotations();
589
+
480
590
  if (Platform.OS === "android" || Platform.OS === "ios" || Platform.OS === "windows") {
481
591
  return (
482
592
  <View style={[this.props.style,{overflow: 'hidden'}]}>
@@ -492,6 +602,7 @@ export default class Pdf extends Component {
492
602
  <PdfCustom
493
603
  ref={component => (this._root = component)}
494
604
  {...this.props}
605
+ annotations={nativeAnnotations}
495
606
  style={[{flex:1,backgroundColor: '#EEE'}, this.props.style]}
496
607
  path={this.state.path}
497
608
  onChange={this._onChange}
@@ -501,6 +612,7 @@ export default class Pdf extends Component {
501
612
  <PdfCustom
502
613
  ref={component => (this._root = component)}
503
614
  {...this.props}
615
+ annotations={nativeAnnotations}
504
616
  style={[{backgroundColor: '#EEE',overflow: 'hidden'}, this.props.style]}
505
617
  path={this.state.path}
506
618
  onChange={this._onChange}
package/index.js.flow CHANGED
@@ -24,6 +24,68 @@ export type Source = {
24
24
  uri: string
25
25
  };
26
26
 
27
+ export type AnnotationRotation = 0 | 90 | 180 | 270;
28
+ export type AnnotationIdMode = 'auto' | 'manual';
29
+ export type AnnotationTool = 'select' | 'ink' | 'text';
30
+ export type AnnotationTextAlign = 'left' | 'center' | 'right';
31
+
32
+ export type AnnotationPoint = {
33
+ x: number,
34
+ y: number,
35
+ pressure?: number,
36
+ };
37
+
38
+ export type AnnotationBounds = {
39
+ x: number,
40
+ y: number,
41
+ width: number,
42
+ height: number,
43
+ };
44
+
45
+ export type AnnotationStyle = {
46
+ color?: string,
47
+ thickness?: number,
48
+ fontFamily?: string,
49
+ fontSize?: number,
50
+ textAlign?: AnnotationTextAlign,
51
+ rotation?: AnnotationRotation,
52
+ };
53
+
54
+ export type AnnotationBase = {
55
+ id: string,
56
+ page: number,
57
+ locked?: boolean,
58
+ createdAt?: number,
59
+ updatedAt?: number,
60
+ };
61
+
62
+ export type InkAnnotation = AnnotationBase & {
63
+ type: 'ink',
64
+ points: Array<AnnotationPoint>,
65
+ style?: AnnotationStyle,
66
+ };
67
+
68
+ export type TextAnnotation = AnnotationBase & {
69
+ type: 'text',
70
+ bounds: AnnotationBounds,
71
+ text: string,
72
+ style?: AnnotationStyle,
73
+ };
74
+
75
+ export type MarkupAnnotation = AnnotationBase & {
76
+ type: 'highlight',
77
+ bounds: AnnotationBounds,
78
+ style?: AnnotationStyle,
79
+ };
80
+
81
+ export type Annotation = InkAnnotation | TextAnnotation | MarkupAnnotation;
82
+
83
+ export type AnnotationDocument = {
84
+ editable?: boolean,
85
+ idMode?: AnnotationIdMode,
86
+ annotations: Array<Annotation>,
87
+ };
88
+
27
89
  export type TableContent = {
28
90
  children: TableContent[],
29
91
  mNativePtr: number,
@@ -33,6 +95,13 @@ export type TableContent = {
33
95
 
34
96
  export type Props = {
35
97
  renderActivityIndicator?: (progress: number) => Node,
98
+ annotations?: AnnotationDocument,
99
+ annotationMode?: boolean,
100
+ annotationTool?: AnnotationTool,
101
+ annotationEditable?: boolean,
102
+ annotationIdMode?: AnnotationIdMode,
103
+ annotationInkColor?: string,
104
+ annotationInkThickness?: number,
36
105
  enableAnnotationRendering?: boolean,
37
106
  enableAntialiasing?: boolean,
38
107
  enablePaging?: boolean,
@@ -52,6 +121,7 @@ export type Props = {
52
121
  onPageSingleTap?: (page: number, x: number, y: number) => void,
53
122
  onScaleChanged?: (scale: number) => void,
54
123
  onPressLink?: (url: string) => void,
124
+ onAnnotationStrokeEnd?: () => void,
55
125
  page?: number,
56
126
  password?: string,
57
127
  progressContainerStyle?: ViewStyleProp,
@@ -64,4 +134,7 @@ export type Props = {
64
134
 
65
135
  declare export default class Pdf extends Component<Props> {
66
136
  setPage: (pageNumber: number) => void;
137
+ saveAnnotations: () => Promise<AnnotationDocument>;
138
+ deleteSelectedAnnotation: () => void;
139
+ deleteAllAnnotations: () => void;
67
140
  }
@@ -49,6 +49,13 @@ UIView
49
49
  @property(nonatomic) BOOL enableRTL;
50
50
  @property(nonatomic) BOOL enableAnnotationRendering;
51
51
  @property(nonatomic) BOOL enableDoubleTapZoom;
52
+ @property(nonatomic, strong) NSString *annotations;
53
+ @property(nonatomic) BOOL annotationMode;
54
+ @property(nonatomic, strong) NSString *annotationTool;
55
+ @property(nonatomic) BOOL annotationEditable;
56
+ @property(nonatomic, strong) NSString *annotationIdMode;
57
+ @property(nonatomic, strong) NSString *annotationInkColor;
58
+ @property(nonatomic) float annotationInkThickness;
52
59
  @property(nonatomic) int fitPolicy;
53
60
  @property(nonatomic) int spacing;
54
61
  @property(nonatomic, strong) NSString *password;
@@ -56,6 +63,10 @@ UIView
56
63
 
57
64
  @property(nonatomic, copy) RCTBubblingEventBlock onChange;
58
65
 
66
+ - (void)saveAnnotations;
67
+ - (void)deleteSelectedAnnotation;
68
+ - (void)deleteAllAnnotations;
69
+
59
70
  @property(nonatomic, strong) NSString *selectedText;
60
71
  @property(nonatomic) BOOL enableTextSelection;
61
72
  @property(nonatomic, strong) PDFSelection *currentPDFSelection;