react-native-pdf-renderer 1.6.0 → 2.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.
Files changed (31) hide show
  1. package/README.md +4 -4
  2. package/ReactNativePdfRenderer.podspec +9 -2
  3. package/android/build.gradle +111 -66
  4. package/android/gradle/wrapper/gradle-wrapper.properties +3 -1
  5. package/android/src/main/java/com/github/douglasjunior/reactNativePdfRenderer/PdfRendererPackage.java +32 -9
  6. package/android/src/main/java/com/github/douglasjunior/reactNativePdfRenderer/PdfRendererViewManagerImpl.java +94 -0
  7. package/android/src/main/java/com/github/douglasjunior/reactNativePdfRenderer/modules/PdfRendererRecyclerView.java +26 -32
  8. package/android/src/newarch/com/github/douglasjunior/reactNativePdfRenderer/modules/PdfRendererViewManager.java +102 -0
  9. package/android/src/oldarch/com/github/douglasjunior/reactNativePdfRenderer/modules/PdfRendererViewManager.java +92 -0
  10. package/dist/PdfRendererView.d.ts +4 -4
  11. package/dist/PdfRendererView.js +3 -3
  12. package/dist/PdfRendererView.js.map +1 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/mock.js +17 -0
  15. package/dist/mock.js.map +1 -1
  16. package/dist/specs/RNPdfRendererViewNativeComponent.d.ts +19 -0
  17. package/dist/specs/RNPdfRendererViewNativeComponent.js +4 -0
  18. package/dist/specs/RNPdfRendererViewNativeComponent.js.map +1 -0
  19. package/ios/ReactNativePdfRenderer.xcodeproj/project.pbxproj +10 -4
  20. package/ios/ReactNativePdfRendererLibrary/RNPDFView.h +9 -3
  21. package/ios/ReactNativePdfRendererLibrary/{RNPDFView.m → RNPDFView.mm} +9 -10
  22. package/ios/ReactNativePdfRendererLibrary/RNPdfRendererComponentView.h +44 -0
  23. package/ios/ReactNativePdfRendererLibrary/RNPdfRendererComponentView.mm +134 -0
  24. package/ios/ReactNativePdfRendererLibrary/RNPdfRendererModule.h +7 -0
  25. package/ios/ReactNativePdfRendererLibrary/RNPdfRendererModule.m +13 -0
  26. package/package.json +36 -16
  27. package/src/PdfRendererView.tsx +147 -0
  28. package/src/index.ts +24 -0
  29. package/src/mock.tsx +32 -0
  30. package/src/specs/RNPdfRendererViewNativeComponent.ts +51 -0
  31. package/android/src/main/java/com/github/douglasjunior/reactNativePdfRenderer/modules/PdfRendererViewManager.java +0 -118
