@kishannareshpal/expo-pdf 0.2.2 → 0.2.3

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/CHANGELOG.md CHANGED
@@ -13,18 +13,26 @@
13
13
  _This version does not introduce any user-facing changes._
14
14
  -->
15
15
 
16
+ ## 0.2.3 - 2026-01-11
17
+
18
+ _This version does not introduce any user-facing changes._
19
+
20
+ ### 💡 Others
21
+
22
+ - Expose `react-native` `ViewProps` as part of `PdfViewProps`. This change also allows for better compatibility with other libraries such as `uniwind` or `nativewind` that supports `className` ([db7e666](https://github.com/kishannareshpal/expo-pdf/commit/db7e666) by [@kishannareshpal](https://github.com/kishannareshpal))
23
+ - Fix TS docs as well as README prop descriptions ([db7e666](https://github.com/kishannareshpal/expo-pdf/commit/db7e666) by [@kishannareshpal](https://github.com/kishannareshpal))
24
+
16
25
  ## 0.2.2 - 2026-01-11
17
26
 
18
27
  _This version does not introduce any user-facing changes._
19
28
 
20
29
  ### 💡 Others
21
30
 
22
- - Export `PdfViewProps`, the props for the main `PdfView` component ([f9be18c](https://github.com/kishannareshpal/expo-pdf/commit/8d5c963) by [@kishannareshpal](https://github.com/kishannareshpal))
31
+ - Export `PdfViewProps`, the props for the main `PdfView` component ([8d5c963](https://github.com/kishannareshpal/expo-pdf/commit/8d5c963) by [@kishannareshpal](https://github.com/kishannareshpal))
23
32
 
24
33
  ### 🐛 Bug fixes
25
34
 
26
- - Fix exported `ErrorCode` literal type to match updated error codes from the native ([f9be18c](https://github.com/kishannareshpal/expo-pdf/commit/3a34f39) by [@kishannareshpal](https://github.com/kishannareshpal))
27
-
35
+ - Fix exported `ErrorCode` literal type to match updated error codes from the native ([3a34f39](https://github.com/kishannareshpal/expo-pdf/commit/3a34f39) by [@kishannareshpal](https://github.com/kishannareshpal))
28
36
 
29
37
  ## 0.2.1 - 2026-01-09
30
38
 
package/README.md CHANGED
@@ -174,104 +174,101 @@ export const App = () => {
174
174
  ## API
175
175
 
176
176
  <table>
177
- <thead>
178
- <tr>
179
- <th>Props</th>
180
- <th>Required</th>
181
- <th>Type</th>
182
- <th>Description</th>
183
- <th>Default</th>
184
- </tr>
185
- </thead>
186
- <tbody>
187
- <tr>
188
- <td><code>uri</code></td>
189
- <td>Required</td>
190
- <td><code>string</code></td>
191
- <td>PDF document URL or local file path.</td>
192
- <td>-</td>
193
- </tr>
194
- <tr>
195
- <td><code>password</code></td>
196
- <td>No</td>
197
- <td><code>string</code></td>
198
- <td>PDF document URL or local file path.</td>
199
- <td><code>undefined</code></td>
200
- </tr>
201
- <tr>
202
- <td><code>pagingEnabled</code></td>
203
- <td>No</td>
204
- <td><code>boolean</code></td>
205
- <td>PDF document URL or local file path.</td>
206
- <td><code>false</code></td>
207
- </tr>
208
- <tr>
209
- <td><code>doubleTapToZoom</code></td>
210
- <td>No</td>
211
- <td><code>boolean</code></td>
212
- <td>PDF document URL or local file path.</td>
213
- <td><code>true</code></td>
214
- </tr>
215
- <tr>
216
- <td><code>horizontal</code></td>
217
- <td>No</td>
218
- <td><code>boolean</code></td>
219
- <td>PDF document URL or local file path.</td>
220
- <td><code>false</code></td>
221
- </tr>
222
- <tr>
223
- <td><code>pageGap</code></td>
224
- <td>No</td>
225
- <td><code>number</code></td>
226
- <td>PDF document URL or local file path.</td>
227
- <td><code>0</code></td>
228
- </tr>
229
- <tr>
230
- <td><code>contentPadding</code></td>
231
- <td>No</td>
232
- <td><a href="#contentpadding"><code>ContentPadding</code></a></td>
233
- <td>PDF document URL or local file path.</td>
234
- <td><code>{ top: 0, left: 0, right: 0, bottom: 0 }</code></td>
235
- </tr>
236
- <tr>
237
- <td><code>fitMode</code></td>
238
- <td>No</td>
239
- <td><a href="#fitmode"><code>FitMode</code></a></td>
240
- <td>PDF document URL or local file path.</td>
241
- <td><code>"width"</code></td>
242
- </tr>
243
- <tr>
244
- <td><code>autoScale</code></td>
245
- <td>No</td>
246
- <td><code>boolean</code></td>
247
- <td>
248
- Whether the document should auto-scale when itself or its parent view changes its layout metrics.
249
- Please note that the initial render will always auto-scale to fit whatever <code>fitMode</code> is set to.
250
- This prop only affects subsequent layout changes.</td>
251
- <td><code>true</code></td>
252
- </tr>
253
- <tr>
254
- <td><code>onLoadComplete</code></td>
255
- <td>No</td>
256
- <td><a href="#onloadcompleteeventpayload"><code>(OnLoadCompleteEventPayload) =&gt; void</code></a></td>
257
- <td>Triggered once the document has been fully loaded.</td>
258
- <td>-</td>
259
- </tr>
260
- <tr>
261
- <td><code>onPageChanged</code></td>
262
- <td>No</td>
263
- <td><a href="#onpagechangedeventpayload"><code>(OnPageChangedPayload) =&gt; void</code></a></td>
264
- <td>Triggered when the user navigates to a different page.</td>
265
- <td>-</td>
266
- </tr>
267
- <tr>
268
- <td><code>onError</code></td>
269
- <td>No</td>
270
- <td><a href="#onerroreventpayload"><code>(OnErrorPayload) =&gt; void</code></a></td>
271
- <td>Triggered when the PDF fails to load or render.</td>
272
- <td>-</td>
273
- </tr>
274
- </tbody>
177
+ <thead>
178
+ <tr>
179
+ <th>Props</th>
180
+ <th>Required</th>
181
+ <th>Type</th>
182
+ <th>Description</th>
183
+ <th>Default</th>
184
+ </tr>
185
+ </thead>
186
+ <tbody>
187
+ <tr>
188
+ <td><code>uri</code></td>
189
+ <td>Required</td>
190
+ <td><code>string</code></td>
191
+ <td>PDF document URL or local file path.</td>
192
+ <td>-</td>
193
+ </tr>
194
+ <tr>
195
+ <td><code>password</code></td>
196
+ <td>No</td>
197
+ <td><code>string</code></td>
198
+ <td>Password to apply for password-protected PDFs by on load.</td>
199
+ <td><code>undefined</code></td>
200
+ </tr>
201
+ <tr>
202
+ <td><code>pagingEnabled</code></td>
203
+ <td>No</td>
204
+ <td><code>boolean</code></td>
205
+ <td>Enables page-by-page snapping instead of free scrolling.</td>
206
+ <td><code>false</code></td>
207
+ </tr>
208
+ <tr>
209
+ <td><code>doubleTapToZoom</code></td>
210
+ <td>No</td>
211
+ <td><code>boolean</code></td>
212
+ <td>Allows the user to zoom in/out by double-tapping the document.</td>
213
+ <td><code>true</code></td>
214
+ </tr>
215
+ <tr>
216
+ <td><code>horizontal</code></td>
217
+ <td>No</td>
218
+ <td><code>boolean</code></td>
219
+ <td>Renders and scrolls pages horizontally instead of vertically. If paging is enabled, then it changes horizontally.</td>
220
+ <td><code>false</code></td>
221
+ </tr>
222
+ <tr>
223
+ <td><code>pageGap</code></td>
224
+ <td>No</td>
225
+ <td><code>number</code></td>
226
+ <td>Space (in points/pixels) between adjacent pages.</td>
227
+ <td><code>0</code></td>
228
+ </tr>
229
+ <tr>
230
+ <td><code>contentPadding</code></td>
231
+ <td>No</td>
232
+ <td><a href="#contentpadding"><code>ContentPadding</code></a></td>
233
+ <td>Padding applied around the document inside the viewer container.</td>
234
+ <td><code>{ top: 0, left: 0, right: 0, bottom: 0 }</code></td>
235
+ </tr>
236
+ <tr>
237
+ <td><code>fitMode</code></td>
238
+ <td>No</td>
239
+ <td><a href="#fitmode"><code>FitMode</code></a></td>
240
+ <td>How the document is scaled to fit within the viewer (e.g., width or height).</td>
241
+ <td><code>"width"</code></td>
242
+ </tr>
243
+ <tr>
244
+ <td><code>autoScale</code></td>
245
+ <td>No</td>
246
+ <td><code>boolean</code></td>
247
+ <td>Automatically rescales the document when its or its parent’s layout changes after initial render.</td>
248
+ <td><code>true</code></td>
249
+ </tr>
250
+ <tr>
251
+ <td><code>onLoadComplete</code></td>
252
+ <td>No</td>
253
+ <td><a href="#onloadcompleteeventpayload"><code>(OnLoadCompleteEventPayload) =&gt; void</code></a></td>
254
+ <td>Triggered once the document and its metadata have finished loading.</td>
255
+ <td>-</td>
256
+ </tr>
257
+ <tr>
258
+ <td><code>onPageChanged</code></td>
259
+ <td>No</td>
260
+ <td><a href="#onpagechangedeventpayload"><code>(OnPageChangedPayload) =&gt; void</code></a></td>
261
+ <td>Triggered when the currently visible page index changes.</td>
262
+ <td>-</td>
263
+ </tr>
264
+ <tr>
265
+ <td><code>onError</code></td>
266
+ <td>No</td>
267
+ <td><a href="#onerroreventpayload"><code>(OnErrorPayload) =&gt; void</code></a></td>
268
+ <td>Triggered when the PDF fails to load, decrypt, or render.</td>
269
+ <td>-</td>
270
+ </tr>
271
+ </tbody>
275
272
  </table>
276
273
 
277
274
  ### API Reference
@@ -1,19 +1,56 @@
1
1
  import * as React from 'react';
2
2
  import { ContentPadding, FitMode, OnErrorEventPayload, OnLoadCompleteEventPayload, OnPageChangedEventPayload } from './types';
3
- import { StyleProp, ViewStyle } from 'react-native';
4
- type BaseProps = {
5
- style?: StyleProp<ViewStyle>;
3
+ import { ViewProps } from 'react-native';
4
+ type BaseProps = ViewProps & {
6
5
  /**
7
- * The file URI. Accepts a remote resource (e.g. via HTTPs) or a local file path (e.g. file:///)
6
+ * The file URI.
7
+ *
8
+ * Accepts either:
9
+ * - a remote resource (e.g., https://…)
10
+ * - a local file path (e.g., file:///…)
8
11
  */
9
12
  uri: string;
13
+ /**
14
+ * Password used to open password-protected or encrypted PDFs.
15
+ * If not provided, locked documents will fail to load.
16
+ */
10
17
  password?: string;
18
+ /**
19
+ * Enables page-by-page snapping instead of free scrolling.
20
+ *
21
+ * Defaults to vertical paging. If `horizontal` is true,
22
+ * paging occurs horizontally instead.
23
+ */
11
24
  pagingEnabled?: boolean;
25
+ /**
26
+ * Enables zoom in/out via double-tap gestures on the document.
27
+ */
12
28
  doubleTapToZoom?: boolean;
29
+ /**
30
+ * Renders and scrolls pages horizontally instead of vertically.
31
+ *
32
+ * If `pagingEnabled` is true, page snapping will follow the same direction.
33
+ */
13
34
  horizontal?: boolean;
35
+ /**
36
+ * Space between adjacent pages, expressed in layout units (dp/px depending on platform).
37
+ */
14
38
  pageGap?: number;
39
+ /**
40
+ * Padding applied around the document inside the viewer container.
41
+ */
15
42
  contentPadding?: ContentPadding;
43
+ /**
44
+ * Determines how the document is scaled to fit within the viewer
45
+ * (e.g., fit to width, height, or entire page depending on enum value).
46
+ */
16
47
  fitMode?: FitMode;
48
+ /**
49
+ * Automatically rescales the document when its own layout
50
+ * or its parent view’s layout changes after initial render.
51
+ *
52
+ * Note: initial render always auto-scales according to `fitMode`.
53
+ */
17
54
  autoScale?: boolean;
18
55
  };
19
56
  export type PdfViewProps = BaseProps & {
@@ -1 +1 @@
1
- {"version":3,"file":"pdf-view.d.ts","sourceRoot":"","sources":["../src/pdf-view.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAC9H,OAAO,EAAwB,SAAS,EAAc,SAAS,EAAE,MAAM,cAAc,CAAC;AAGtF,KAAK,SAAS,GAAG;IACf,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA;AAYD,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG;IACrC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,0BAA0B,KAAK,IAAI,CAAC;IAC9D,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,yBAAyB,KAAK,IAAI,CAAC;IAC5D,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAA;CAChD,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,6DAMrB,YAAY,sBAkBd,CAAA"}
1
+ {"version":3,"file":"pdf-view.d.ts","sourceRoot":"","sources":["../src/pdf-view.t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AAmC,UAAU,EAAa,MAAM,cAAc,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAwB/C,MAAM,aAAa,GAA4C,iBAAiB,CAAC,WAAW,CAAC,CAAC;AAU9F,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EACtB,KAAK,EACL,cAAc,EACd,OAAO,EACP,aAAa,EACb,GAAG,KAAK,EACK,EAAE,EAAE;IACjB,OAAO,CACL,CAAC,aAAa,CACZ,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CACjC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CACf,eAAe,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CACvC,UAAU,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAC7B,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CACvB,aAAa,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CACnC,QAAQ,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CACzB,cAAc,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CACrC,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CACvB,SAAS,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAC3B,cAAc,CAAC,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC,CACrD,aAAa,CAAC,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC,CACnD,OAAO,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,EACvC,CACH,CAAA;AACH,CAAC,CAAA;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,eAAe,EAAE,SAAS;KAC3B;CACF,CAAC,CAAA","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\n\nimport { ContentPadding, FitMode, OnErrorEventPayload, OnLoadCompleteEventPayload, OnPageChangedEventPayload } from './types';\nimport { NativeSyntheticEvent, StyleProp, StyleSheet, ViewStyle } from 'react-native';\nimport { forwardNativeEventTo } from './utils';\n\ntype BaseProps = {\n style?: StyleProp<ViewStyle>;\n /**\n * The file URI. Accepts a remote resource (e.g. via HTTPs) or a local file path (e.g. file:///)\n */\n uri: string;\n password?: string;\n pagingEnabled?: boolean\n doubleTapToZoom?: boolean\n horizontal?: boolean\n pageGap?: number\n contentPadding?: ContentPadding\n fitMode?: FitMode\n autoScale?: boolean\n}\n\ntype NativePdfViewProps = BaseProps & {\n onLoadComplete?: (event: NativeSyntheticEvent<OnLoadCompleteEventPayload>) => void;\n onPageChanged?: (event: NativeSyntheticEvent<OnPageChangedEventPayload>) => void;\n onError?: (event: NativeSyntheticEvent<OnErrorEventPayload>) => void;\n};\n\nconst NativePdfView: React.ComponentType<NativePdfViewProps> = requireNativeView('KJExpoPdf');\n\n// -----------\n\nexport type PdfViewProps = BaseProps & {\n onLoadComplete?: (params: OnLoadCompleteEventPayload) => void,\n onPageChanged?: (params: OnPageChangedEventPayload) => void,\n onError?: (params: OnErrorEventPayload) => void\n};\n\nexport const PdfView = ({\n style,\n onLoadComplete,\n onError,\n onPageChanged,\n ...props\n}: PdfViewProps) => {\n return (\n <NativePdfView\n style={[styles.container, style]}\n uri={props.uri}\n doubleTapToZoom={props.doubleTapToZoom}\n horizontal={props.horizontal}\n pageGap={props.pageGap}\n pagingEnabled={props.pagingEnabled}\n password={props.password}\n contentPadding={props.contentPadding}\n fitMode={props.fitMode}\n autoScale={props.autoScale}\n onLoadComplete={forwardNativeEventTo(onLoadComplete)}\n onPageChanged={forwardNativeEventTo(onPageChanged)}\n onError={forwardNativeEventTo(onError)}\n />\n )\n}\n\nconst styles = StyleSheet.create({\n container: {\n backgroundColor: '#eeeeee'\n }\n})\n"]}
1
+ {"version":3,"file":"pdf-view.js","sourceRoot":"","sources":["../src/pdf-view.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,M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';\n\nimport { ContentPadding, FitMode, OnErrorEventPayload, OnLoadCompleteEventPayload, OnPageChangedEventPayload } from './types';\nimport { NativeSyntheticEvent, StyleSheet, ViewProps } from 'react-native';\nimport { forwardNativeEventTo } from './utils';\n\ntype BaseProps = ViewProps & {\n /**\n * The file URI.\n *\n * Accepts either:\n * - a remote resource (e.g., https://…)\n * - a local file path (e.g., file:///…)\n */\n uri: string;\n\n /**\n * Password used to open password-protected or encrypted PDFs.\n * If not provided, locked documents will fail to load.\n */\n password?: string;\n\n /**\n * Enables page-by-page snapping instead of free scrolling.\n *\n * Defaults to vertical paging. If `horizontal` is true,\n * paging occurs horizontally instead.\n */\n pagingEnabled?: boolean;\n\n /**\n * Enables zoom in/out via double-tap gestures on the document.\n */\n doubleTapToZoom?: boolean;\n\n /**\n * Renders and scrolls pages horizontally instead of vertically.\n *\n * If `pagingEnabled` is true, page snapping will follow the same direction.\n */\n horizontal?: boolean;\n\n /**\n * Space between adjacent pages, expressed in layout units (dp/px depending on platform).\n */\n pageGap?: number;\n\n /**\n * Padding applied around the document inside the viewer container.\n */\n contentPadding?: ContentPadding;\n\n /**\n * Determines how the document is scaled to fit within the viewer\n * (e.g., fit to width, height, or entire page depending on enum value).\n */\n fitMode?: FitMode;\n\n /**\n * Automatically rescales the document when its own layout\n * or its parent view’s layout changes after initial render.\n *\n * Note: initial render always auto-scales according to `fitMode`.\n */\n autoScale?: boolean;\n}\n\ntype NativePdfViewProps = BaseProps & {\n /**\n * Fired after the PDF document has been fully loaded\n * and its metadata (such as page count) is available.\n */\n onLoadComplete?: (\n event: NativeSyntheticEvent<OnLoadCompleteEventPayload>\n ) => void;\n\n /**\n * Fired when the currently visible page changes due to user interaction\n * or programmatic scroll/paging.\n */\n onPageChanged?: (\n event: NativeSyntheticEvent<OnPageChangedEventPayload>\n ) => void;\n\n /**\n * Fired when the PDF fails to load, decrypt, or render.\n * The payload contains error information.\n */\n onError?: (\n event: NativeSyntheticEvent<OnErrorEventPayload>\n ) => void;\n};\n\nconst NativePdfView: React.ComponentType<NativePdfViewProps> = requireNativeView('KJExpoPdf');\n\n// -----------\n\nexport type PdfViewProps = BaseProps & {\n onLoadComplete?: (params: OnLoadCompleteEventPayload) => void,\n onPageChanged?: (params: OnPageChangedEventPayload) => void,\n onError?: (params: OnErrorEventPayload) => void\n};\n\nexport const PdfView = ({\n style,\n onLoadComplete,\n onError,\n onPageChanged,\n ...props\n}: PdfViewProps) => {\n return (\n <NativePdfView\n style={[styles.container, style]}\n uri={props.uri}\n doubleTapToZoom={props.doubleTapToZoom}\n horizontal={props.horizontal}\n pageGap={props.pageGap}\n pagingEnabled={props.pagingEnabled}\n password={props.password}\n contentPadding={props.contentPadding}\n fitMode={props.fitMode}\n autoScale={props.autoScale}\n onLoadComplete={forwardNativeEventTo(onLoadComplete)}\n onPageChanged={forwardNativeEventTo(onPageChanged)}\n onError={forwardNativeEventTo(onError)}\n />\n )\n}\n\nconst styles = StyleSheet.create({\n container: {\n backgroundColor: '#eeeeee'\n }\n})\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kishannareshpal/expo-pdf",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "author": "Kishan Jadav <kishan_jadav@hotmail.com> (https://github.com/kishannareshpal)",
5
5
  "repository": "https://github.com/kishannareshpal/expo-pdf",
6
6
  "main": "build/index.js",
package/src/pdf-view.tsx CHANGED
@@ -2,29 +2,94 @@ import { requireNativeView } from 'expo';
2
2
  import * as React from 'react';
3
3
 
4
4
  import { ContentPadding, FitMode, OnErrorEventPayload, OnLoadCompleteEventPayload, OnPageChangedEventPayload } from './types';
5
- import { NativeSyntheticEvent, StyleProp, StyleSheet, ViewStyle } from 'react-native';
5
+ import { NativeSyntheticEvent, StyleSheet, ViewProps } from 'react-native';
6
6
  import { forwardNativeEventTo } from './utils';
7
7
 
8
- type BaseProps = {
9
- style?: StyleProp<ViewStyle>;
8
+ type BaseProps = ViewProps & {
10
9
  /**
11
- * The file URI. Accepts a remote resource (e.g. via HTTPs) or a local file path (e.g. file:///)
10
+ * The file URI.
11
+ *
12
+ * Accepts either:
13
+ * - a remote resource (e.g., https://…)
14
+ * - a local file path (e.g., file:///…)
12
15
  */
13
16
  uri: string;
17
+
18
+ /**
19
+ * Password used to open password-protected or encrypted PDFs.
20
+ * If not provided, locked documents will fail to load.
21
+ */
14
22
  password?: string;
15
- pagingEnabled?: boolean
16
- doubleTapToZoom?: boolean
17
- horizontal?: boolean
18
- pageGap?: number
19
- contentPadding?: ContentPadding
20
- fitMode?: FitMode
21
- autoScale?: boolean
23
+
24
+ /**
25
+ * Enables page-by-page snapping instead of free scrolling.
26
+ *
27
+ * Defaults to vertical paging. If `horizontal` is true,
28
+ * paging occurs horizontally instead.
29
+ */
30
+ pagingEnabled?: boolean;
31
+
32
+ /**
33
+ * Enables zoom in/out via double-tap gestures on the document.
34
+ */
35
+ doubleTapToZoom?: boolean;
36
+
37
+ /**
38
+ * Renders and scrolls pages horizontally instead of vertically.
39
+ *
40
+ * If `pagingEnabled` is true, page snapping will follow the same direction.
41
+ */
42
+ horizontal?: boolean;
43
+
44
+ /**
45
+ * Space between adjacent pages, expressed in layout units (dp/px depending on platform).
46
+ */
47
+ pageGap?: number;
48
+
49
+ /**
50
+ * Padding applied around the document inside the viewer container.
51
+ */
52
+ contentPadding?: ContentPadding;
53
+
54
+ /**
55
+ * Determines how the document is scaled to fit within the viewer
56
+ * (e.g., fit to width, height, or entire page depending on enum value).
57
+ */
58
+ fitMode?: FitMode;
59
+
60
+ /**
61
+ * Automatically rescales the document when its own layout
62
+ * or its parent view’s layout changes after initial render.
63
+ *
64
+ * Note: initial render always auto-scales according to `fitMode`.
65
+ */
66
+ autoScale?: boolean;
22
67
  }
23
68
 
24
69
  type NativePdfViewProps = BaseProps & {
25
- onLoadComplete?: (event: NativeSyntheticEvent<OnLoadCompleteEventPayload>) => void;
26
- onPageChanged?: (event: NativeSyntheticEvent<OnPageChangedEventPayload>) => void;
27
- onError?: (event: NativeSyntheticEvent<OnErrorEventPayload>) => void;
70
+ /**
71
+ * Fired after the PDF document has been fully loaded
72
+ * and its metadata (such as page count) is available.
73
+ */
74
+ onLoadComplete?: (
75
+ event: NativeSyntheticEvent<OnLoadCompleteEventPayload>
76
+ ) => void;
77
+
78
+ /**
79
+ * Fired when the currently visible page changes due to user interaction
80
+ * or programmatic scroll/paging.
81
+ */
82
+ onPageChanged?: (
83
+ event: NativeSyntheticEvent<OnPageChangedEventPayload>
84
+ ) => void;
85
+
86
+ /**
87
+ * Fired when the PDF fails to load, decrypt, or render.
88
+ * The payload contains error information.
89
+ */
90
+ onError?: (
91
+ event: NativeSyntheticEvent<OnErrorEventPayload>
92
+ ) => void;
28
93
  };
29
94
 
30
95
  const NativePdfView: React.ComponentType<NativePdfViewProps> = requireNativeView('KJExpoPdf');