Skip to content

Commit b222c2e

Browse files
committed
Add Android resolution limit to prevent crash on reder large bitmaps
1 parent f2e1a70 commit b222c2e

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ For more details, see the [Sample Project](https://github.com/douglasjunior/reac
7878
|source|`string`||Path to a file stored on the device.|
7979
|distanceBetweenPages|`number`|`16`|Distance in `DPI` between pages.|
8080
|maxZoom|`number`|`5`|Max zoom scale.|
81-
|maxPageResolution|`number`|`2048`|(Android only) Max page resolution (width/height) when zooming. Defined to prevent Android crash when zooming too much: https://github.com/douglasjunior/react-native-pdf-renderer/issues/26 . |
81+
|maxPageResolution|`number`|`2048`|(Android only) Max page resolution (width/height) in pixels when zooming. Defined to prevent Android crash when zooming too much: https://github.com/douglasjunior/react-native-pdf-renderer/issues/26 . |
8282
|singlePage|`boolean`|`false`|(Experimental) Renders only the first page without scroll. (useful for display thumbnail)|
8383
|onPageChange|`(current: number, total: number) => void`||Invoked on pages scroll.|
8484
|style|`StyleProp<ViewStyle>`||Styles to be applied to the native [view](https://reactnative.dev/docs/view-style-props).|

src/PdfRendererView.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ export type PdfRendererViewPropsType = {
5454
* Default: 5
5555
*/
5656
maxZoom?: number;
57+
/**
58+
* (Android only)
59+
*
60+
* Max page resolution (width/height) in pixels when zooming.
61+
*
62+
* Defined to prevent Android crash when zooming too much: https://github.com/douglasjunior/react-native-pdf-renderer/issues/26
63+
*
64+
* Default: 2048
65+
*/
66+
maxPageResolution?: number;
5767
/**
5868
* (Experimental)
5969
*
@@ -93,6 +103,7 @@ const PdfRendererView = ({
93103
singlePage = false,
94104
distanceBetweenPages = 16,
95105
maxZoom = 5,
106+
maxPageResolution = 2048,
96107
}: PdfRendererViewPropsType): JSX.Element => {
97108
const viewStyles = useMemo(
98109
() => [
@@ -125,6 +136,7 @@ const PdfRendererView = ({
125136
return (
126137
<PdfRendererNative
127138
testID={testID}
139+
maxPageResolution={maxPageResolution}
128140
distanceBetweenPages={distanceBetweenPages}
129141
style={viewStyles}
130142
params={params}

0 commit comments

Comments
 (0)