@@ -0,0 +1,92 @@
1
+ // MIT License
2
+
3
+ // Copyright (c) 2023 Douglas Nassif Roma Junior
4
+
5
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ // of this software and associated documentation files (the "Software"), to deal
7
+ // in the Software without restriction, including without limitation the rights
8
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ // copies of the Software, and to permit persons to whom the Software is
10
+ // furnished to do so, subject to the following conditions:
11
+
12
+ // The above copyright notice and this permission notice shall be included in all
13
+ // copies or substantial portions of the Software.
14
+
15
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ // SOFTWARE.
22
+
23
+ package com.github.douglasjunior.reactNativePdfRenderer.modules;
24
+
25
+ import static com.github.douglasjunior.reactNativePdfRenderer.PdfRendererViewManagerImpl.REACT_CLASS;
26
+
27
+ import androidx.annotation.NonNull;
28
+ import androidx.annotation.Nullable;
29
+
30
+ import com.facebook.react.bridge.ReactApplicationContext;
31
+ import com.facebook.react.bridge.ReadableMap;
32
+ import com.facebook.react.uimanager.SimpleViewManager;
33
+ import com.facebook.react.uimanager.ThemedReactContext;
34
+ import com.facebook.react.uimanager.UIManagerHelper;
35
+ import com.facebook.react.uimanager.UIManagerModule;
36
+ import com.facebook.react.uimanager.annotations.ReactProp;
37
+ import com.github.douglasjunior.reactNativePdfRenderer.PdfRendererViewManagerImpl;
38
+
39
+ import java.io.IOException;
40
+ import java.util.Map;
41
+
42
+ public class PdfRendererViewManager extends SimpleViewManager<PdfRendererRecyclerView> implements PdfRendererRecyclerView.PdfRendererRecyclerViewListener {
43
+ private final ReactApplicationContext mReactApplicationContext;
44
+
45
+ public PdfRendererViewManager(ReactApplicationContext reactApplicationContext) {
46
+ this.mReactApplicationContext = reactApplicationContext;
47
+ }
48
+
49
+ @NonNull
50
+ @Override
51
+ public String getName() {
52
+ return REACT_CLASS;
53
+ }
54
+
55
+ @NonNull
56
+ @Override
57
+ protected PdfRendererRecyclerView createViewInstance(@NonNull ThemedReactContext themedReactContext) {
58
+ return new PdfRendererRecyclerView(mReactApplicationContext, this);
59
+ }
60
+
61
+ @Nullable
62
+ @Override
63
+ public Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
64
+ return PdfRendererViewManagerImpl.getExportedCustomBubblingEventTypeConstants();
65
+ }
66
+
67
+ @ReactProp(name = "params")
68
+ public void setParams(PdfRendererRecyclerView view, @Nullable ReadableMap params) throws IOException {
69
+ PdfRendererViewManagerImpl.setParams(view, params);
70
+ }
71
+
72
+ @ReactProp(name = "distanceBetweenPages")
73
+ public void setDistanceBetweenPages(PdfRendererRecyclerView view, float distanceBetweenPages) {
74
+ view.setDistanceBetweenPages(distanceBetweenPages);
75
+ }
76
+
77
+ @ReactProp(name = "maxPageResolution")
78
+ public void setMaxPageResolution(PdfRendererRecyclerView view, float maxPageResolution) {
79
+ view.setMaxPageResolution(maxPageResolution);
80
+ }
81
+
82
+ @Override
83
+ public void onPageChange(PdfRendererRecyclerView target, int position, int total) {
84
+ UIManagerModule uiManager = mReactApplicationContext.getNativeModule(UIManagerModule.class);
85
+ if (uiManager != null) {
86
+ int surfaceId = UIManagerHelper.getSurfaceId(mReactApplicationContext);
87
+ uiManager.getEventDispatcher().dispatchEvent(
88
+ PdfRendererViewManagerImpl.createOnPageChangeEvent(surfaceId, target.getId(), position, total)
89
+ );
90
+ }
91
+ }
92
+ }
@@ -1,4 +1,5 @@
1
- import { ViewProps } from 'react-native';
1
+ import React from 'react';
2
+ import { StyleProp, ViewStyle } from 'react-native';
2
3
  export type PdfRendererViewPropsType = {
3
4
  testID?: string;
4
5
  /**
@@ -6,7 +7,7 @@ export type PdfRendererViewPropsType = {
6
7
  *
7
8
  * Note: Border radius is not supported.
8
9
  */
9
- style?: ViewProps['style'];
10
+ style?: StyleProp<ViewStyle>;
10
11
  /**
11
12
  * Path to a file stored on device.
12
13
  *
@@ -36,7 +37,6 @@ export type PdfRendererViewPropsType = {
36
37
  */
37
38
  maxPageResolution?: number;
38
39
  /**
39
- * (Experimental)
40
40
  *
41
41
  * Renders only the first page without scroll. (useful for display thumbnail).
42
42
  *
@@ -51,5 +51,5 @@ export type PdfRendererViewPropsType = {
51
51
  */
52
52
  onPageChange?: (page: number, totalPages: number) => void;
53
53
  };
54
- declare const PdfRendererView: ({ testID, onPageChange, style, source, singlePage, distanceBetweenPages, maxZoom, maxPageResolution, }: PdfRendererViewPropsType) => JSX.Element;
54
+ declare const PdfRendererView: ({ testID, onPageChange, style, source, singlePage, distanceBetweenPages, maxZoom, maxPageResolution, }: PdfRendererViewPropsType) => React.JSX.Element;
55
55
  export default PdfRendererView;
@@ -16,8 +16,8 @@
16
16
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17
17
  // SOFTWARE.
18
18
  import React, { useCallback, useMemo } from 'react';
