@thatkid02/react-native-pdf-viewer 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +115 -232
- package/android/build.gradle +5 -3
- package/android/src/main/java/com/margelo/nitro/pdfviewer/HybridPdfViewer.kt +10 -0
- package/android/src/main/java/com/margelo/nitro/pdfviewer/PdfViewer.kt +792 -651
- package/ios/PdfViewer.swift +151 -36
- package/lib/typescript/src/PdfViewer.nitro.d.ts +7 -0
- package/lib/typescript/src/PdfViewer.nitro.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JDocumentInfo.hpp +65 -0
- package/nitrogen/generated/android/c++/JHybridPdfViewerSpec.cpp +9 -0
- package/nitrogen/generated/android/c++/JHybridPdfViewerSpec.hpp +1 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/DocumentInfo.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/HybridPdfViewerSpec.kt +4 -0
- package/nitrogen/generated/ios/PdfViewer-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/PdfViewer-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridPdfViewerSpecSwift.hpp +11 -0
- package/nitrogen/generated/ios/swift/DocumentInfo.swift +68 -0
- package/nitrogen/generated/ios/swift/HybridPdfViewerSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridPdfViewerSpec_cxx.swift +18 -0
- package/nitrogen/generated/shared/c++/DocumentInfo.hpp +79 -0
- package/nitrogen/generated/shared/c++/HybridPdfViewerSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridPdfViewerSpec.hpp +4 -0
- package/package.json +1 -1
- package/src/PdfViewer.nitro.ts +10 -0
package/README.md
CHANGED
|
@@ -3,32 +3,20 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@thatkid02/react-native-pdf-viewer)
|
|
4
4
|
[](https://www.npmjs.com/package/@thatkid02/react-native-pdf-viewer)
|
|
5
5
|
|
|
6
|
-
High-performance PDF viewer for React Native, built with [Nitro Modules](https://nitro.margelo.com/) for native rendering
|
|
6
|
+
High-performance PDF viewer for React Native, built with [Nitro Modules](https://nitro.margelo.com/) for native rendering.
|
|
7
7
|
|
|
8
|
-
<
|
|
8
|
+
<p align="center">
|
|
9
|
+
<video src="docs/pdf.mp4" width="300" controls></video>
|
|
10
|
+
</p>
|
|
9
11
|
|
|
10
12
|
## Features
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
✅ **Memory efficient** - Virtualizes pages, only renders visible content
|
|
19
|
-
✅ **iOS-specific layouts** - Horizontal scroll and paging modes
|
|
20
|
-
|
|
21
|
-
## Platform Support
|
|
22
|
-
|
|
23
|
-
| Feature | Android | iOS | Notes |
|
|
24
|
-
|---------|---------|-----|-------|
|
|
25
|
-
| Local Files (file://) | ✅ | ✅ | |
|
|
26
|
-
| Remote URLs (http/https) | ✅ | ✅ | Prefer HTTPS in production |
|
|
27
|
-
| Zoom Controls | ✅(2 scale) | ✅ | |
|
|
28
|
-
| Page Navigation | ✅ | ✅ | |
|
|
29
|
-
| Horizontal Scroll | ❌ | ✅ | iOS only |
|
|
30
|
-
| Paging Mode | ❌ | ✅ | iOS only |
|
|
31
|
-
| Thumbnail Generation | ✅ | ✅ | Async on both platforms |
|
|
14
|
+
- 📄 **Native PDF rendering** — PDFKit (iOS) & PdfRenderer (Android)
|
|
15
|
+
- 🔍 **Pinch-to-zoom & pan** — Smooth gesture handling
|
|
16
|
+
- 🖼️ **Thumbnail generation** — Async page previews
|
|
17
|
+
- 🌐 **Local & remote files** — `file://`, `http://`, `https://`
|
|
18
|
+
- 📱 **iOS layouts** — Horizontal scroll & paging modes
|
|
19
|
+
- 💾 **Memory efficient** — Virtualized pages, LRU cache
|
|
32
20
|
|
|
33
21
|
## Installation
|
|
34
22
|
|
|
@@ -36,285 +24,180 @@ High-performance PDF viewer for React Native, built with [Nitro Modules](https:/
|
|
|
36
24
|
npm install @thatkid02/react-native-pdf-viewer react-native-nitro-modules
|
|
37
25
|
```
|
|
38
26
|
|
|
39
|
-
|
|
27
|
+
### iOS
|
|
40
28
|
|
|
41
|
-
|
|
29
|
+
```sh
|
|
30
|
+
cd ios && pod install
|
|
31
|
+
```
|
|
42
32
|
|
|
43
|
-
|
|
33
|
+
## Quick Start
|
|
44
34
|
|
|
45
35
|
```tsx
|
|
46
36
|
import { PdfViewerView } from '@thatkid02/react-native-pdf-viewer';
|
|
47
37
|
|
|
48
|
-
|
|
38
|
+
function App() {
|
|
49
39
|
return (
|
|
50
40
|
<PdfViewerView
|
|
51
41
|
source="https://example.com/document.pdf"
|
|
52
42
|
style={{ flex: 1 }}
|
|
53
|
-
onLoadComplete={(
|
|
54
|
-
|
|
55
|
-
}}
|
|
56
|
-
onError={(event) => {
|
|
57
|
-
console.error('PDF error:', event.message);
|
|
58
|
-
}}
|
|
43
|
+
onLoadComplete={(e) => console.log(`Loaded ${e.pageCount} pages`)}
|
|
44
|
+
onError={(e) => console.error(e.message)}
|
|
59
45
|
/>
|
|
60
46
|
);
|
|
61
47
|
}
|
|
62
48
|
```
|
|
63
49
|
|
|
64
|
-
|
|
50
|
+
## Usage with Ref
|
|
65
51
|
|
|
66
|
-
|
|
52
|
+
Callbacks must be wrapped with `callback()` from nitro-modules to avoid re-renders. [Learn more](https://nitro.margelo.com/docs/view-components#callbacks-have-to-be-wrapped)
|
|
67
53
|
|
|
68
54
|
```tsx
|
|
69
|
-
import
|
|
70
|
-
import { View, Button
|
|
71
|
-
import {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// Generate thumbnails for all pages
|
|
81
|
-
pdfRef.current?.generateAllThumbnails();
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const handlePageChange = (event) => {
|
|
85
|
-
console.log(`Current page: ${event.page + 1} of ${event.pageCount}`);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const handleScaleChange = (event) => {
|
|
89
|
-
console.log(`Zoom scale: ${event.scale}`);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const handleThumbnailGenerated = (event) => {
|
|
93
|
-
console.log(`Thumbnail for page ${event.page}: ${event.uri}`);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const goToPage = (page: number) => {
|
|
97
|
-
pdfRef.current?.goToPage(page);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const zoomIn = () => {
|
|
101
|
-
pdfRef.current?.setScale(2.0);
|
|
102
|
-
};
|
|
103
|
-
|
|
55
|
+
import { useRef } from 'react';
|
|
56
|
+
import { View, Button } from 'react-native';
|
|
57
|
+
import {
|
|
58
|
+
PdfViewerView,
|
|
59
|
+
callback,
|
|
60
|
+
type PdfViewerRef
|
|
61
|
+
} from '@thatkid02/react-native-pdf-viewer';
|
|
62
|
+
|
|
63
|
+
function PdfScreen() {
|
|
64
|
+
const pdfRef = useRef<PdfViewerRef>(null);
|
|
104
65
|
|
|
105
66
|
return (
|
|
106
|
-
<View style={
|
|
67
|
+
<View style={{ flex: 1 }}>
|
|
107
68
|
<PdfViewerView
|
|
108
|
-
hybridRef={callback((ref
|
|
69
|
+
hybridRef={callback((ref) => { pdfRef.current = ref; })}
|
|
109
70
|
source="https://example.com/document.pdf"
|
|
110
|
-
style={
|
|
111
|
-
// Layout options
|
|
112
|
-
spacing={16}
|
|
71
|
+
style={{ flex: 1 }}
|
|
113
72
|
enableZoom={true}
|
|
114
73
|
minScale={0.5}
|
|
115
|
-
maxScale={
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
onError={callback(handleError)}
|
|
126
|
-
onThumbnailGenerated={callback(handleThumbnailGenerated)}
|
|
127
|
-
onLoadingChange={callback(handleLoadingChange)}
|
|
74
|
+
maxScale={4.0}
|
|
75
|
+
onLoadComplete={callback((e) => {
|
|
76
|
+
console.log(`${e.pageCount} pages, ${e.pageWidth}x${e.pageHeight}`);
|
|
77
|
+
})}
|
|
78
|
+
onPageChange={callback((e) => {
|
|
79
|
+
console.log(`Page ${e.page} of ${e.pageCount}`);
|
|
80
|
+
})}
|
|
81
|
+
onThumbnailGenerated={callback((e) => {
|
|
82
|
+
console.log(`Thumbnail page ${e.page}: ${e.uri}`);
|
|
83
|
+
})}
|
|
128
84
|
/>
|
|
129
85
|
|
|
130
|
-
<View style={
|
|
131
|
-
<Button title="
|
|
132
|
-
<Button title="Zoom
|
|
86
|
+
<View style={{ flexDirection: 'row', padding: 16, gap: 8 }}>
|
|
87
|
+
<Button title="Page 1" onPress={() => pdfRef.current?.goToPage(0)} />
|
|
88
|
+
<Button title="Zoom 2x" onPress={() => pdfRef.current?.setScale(2)} />
|
|
89
|
+
<Button title="Thumbnails" onPress={() => pdfRef.current?.generateAllThumbnails()} />
|
|
133
90
|
</View>
|
|
134
91
|
</View>
|
|
135
92
|
);
|
|
136
93
|
}
|
|
137
|
-
|
|
138
|
-
const styles = StyleSheet.create({
|
|
139
|
-
container: {
|
|
140
|
-
flex: 1,
|
|
141
|
-
},
|
|
142
|
-
pdf: {
|
|
143
|
-
flex: 1,
|
|
144
|
-
},
|
|
145
|
-
controls: {
|
|
146
|
-
flexDirection: 'row',
|
|
147
|
-
justifyContent: 'space-around',
|
|
148
|
-
padding: 16,
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
94
|
```
|
|
152
95
|
|
|
153
|
-
|
|
96
|
+
## iOS-Only Features
|
|
154
97
|
|
|
155
98
|
```tsx
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
99
|
+
// Horizontal scrolling
|
|
100
|
+
<PdfViewerView source={url} horizontal={true} />
|
|
101
|
+
|
|
102
|
+
// Paging mode (swipe between pages)
|
|
103
|
+
<PdfViewerView source={url} enablePaging={true} />
|
|
104
|
+
|
|
105
|
+
// Combined
|
|
106
|
+
<PdfViewerView source={url} horizontal={true} enablePaging={true} />
|
|
160
107
|
```
|
|
161
108
|
|
|
162
|
-
|
|
109
|
+
## Glass UI / Transparent Bars
|
|
163
110
|
|
|
164
|
-
|
|
165
|
-
// Horizontal scrolling (iOS only)
|
|
166
|
-
<PdfViewerView
|
|
167
|
-
source="https://example.com/document.pdf"
|
|
168
|
-
horizontal={true}
|
|
169
|
-
style={{ flex: 1 }}
|
|
170
|
-
/>
|
|
111
|
+
Content scrolls behind transparent headers/toolbars:
|
|
171
112
|
|
|
172
|
-
|
|
113
|
+
```tsx
|
|
173
114
|
<PdfViewerView
|
|
174
|
-
source=
|
|
175
|
-
|
|
115
|
+
source={url}
|
|
116
|
+
contentInsetTop={100} // Header height
|
|
117
|
+
contentInsetBottom={80} // Toolbar height
|
|
176
118
|
style={{ flex: 1 }}
|
|
177
119
|
/>
|
|
178
120
|
```
|
|
179
121
|
|
|
180
|
-
##
|
|
181
|
-
|
|
182
|
-
### Props
|
|
122
|
+
## Props
|
|
183
123
|
|
|
184
124
|
| Prop | Type | Default | Description |
|
|
185
125
|
|------|------|---------|-------------|
|
|
186
|
-
| `source` | `string` |
|
|
187
|
-
| `spacing` | `number` | `8` | Space between pages
|
|
188
|
-
| `enableZoom` | `boolean` | `true` | Enable pinch-to-zoom
|
|
126
|
+
| `source` | `string` | — | PDF URI (`file://`, `http://`, `https://`) |
|
|
127
|
+
| `spacing` | `number` | `8` | Space between pages (px) |
|
|
128
|
+
| `enableZoom` | `boolean` | `true` | Enable pinch-to-zoom |
|
|
189
129
|
| `minScale` | `number` | `0.5` | Minimum zoom scale |
|
|
190
130
|
| `maxScale` | `number` | `4.0` | Maximum zoom scale |
|
|
191
|
-
| `showsActivityIndicator` | `boolean` | `true` | Show loading
|
|
192
|
-
| `horizontal` | `boolean` | `false` | Horizontal scroll (iOS only) |
|
|
193
|
-
| `enablePaging` | `boolean` | `false` |
|
|
194
|
-
| `contentInsetTop` | `number` | `0` | Top
|
|
195
|
-
| `contentInsetBottom` | `number` | `0` | Bottom
|
|
196
|
-
| `contentInsetLeft` | `number` | `0` | Left
|
|
197
|
-
| `contentInsetRight` | `number` | `0` | Right
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
|
202
|
-
|
|
203
|
-
| `
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
source="https://example.com/document.pdf"
|
|
212
|
-
contentInsetTop={80} // Height of your transparent top bar
|
|
213
|
-
contentInsetBottom={60} // Height of your transparent bottom toolbar
|
|
214
|
-
style={{ flex: 1 }}
|
|
215
|
-
/>
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
This creates a modern "glass" effect where:
|
|
219
|
-
- PDF content starts below the top bar
|
|
220
|
-
- Content scrolls behind transparent bars
|
|
221
|
-
- Content ends above the bottom toolbar
|
|
222
|
-
|
|
223
|
-
### Methods
|
|
224
|
-
|
|
225
|
-
Access methods via ref:
|
|
131
|
+
| `showsActivityIndicator` | `boolean` | `true` | Show loading spinner |
|
|
132
|
+
| `horizontal` | `boolean` | `false` | Horizontal scroll *(iOS only)* |
|
|
133
|
+
| `enablePaging` | `boolean` | `false` | Paging mode *(iOS only)* |
|
|
134
|
+
| `contentInsetTop` | `number` | `0` | Top inset for glass UI |
|
|
135
|
+
| `contentInsetBottom` | `number` | `0` | Bottom inset for glass UI |
|
|
136
|
+
| `contentInsetLeft` | `number` | `0` | Left inset |
|
|
137
|
+
| `contentInsetRight` | `number` | `0` | Right inset |
|
|
138
|
+
|
|
139
|
+
## Events
|
|
140
|
+
|
|
141
|
+
| Event | Payload | Description |
|
|
142
|
+
|-------|---------|-------------|
|
|
143
|
+
| `onLoadComplete` | `{ pageCount, pageWidth, pageHeight }` | PDF loaded successfully |
|
|
144
|
+
| `onPageChange` | `{ page, pageCount }` | Visible page changed |
|
|
145
|
+
| `onScaleChange` | `{ scale }` | Zoom level changed |
|
|
146
|
+
| `onError` | `{ message, code }` | Error occurred |
|
|
147
|
+
| `onThumbnailGenerated` | `{ page, uri }` | Thumbnail ready |
|
|
148
|
+
| `onLoadingChange` | `{ isLoading }` | Loading state changed |
|
|
149
|
+
|
|
150
|
+
## Methods
|
|
226
151
|
|
|
227
152
|
```tsx
|
|
228
|
-
const pdfRef = useRef<
|
|
153
|
+
const pdfRef = useRef<PdfViewerRef>(null);
|
|
229
154
|
|
|
230
|
-
// Navigate to
|
|
231
|
-
pdfRef.current?.goToPage(
|
|
155
|
+
// Navigate to page (0-indexed)
|
|
156
|
+
pdfRef.current?.goToPage(0);
|
|
232
157
|
|
|
233
|
-
// Set zoom
|
|
158
|
+
// Set zoom level
|
|
234
159
|
pdfRef.current?.setScale(2.0);
|
|
235
160
|
|
|
236
|
-
// Generate thumbnail
|
|
237
|
-
pdfRef.current?.generateThumbnail(
|
|
161
|
+
// Generate single thumbnail
|
|
162
|
+
pdfRef.current?.generateThumbnail(0);
|
|
238
163
|
|
|
239
|
-
// Generate
|
|
164
|
+
// Generate all thumbnails
|
|
240
165
|
pdfRef.current?.generateAllThumbnails();
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
### Events
|
|
244
|
-
|
|
245
|
-
#### LoadCompleteEvent
|
|
246
|
-
```typescript
|
|
247
|
-
{
|
|
248
|
-
pageCount: number; // Total number of pages
|
|
249
|
-
pageWidth: number; // Width of first page
|
|
250
|
-
pageHeight: number; // Height of first page
|
|
251
|
-
}
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
#### PageChangeEvent
|
|
255
|
-
```typescript
|
|
256
|
-
{
|
|
257
|
-
page: number; // Current page index (0-based)
|
|
258
|
-
pageCount: number; // Total pages
|
|
259
|
-
}
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
#### ScaleChangeEvent
|
|
263
|
-
```typescript
|
|
264
|
-
{
|
|
265
|
-
scale: number; // Current zoom scale
|
|
266
|
-
}
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
#### ErrorEvent
|
|
270
|
-
```typescript
|
|
271
|
-
{
|
|
272
|
-
message: string; // Error description
|
|
273
|
-
code: string; // Error code (e.g., "FILE_NOT_FOUND")
|
|
274
|
-
}
|
|
275
|
-
```
|
|
276
166
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
{
|
|
280
|
-
page: number; // Page index
|
|
281
|
-
uri: string; // File URI of thumbnail image
|
|
282
|
-
}
|
|
167
|
+
// Get document info
|
|
168
|
+
const info = pdfRef.current?.getDocumentInfo();
|
|
169
|
+
// { pageCount, pageWidth, pageHeight, currentPage }
|
|
283
170
|
```
|
|
284
171
|
|
|
285
|
-
##
|
|
172
|
+
## Platform Differences
|
|
286
173
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
174
|
+
| Feature | Android | iOS |
|
|
175
|
+
|---------|:-------:|:---:|
|
|
176
|
+
| Vertical scroll | ✅ | ✅ |
|
|
177
|
+
| Horizontal scroll | — | ✅ |
|
|
178
|
+
| Paging mode | — | ✅ |
|
|
179
|
+
| Pinch-to-zoom | ✅ | ✅ |
|
|
180
|
+
| Double-tap zoom | ✅ | ✅ |
|
|
181
|
+
| Pan when zoomed | ✅ | ✅ |
|
|
182
|
+
| Thumbnails | ✅ | ✅ |
|
|
183
|
+
| Remote URLs | ✅ | ✅ |
|
|
184
|
+
| Local files | ✅ | ✅ |
|
|
291
185
|
|
|
292
186
|
## Troubleshooting
|
|
293
187
|
|
|
294
|
-
|
|
188
|
+
**PDF fails to load from URL**
|
|
189
|
+
Ensure the URL is accessible. Use HTTPS in production.
|
|
295
190
|
|
|
296
|
-
|
|
191
|
+
**Out of memory on large PDFs**
|
|
192
|
+
Lower `maxScale` to reduce memory usage. The viewer automatically manages memory with dynamic quality scaling.
|
|
297
193
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
The library automatically manages memory, but for very large documents at high zoom levels:
|
|
301
|
-
- Limit `maxScale` to reduce memory usage
|
|
302
|
-
- The Android implementation dynamically reduces quality at high zoom levels
|
|
303
|
-
|
|
304
|
-
### iOS horizontal/paging mode not working
|
|
305
|
-
|
|
306
|
-
These features are iOS-only. On Android, the viewer always uses vertical scrolling.
|
|
194
|
+
**Horizontal/paging not working**
|
|
195
|
+
These are iOS-only features. Android uses vertical scroll.
|
|
307
196
|
|
|
308
197
|
## Contributing
|
|
309
198
|
|
|
310
|
-
|
|
311
|
-
- [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request)
|
|
312
|
-
- [Code of conduct](CODE_OF_CONDUCT.md)
|
|
199
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup.
|
|
313
200
|
|
|
314
201
|
## License
|
|
315
202
|
|
|
316
203
|
MIT
|
|
317
|
-
|
|
318
|
-
---
|
|
319
|
-
|
|
320
|
-
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
package/android/build.gradle
CHANGED
|
@@ -36,8 +36,6 @@ apply plugin: "com.android.library"
|
|
|
36
36
|
apply plugin: "kotlin-android"
|
|
37
37
|
apply from: '../nitrogen/generated/android/pdfviewer+autolinking.gradle'
|
|
38
38
|
|
|
39
|
-
apply plugin: "com.facebook.react"
|
|
40
|
-
|
|
41
39
|
android {
|
|
42
40
|
namespace "com.margelo.nitro.pdfviewer"
|
|
43
41
|
|
|
@@ -89,7 +87,10 @@ android {
|
|
|
89
87
|
"**/libreactnativejni.so",
|
|
90
88
|
"**/libturbomodulejsijni.so",
|
|
91
89
|
"**/libreact_nativemodule_core.so",
|
|
92
|
-
"**/libjscexecutor.so"
|
|
90
|
+
"**/libjscexecutor.so",
|
|
91
|
+
// Exclude react-native-safe-area-context generated code to prevent duplicate classes
|
|
92
|
+
"com/facebook/react/viewmanagers/RNCSafeAreaProviderManagerDelegate**",
|
|
93
|
+
"com/facebook/react/viewmanagers/RNCSafeAreaViewManagerDelegate**"
|
|
93
94
|
]
|
|
94
95
|
}
|
|
95
96
|
|
|
@@ -118,4 +119,5 @@ dependencies {
|
|
|
118
119
|
implementation "com.facebook.react:react-android"
|
|
119
120
|
implementation project(":react-native-nitro-modules")
|
|
120
121
|
implementation "androidx.recyclerview:recyclerview:1.3.2"
|
|
122
|
+
implementation "androidx.lifecycle:lifecycle-process:2.6.2"
|
|
121
123
|
}
|
|
@@ -190,4 +190,14 @@ class HybridPdfViewer(private val reactContext: ThemedReactContext) : HybridPdfV
|
|
|
190
190
|
override fun generateAllThumbnails() {
|
|
191
191
|
documentViewer.generateAllThumbnails()
|
|
192
192
|
}
|
|
193
|
+
|
|
194
|
+
override fun getDocumentInfo(): DocumentInfo? {
|
|
195
|
+
val info = documentViewer.getDocumentInfo() ?: return null
|
|
196
|
+
return DocumentInfo(
|
|
197
|
+
pageCount = (info["pageCount"] as? Int)?.toDouble() ?: 0.0,
|
|
198
|
+
pageWidth = (info["pageWidth"] as? Int)?.toDouble() ?: 0.0,
|
|
199
|
+
pageHeight = (info["pageHeight"] as? Int)?.toDouble() ?: 0.0,
|
|
200
|
+
currentPage = (info["currentPage"] as? Int)?.toDouble() ?: 0.0
|
|
201
|
+
)
|
|
202
|
+
}
|
|
193
203
|
}
|