19
- import { requireNativeComponent, StyleSheet, } from 'react-native';
20
- const PdfRendererNative = requireNativeComponent('RNPdfRendererView');
19
+ import { StyleSheet, } from 'react-native';
20
+ import PdfRendererNative from './specs/RNPdfRendererViewNativeComponent';
21
21
  const styles = StyleSheet.create({
22
22
  default: {
23
23
  backgroundColor: 'gray',
@@ -30,7 +30,7 @@ const PdfRendererView = ({ testID = undefined, onPageChange, style, source, sing
30
30
  style,
31
31
  {
32
32
  // See https://github.com/douglasjunior/react-native-pdf-renderer#limitations
33
- borderRadius: null,
33
+ borderRadius: undefined,
34
34
  },
35
35
  ], [style]);
36
36
  const handlePageChange = useCallback((event) => {
@@ -1 +1 @@
1
- {"version":3,"file":"PdfRendererView.js","sourceRoot":"","sources":["../src/PdfRendererView.tsx"],"names":[],"mappings":"AAAA,cAAc;AAEd,gDAAgD;AAEhD,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAE3D,iFAAiF;AACjF,kDAAkD;AAElD,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;AAEZ,OAAO,KAAK,EAAE,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAClD,OAAO,EAEL,sBAAsB,EACtB,UAAU,GAEX,MAAM,cAAc,CAAC;AA4DtB,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,mBAAmB,CAAQ,CAAC;AAE7E,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE;QACP,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,CAAC;KACR;CACF,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,CAAC,EACvB,MAAM,GAAG,SAAS,EAClB,YAAY,EACZ,KAAK,EACL,MAAM,EACN,UAAU,GAAG,KAAK,EAClB,oBAAoB,GAAG,EAAE,EACzB,OAAO,GAAG,CAAC,EACX,iBAAiB,GAAG,IAAI,GACC,EAAe,EAAE;IAC1C,MAAM,UAAU,GAAG,OAAO,CACxB,GAAG,EAAE,CAAC;QACJ,MAAM,CAAC,OAAO;QACd,KAAK;QACL;YACE,6EAA6E;YAC7E,YAAY,EAAE,IAAI;SACnB;KACF,EACD,CAAC,KAAK,CAAC,CACR,CAAC;IAEF,MAAM,gBAAgB,GAAG,WAAW,CAClC,CAAC,KAAkD,EAAE,EAAE;QACrD,YAAY,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACtE,CAAC,EACD,CAAC,YAAY,CAAC,CACf,CAAC;IAEF,MAAM,MAAM,GAAG,OAAO,CACpB,GAAG,EAAE,CAAC,CAAC;QACL,MAAM;QACN,UAAU;QACV,OAAO;KACR,CAAC,EACF,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAC9B,CAAC;IAEF,OAAO,CACL,oBAAC,iBAAiB,IAChB,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,iBAAiB,EACpC,oBAAoB,EAAE,oBAAoB,EAC1C,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,gBAAgB,GAC9B,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"PdfRendererView.js","sourceRoot":"","sources":["../src/PdfRendererView.tsx"],"names":[],"mappings":"AAAA,cAAc;AAEd,gDAAgD;AAEhD,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAE3D,iFAAiF;AACjF,kDAAkD;AAElD,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;AAEZ,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAGL,UAAU,GAEX,MAAM,cAAc,CAAC;AAEtB,OAAO,iBAAmC,MAAM,0CAA0C,CAAC;AA2D3F,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE;QACP,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,CAAC;KACR;CACF,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,CAAC,EACvB,MAAM,GAAG,SAAS,EAClB,YAAY,EACZ,KAAK,EACL,MAAM,EACN,UAAU,GAAG,KAAK,EAClB,oBAAoB,GAAG,EAAE,EACzB,OAAO,GAAG,CAAC,EACX,iBAAiB,GAAG,IAAI,GACC,EAAqB,EAAE;IAChD,MAAM,UAAU,GAAyB,OAAO,CAC9C,GAAG,EAAE,CAAC;QACJ,MAAM,CAAC,OAAO;QACd,KAAK;QACL;YACE,6EAA6E;YAC7E,YAAY,EAAE,SAAS;SACxB;KACF,EACD,CAAC,KAAK,CAAC,CACR,CAAC;IAEF,MAAM,gBAAgB,GAAG,WAAW,CAClC,CAAC,KAAkD,EAAE,EAAE;QACrD,YAAY,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACtE,CAAC,EACD,CAAC,YAAY,CAAC,CACf,CAAC;IAEF,MAAM,MAAM,GAAiB,OAAO,CAClC,GAAG,EAAE,CAAC,CAAC;QACL,MAAM;QACN,UAAU;QACV,OAAO;KACR,CAAC,EACF,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAC9B,CAAC;IAEF,OAAO,CACL,oBAAC,iBAAiB,IAChB,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,iBAAiB,EACpC,oBAAoB,EAAE,oBAAoB,EAC1C,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,gBAAgB,GAC9B,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AAEd,gDAAgD;AAEhD,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAE3D,iFAAiF;AACjF,kDAAkD;AAElD,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;AAEZ,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AAEd,gDAAgD;AAEhD,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAE3D,iFAAiF;AACjF,kDAAkD;AAElD,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;AAEZ,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/mock.js CHANGED
@@ -1,3 +1,20 @@
1
+ // MIT License
2
+ // Copyright (c) 2024 Douglas Nassif Roma Junior
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ // The above copyright notice and this permission notice shall be included in all
10
+ // copies or substantial portions of the Software.
11
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17
+ // SOFTWARE.
1
18
  import React from 'react';
2
19
  import { View } from 'react-native';
3
20
  const PdfRendererViewMock = (props) => {
package/dist/mock.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mock.js","sourceRoot":"","sources":["../src/mock.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAGlC,MAAM,mBAAmB,GAAG,CAAC,KAA+B,EAAE,EAAE;IAC9D,OAAO,oBAAC,IAAI,IAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAI,CAAC;AAC5D,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"mock.js","sourceRoot":"","sources":["../src/mock.tsx"],"names":[],"mappings":"AAAA,cAAc;AAEd,gDAAgD;AAEhD,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAE3D,iFAAiF;AACjF,kDAAkD;AAElD,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;AAEZ,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,MAAM,mBAAmB,GAAG,CAAC,KAA+B,EAAE,EAAE;IAC9D,OAAO,oBAAC,IAAI,IAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAI,CAAC;AAC5D,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { HostComponent, ViewProps } from 'react-native';
2
+ import { BubblingEventHandler, Float, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
3
+ export type NativeParams = {
4
+ source?: string;
5
+ singlePage: boolean;
6
+ maxZoom: Float;
7
+ };
8
+ type PageChangeEventPayload = {
9
+ position: Int32;
10
+ total: Int32;
11
+ };
12
+ export interface NativeProps extends ViewProps {
13
+ maxPageResolution: Float;
14
+ distanceBetweenPages: Float;
15
+ params: NativeParams;
16
+ onPageChange: BubblingEventHandler<PageChangeEventPayload>;
17
+ }
18
+ declare const _default: HostComponent<NativeProps>;
19
+ export default _default;
@@ -0,0 +1,4 @@
1
+ // MIT License
2
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
3
+ export default codegenNativeComponent('RNPdfRendererView');
4
+ //# sourceMappingURL=RNPdfRendererViewNativeComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RNPdfRendererViewNativeComponent.js","sourceRoot":"","sources":["../../src/specs/RNPdfRendererViewNativeComponent.ts"],"names":[],"mappings":"AAAA,cAAc;AA4Bd,OAAO,sBAAsB,MAAM,yDAAyD,CAAC;AAoB7F,eAAe,sBAAsB,CACnC,mBAAmB,CACU,CAAC"}
@@ -7,8 +7,9 @@
7
7
  objects = {
8
8
 
9
9
  /* Begin PBXBuildFile section */
10
- 241DF20429B9FD8B003ED990 /* RNPDFView.m in Sources */ = {isa = PBXBuildFile; fileRef = 241DF20129B9FD8B003ED990 /* RNPDFView.m */; };
10
+ 241DF20429B9FD8B003ED990 /* RNPDFView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 241DF20129B9FD8B003ED990 /* RNPDFView.mm */; };
11
11
  241DF20529B9FD8B003ED990 /* RNPdfRendererModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 241DF20329B9FD8B003ED990 /* RNPdfRendererModule.m */; };
12
+ 248B169F2E10C36D00F84136 /* RNPdfRendererComponentView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 248B169E2E10C36D00F84136 /* RNPdfRendererComponentView.mm */; };
12
13
  /* End PBXBuildFile section */
13
14
 
14
15
  /* Begin PBXCopyFilesBuildPhase section */
@@ -25,9 +26,11 @@
25
26
 
26
27
  /* Begin PBXFileReference section */
27
28
  241DF20029B9FD8A003ED990 /* RNPDFView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNPDFView.h; sourceTree = "<group>"; };
28
- 241DF20129B9FD8B003ED990 /* RNPDFView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNPDFView.m; sourceTree = "<group>"; };
29
+ 241DF20129B9FD8B003ED990 /* RNPDFView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RNPDFView.mm; sourceTree = "<group>"; };
29
30
  241DF20229B9FD8B003ED990 /* RNPdfRendererModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNPdfRendererModule.h; sourceTree = "<group>"; };
30
31
  241DF20329B9FD8B003ED990 /* RNPdfRendererModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNPdfRendererModule.m; sourceTree = "<group>"; };
32
+ 248B169D2E10C36D00F84136 /* RNPdfRendererComponentView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNPdfRendererComponentView.h; sourceTree = "<group>"; };
33
+ 248B169E2E10C36D00F84136 /* RNPdfRendererComponentView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RNPdfRendererComponentView.mm; sourceTree = "<group>"; };
31
34
  A5AF7CE21FAA17C900C5BDC0 /* libReactNativePdfRendererLibrary.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libReactNativePdfRendererLibrary.a; sourceTree = BUILT_PRODUCTS_DIR; };
32
35
  /* End PBXFileReference section */
33
36
 
@@ -57,10 +60,12 @@
57
60
  A5AF7CE31FAA17C900C5BDC0 /* ReactNativePdfRendererLibrary */ = {
58
61
  isa = PBXGroup;
59
62
  children = (
63
+ 248B169D2E10C36D00F84136 /* RNPdfRendererComponentView.h */,
64
+ 248B169E2E10C36D00F84136 /* RNPdfRendererComponentView.mm */,
60
65
  241DF20229B9FD8B003ED990 /* RNPdfRendererModule.h */,
61
66
  241DF20329B9FD8B003ED990 /* RNPdfRendererModule.m */,
62
67
  241DF20029B9FD8A003ED990 /* RNPDFView.h */,
63
- 241DF20129B9FD8B003ED990 /* RNPDFView.m */,
68
+ 241DF20129B9FD8B003ED990 /* RNPDFView.mm */,
64
69
  );
65
70
  path = ReactNativePdfRendererLibrary;
66
71
  sourceTree = "<group>";
@@ -138,8 +143,9 @@
138
143
  isa = PBXSourcesBuildPhase;
139
144
  buildActionMask = 2147483647;
140
145
  files = (
141
- 241DF20429B9FD8B003ED990 /* RNPDFView.m in Sources */,
146
+ 241DF20429B9FD8B003ED990 /* RNPDFView.mm in Sources */,
142
147
  241DF20529B9FD8B003ED990 /* RNPdfRendererModule.m in Sources */,
148
+ 248B169F2E10C36D00F84136 /* RNPdfRendererComponentView.mm in Sources */,
143
149
  );
144
150
  runOnlyForDeploymentPostprocessing = 0;
145
151
  };
@@ -23,15 +23,21 @@
23
23
  // Created by Douglas Nassif Roma Junior on 08/03/23.
24
24
  //
25
25
 
26
- @import Foundation;
27
- @import UIKit;
28
- @import PDFKit;
26
+ #import <Foundation/Foundation.h>
27
+ #import <UIKit/UIKit.h>
28
+ #import <PDFKit/PDFKit.h>
29
29
 
30
+ #ifdef RCT_NEW_ARCH_ENABLED
31
+ #else
30
32
  #import <React/RCTComponent.h>
33
+ #endif
31
34
 
32
35
  @interface RNPDFView: PDFView
33
36
 
37
+ #ifdef RCT_NEW_ARCH_ENABLED
38
+ #else
34
39
  @property (nonatomic, copy) RCTBubblingEventBlock onPageChange;
40
+ #endif
35
41
 
36
42
  -(void) setDistanceBetweenPages:(NSNumber*) distance;
37
43
  -(void) setParams:(NSDictionary*) params;
@@ -29,16 +29,13 @@
29
29
 
30
30
  -(void) setParams:(NSDictionary*) params {
31
31
  NSString *source = [params objectForKey:@"source"];
32
+ NSString *maxZoomString = [params objectForKey:@"maxZoom"];
33
+ NSString *singlePageString = [params objectForKey:@"singlePage"];
32
34
 
33
- float maxZoom = [params objectForKey:@"maxZoom"] != nil
34
- ? [[params objectForKey:@"maxZoom"] floatValue]
35
- : 0;
36
-
37
- BOOL singlePage = [params objectForKey:@"singlePage"] != nil
38
- ? [[params objectForKey:@"singlePage"] boolValue]
39
- : NO;
40
-
41
- if ([params objectForKey:@"source"] != nil) {
35
+ if (source != nil) {
36
+ float maxZoom = maxZoomString != nil ? [maxZoomString floatValue] : 0;
37
+ BOOL singlePage = singlePageString != nil ? [singlePageString boolValue] : NO;
38
+
42
39
  if (![source hasPrefix:@"file://"]) {
43
40
  source = [NSString stringWithFormat:@"%@%@", @"file://", source];
44
41
  }
@@ -54,7 +51,9 @@
54
51
  }
55
52
  self.displayMode = singlePage ? kPDFDisplaySinglePage : kPDFDisplaySinglePageContinuous;
56
53
 
57
- self.document = pdfDocument;
54
+ dispatch_async(dispatch_get_main_queue(), ^{
55
+ self.document = pdfDocument;
56
+ });
58
57
 
59
58
  dispatch_async(dispatch_get_main_queue(), ^{
60
59
  self.minScaleFactor = self.scaleFactorForSizeToFit;
@@ -0,0 +1,44 @@
1
+ // MIT License
2
+ //
3
+ // Copyright (c) 2025 Douglas Nassif Roma Junior
4
+ //
5
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ // of this software and associated documentation files (the "Software"), to deal
7
+ // in the Software without restriction, including without limitation the rights
8
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ // copies of the Software, and to permit persons to whom the Software is
10
+ // furnished to do so, subject to the following conditions:
11
+ //
12
+ // The above copyright notice and this permission notice shall be included in all
13
+ // copies or substantial portions of the Software.
14
+ //
15
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ // SOFTWARE.
22
+ //
23
+ // Created by Douglas Nassif Roma Junior on 08/03/23.
24
+ //
25
+
26
+ #ifdef RCT_NEW_ARCH_ENABLED
27
+
28
+
29
+ #import <UIKit/UIKit.h>
30
+ #import <PDFKit/PDFKit.h>
31
+ #import <React/RCTViewComponentView.h>
32
+
33
+ #import "RNPDFView.h"
34
+
35
+ NS_ASSUME_NONNULL_BEGIN
36
+
37
+ @interface RNPdfRendererComponentView : RCTViewComponentView
38
+
39
+ @end
40
+
41
+ NS_ASSUME_NONNULL_END
42
+
43
+ #endif // RCT_NEW_ARCH_ENABLED
44
+
@@ -0,0 +1,134 @@
1
+ // MIT License
2
+ //
3
+ // Copyright (c) 2025 Douglas Nassif Roma Junior
4
+ //
5
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ // of this software and associated documentation files (the "Software"), to deal
7
+ // in the Software without restriction, including without limitation the rights
8
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ // copies of the Software, and to permit persons to whom the Software is
10
+ // furnished to do so, subject to the following conditions:
11
+ //
12
+ // The above copyright notice and this permission notice shall be included in all
13
+ // copies or substantial portions of the Software.
14
+ //
15
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ // SOFTWARE.
22
+ //
23
+ // Created by Douglas Nassif Roma Junior on 08/03/23.
24
+ //
25
+
26
+ #ifdef RCT_NEW_ARCH_ENABLED
27
+
28
+ #import "RNPdfRendererComponentView.h"
29
+
30
+ #import <react/renderer/components/rnpdfrenderer_codegen/ComponentDescriptors.h>
31
+ #import <react/renderer/components/rnpdfrenderer_codegen/EventEmitters.h>
32
+ #import <react/renderer/components/rnpdfrenderer_codegen/Props.h>
33
+ #import <react/renderer/components/rnpdfrenderer_codegen/RCTComponentViewHelpers.h>
34
+
35
+ using namespace facebook::react;
36
+
37
+ @interface RNPdfRendererComponentView () <RCTRNPdfRendererViewViewProtocol>
38
+ @end
39
+
40
+ @implementation RNPdfRendererComponentView {
41
+ RNPDFView * _pdfView;
42
+ }
43
+
44
+ BOOL observerAdded = NO;
45
+
46
+ -(instancetype)init
47
+ {
48
+ if (!observerAdded) {
49
+ observerAdded = YES;
50
+ [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(handlePageChange:) name:PDFViewPageChangedNotification object:nil];
51
+ }
52
+ if(self = [super init]) {
53
+ _pdfView = [RNPDFView new];
54
+ _pdfView.backgroundColor = UIColor.clearColor;
55
+ [self addSubview:_pdfView];
56
+ }
57
+ return self;
58
+ }
59
+
60
+ - (void)dealloc
61
+ {
62
+ if (observerAdded) {
63
+ observerAdded = NO;
64
+ [NSNotificationCenter.defaultCenter removeObserver:self name:PDFViewPageChangedNotification object:nil];
65
+ }
66
+ }
67
+
68
+ - (void)handlePageChange:(NSNotification*) notification {
69
+ if ([RNPDFView class] != [notification.object class]) {
70
+ return;
71
+ }
72
+
73
+ RNPDFView *view = notification.object;
74
+
75
+ NSUInteger currentPageNumber = [view.document indexForPage:view.currentPage];
76
+
77
+ RNPdfRendererViewEventEmitter::OnPageChange result = RNPdfRendererViewEventEmitter::OnPageChange{};
78
+ result.position = currentPageNumber;
79
+ result.total = view.document.pageCount;
80
+
81
+ if (_eventEmitter) {
82
+ self.eventEmitter.onPageChange(result);
83
+ }
84
+ }
85
+
86
+ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
87
+ {
88
+ const auto &oldViewProps = *std::static_pointer_cast<RNPdfRendererViewProps const>(_props);
89
+ const auto &newViewProps = *std::static_pointer_cast<RNPdfRendererViewProps const>(props);
90
+
91
+ if (oldViewProps.params.source != newViewProps.params.source ||
92
+ oldViewProps.params.maxZoom != newViewProps.params.maxZoom ||
93
+ oldViewProps.params.singlePage != newViewProps.params.singlePage) {
94
+
95
+ NSString *sourceString = [NSString stringWithUTF8String:newViewProps.params.source.c_str()];
96
+
97
+ NSDictionary* params = @{
98
+ @"source": sourceString,
99
+ @"maxZoom": @(newViewProps.params.maxZoom),
100
+ @"singlePage": @(newViewProps.params.singlePage)
101
+ };
102
+
103
+ [_pdfView setParams: params];
104
+
105
+ [self setNeedsLayout];
106
+ }
107
+
108
+ if (oldViewProps.distanceBetweenPages != newViewProps.distanceBetweenPages) {
109
+ [_pdfView setDistanceBetweenPages: @(newViewProps.distanceBetweenPages)];
110
+ }
111
+
112
+ [super updateProps:props oldProps:oldProps];
113
+ }
114
+
115
+ -(void)layoutSubviews
116
+ {
117
+ [super layoutSubviews];
118
+ _pdfView.frame = self.bounds;
119
+ }
120
+
121
+ // Event emitter convenience method
122
+ - (const RNPdfRendererViewEventEmitter &)eventEmitter
123
+ {
124
+ return static_cast<const RNPdfRendererViewEventEmitter &>(*_eventEmitter);
125
+ }
126
+
127
+ + (ComponentDescriptorProvider)componentDescriptorProvider
128
+ {
129
+ return concreteComponentDescriptorProvider<RNPdfRendererViewComponentDescriptor>();
130
+ }
131
+
132
+ @end
133
+
134
+ #endif // RCT_NEW_ARCH_ENABLED
@@ -23,12 +23,19 @@
23
23
  // Created by Douglas Nassif Roma Junior on 08/03/23.
24
24
  //
25
25
 
26
+ #ifdef RCT_NEW_ARCH_ENABLED
27
+ #else
28
+
26
29
  @import Foundation;
27
30
  @import UIKit;
28
31
  @import PDFKit;
29
32
 
30
33
  #import <React/RCTViewManager.h>
34
+ #import <PDFKit/PDFKit.h>
35
+
31
36
  #import "RNPDFView.h"
32
37
 
33
38
  @interface RNPdfRendererModule : RCTViewManager
34
39
  @end
40
+
41
+ #endif // RCT_NEW_ARCH_ENABLED
@@ -23,6 +23,9 @@
23
23
  // Created by Douglas Nassif Roma Junior on 08/03/23.
24
24
  //
25
25
 
26
+ #ifdef RCT_NEW_ARCH_ENABLED
27
+ #else
28
+
26
29
  #import "RNPdfRendererModule.h"
27
30
 
28
31
  @implementation RNPdfRendererModule
@@ -43,6 +46,14 @@ BOOL observerAdded = NO;
43
46
  return view;
44
47
  }
45
48
 
49
+ - (void)dealloc
50
+ {
51
+ if (observerAdded) {
52
+ observerAdded = NO;
53
+ [NSNotificationCenter.defaultCenter removeObserver:self name:PDFViewPageChangedNotification object:nil];
54
+ }
55
+ }
56
+
46
57
  - (void)handlePageChange:(NSNotification*) notification {
47
58
  if ([RNPDFView class] != [notification.object class]) {
48
59
  return;
@@ -73,3 +84,5 @@ RCT_CUSTOM_VIEW_PROPERTY(distanceBetweenPages, NSNumber, RNPDFView)
73
84
  }
74
85
 
75
86
  @end
87
+
88
+ #endif // RCT_NEW_ARCH_ENABLED
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "react-native-pdf-renderer",
3
3
  "displayName": "React-Native Pdf Renderer",
4
- "version": "1.6.0",
4
+ "version": "2.0.1",
5
5
  "description": "⚛ A zoomable, blazing fast, zero dependencies, pure native, typed PDF Renderer for Android and iOS.",
6
6
  "main": "dist",
7
+ "react-native": "src",
7
8
  "license": "MIT",
8
9
  "repository": {
9
10
  "type": "git",
@@ -26,31 +27,50 @@
26
27
  "url": "https://github.com/douglasjunior/react-native-pdf-renderer/issues"
27
28
  },
28
29
  "homepage": "https://github.com/douglasjunior/react-native-pdf-renderer",
30
+ "codegenConfig": {
31
+ "name": "rnpdfrenderer_codegen",
32
+ "type": "components",
33
+ "jsSrcsDir": "./src/specs",
34
+ "android": {
35
+ "javaPackageName": "com.github.douglasjunior.reactNativePdfRenderer"
36
+ },
37
+ "ios": {
38
+ "componentProvider": {
39
+ "RNPdfRendererView": "RNPdfRendererComponentView"
40
+ }
41
+ }
42
+ },
29
43
  "scripts": {
30
44
  "build": "tsc",
31
45
  "publish-script": "node scripts/publish.js"
32
46
  },
33
47
  "peerDependencies": {
34
- "react-native": ">=0.60"
48
+ "react-native": ">=0.71"
35
49
  },
36
50
  "devDependencies": {
37
- "react": "18.2.0",
38
- "react-native": "0.74.1",
39
- "@babel/core": "^7.20.0",
40
- "@babel/preset-env": "^7.20.0",
41
- "@babel/runtime": "^7.20.0",
42
- "@react-native/babel-preset": "0.74.83",
43
- "@react-native/eslint-config": "0.74.83",
44
- "@react-native/metro-config": "0.74.83",
45
- "@react-native/typescript-config": "0.74.83",
46
- "@types/react": "^18.2.6",
47
- "@types/react-test-renderer": "^18.0.0",
48
- "babel-jest": "^29.6.3",
51
+ "react": "19.0.0",
52
+ "react-native": "0.79.4",
53
+ "@babel/core": "^7.25.2",
54
+ "@babel/preset-env": "^7.25.3",
55
+ "@babel/runtime": "^7.25.0",
56
+ "@react-native-community/cli": "18.0.0",
57
+ "@react-native-community/cli-platform-android": "18.0.0",
58
+ "@react-native-community/cli-platform-ios": "18.0.0",
59
+ "@react-native/babel-preset": "0.79.4",
60
+ "@react-native/eslint-config": "0.79.4",
61
+ "@react-native/metro-config": "0.79.4",
62
+ "@react-native/typescript-config": "0.79.4",
63
+ "@types/jest": "^29.5.13",
64
+ "@types/react": "^19.0.0",
65
+ "@types/react-test-renderer": "^19.0.0",
49
66
  "eslint": "^8.19.0",
50
67
  "jest": "^29.6.3",
51
68
  "prettier": "2.8.8",
52
- "react-test-renderer": "18.2.0",
53
- "typescript": "5.0.4"
69
+ "react-test-renderer": "19.0.0",
70
+ "typescript": "~5.8.3"
71
+ },
72
+ "engines": {
73
+ "node": ">=18"
54
74
  },
55
75
  "types": "dist"
56
76
  }