react-native-pdf-jsi 2.2.8 → 3.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.
- package/README.md +312 -176
- package/android/src/main/java/org/wonday/pdf/FileDownloader.java +292 -0
- package/android/src/main/java/org/wonday/pdf/FileManager.java +123 -0
- package/android/src/main/java/org/wonday/pdf/LicenseVerifier.java +311 -0
- package/android/src/main/java/org/wonday/pdf/PDFExporter.java +769 -0
- package/android/src/main/java/org/wonday/pdf/RNPDFPackage.java +7 -0
- package/index.js +58 -0
- package/ios/RNPDFPdf/PDFExporter.h +16 -0
- package/ios/RNPDFPdf/PDFExporter.m +537 -0
- package/package.json +3 -2
- package/src/components/AnalyticsPanel.jsx +243 -0
- package/src/components/BookmarkIndicator.jsx +66 -0
- package/src/components/BookmarkListModal.jsx +378 -0
- package/src/components/BookmarkModal.jsx +253 -0
- package/src/components/BottomSheet.jsx +121 -0
- package/src/components/ExportMenu.jsx +223 -0
- package/src/components/LoadingOverlay.jsx +52 -0
- package/src/components/OperationsMenu.jsx +231 -0
- package/src/components/SidePanel.jsx +95 -0
- package/src/components/Toast.jsx +140 -0
- package/src/components/Toolbar.jsx +135 -0
- package/src/managers/AnalyticsManager.js +695 -0
- package/src/managers/BookmarkManager.js +538 -0
- package/src/managers/ExportManager.js +687 -0
- package/src/managers/FileManager.js +89 -0
- package/src/utils/ErrorHandler.js +179 -0
- package/src/utils/TestData.js +112 -0
package/README.md
CHANGED
|
@@ -1,21 +1,44 @@
|
|
|
1
1
|
# react-native-pdf-jsi 🚀
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/react-native-pdf-jsi)
|
|
4
|
+
[](https://www.npmjs.com/package/react-native-pdf-jsi)
|
|
5
|
+
[](https://www.npmjs.com/package/react-native-pdf-jsi)
|
|
6
|
+
[](https://github.com/126punith/react-native-enhanced-pdf)
|
|
7
|
+
[](https://euphonious-faun-24f4bc.netlify.app/)
|
|
6
8
|
|
|
7
9
|
**The fastest React Native PDF viewer with JSI acceleration - up to 80x faster than traditional bridge!**
|
|
8
10
|
|
|
11
|
+
## 🆓 100% FREE - All Features Included!
|
|
12
|
+
|
|
13
|
+
**Every feature is FREE and MIT licensed - no hidden costs, no Pro tier, no subscriptions!**
|
|
14
|
+
|
|
15
|
+
All advanced features that were previously paid are now completely FREE:
|
|
16
|
+
- ✅ **Bookmarks with 10 Colors** - Create, organize with custom colors
|
|
17
|
+
- ✅ **Reading Analytics** - Track progress, sessions, and insights
|
|
18
|
+
- ✅ **Export to Images** - PNG/JPEG export with quality control
|
|
19
|
+
- ✅ **PDF Operations** - Split, merge, extract, rotate, delete pages
|
|
20
|
+
- ✅ **PDF Compression** - Reduce file sizes with smart presets
|
|
21
|
+
- ✅ **Text Extraction** - Extract and search text from PDFs
|
|
22
|
+
- ✅ **File Management** - Download to storage, open folders (Android)
|
|
23
|
+
- ✅ **All Performance Features** - JSI acceleration, smart caching
|
|
24
|
+
|
|
25
|
+
**Use commercially without restrictions - MIT License!**
|
|
26
|
+
|
|
27
|
+
📚 **[Complete Documentation Website](https://euphonious-faun-24f4bc.netlify.app/)** - API Reference, Guides, and Examples
|
|
28
|
+
|
|
9
29
|
### Key Advantages:
|
|
30
|
+
- 🆓 **100% FREE** - All features MIT licensed, no subscriptions or hidden fees
|
|
10
31
|
- ✅ **Google Play 16KB Compliant** - Ready for Android 15+ requirements
|
|
11
|
-
- ⚡ **High Performance** - JSI integration for faster rendering
|
|
32
|
+
- ⚡ **High Performance** - JSI integration for faster rendering (80x faster)
|
|
12
33
|
- 🚀 **Easy Migration** - Drop-in replacement for existing PDF libraries
|
|
13
|
-
- 📄 **
|
|
34
|
+
- 📄 **Advanced Features** - Bookmarks, analytics, export, compression all FREE
|
|
14
35
|
- 🎯 **Smart Caching** - 30-day persistent cache system
|
|
15
|
-
- 🛡️ **Future-Proof** - Built with latest NDK
|
|
36
|
+
- 🛡️ **Future-Proof** - Built with latest NDK r28.2+ and modern toolchain
|
|
16
37
|
|
|
17
38
|
A high-performance React Native PDF viewer component with JSI (JavaScript Interface) integration for enhanced speed and efficiency. Perfect for large PDF files with lazy loading, smart caching, progressive loading, and zero-bridge overhead operations.
|
|
18
39
|
|
|
40
|
+
**🎓 [Read Full Documentation](https://euphonious-faun-24f4bc.netlify.app/)** - Complete guides, API reference, and examples
|
|
41
|
+
|
|
19
42
|
## ✅ **Google Play 16KB Page Size Compliance**
|
|
20
43
|
|
|
21
44
|
Starting November 1, 2025, Google Play will require apps to support 16KB page sizes for devices with Android 15+. **react-native-pdf-jsi is built with NDK r27+ and fully supports Android 15+ requirements**, ensuring your app meets Google Play policy requirements.
|
|
@@ -35,6 +58,35 @@ Starting November 1, 2025, Google Play will require apps to support 16KB page si
|
|
|
35
58
|
- ✅ **Google Play Approved** - Meets all current and future requirements
|
|
36
59
|
- ✅ **Drop-in Replacement** - Easy migration from existing libraries
|
|
37
60
|
|
|
61
|
+
## 🎉 Version 3.0.0 - Major Release with Complete Feature Sync!
|
|
62
|
+
|
|
63
|
+
**Complete synchronization of all features from development package with enhanced Android capabilities!**
|
|
64
|
+
|
|
65
|
+
### 🚀 **What's New in v3.0.0:**
|
|
66
|
+
- **📦 Complete Feature Sync** - All features from local development package now in production
|
|
67
|
+
- **📥 FileDownloader Module** - Native Android module for downloading files to public storage using MediaStore API
|
|
68
|
+
- **📂 FileManager Module** - Native Android module for opening Downloads folder with multiple fallback strategies
|
|
69
|
+
- **🔧 PDFTextExtractor Utility** - JavaScript wrapper for native text extraction with search capabilities
|
|
70
|
+
- **✅ Enhanced Structure** - Complete src/utils directory with all utility modules
|
|
71
|
+
- **✅ Android 10+ Support** - Scoped Storage compliant with MediaStore API for Android 10+
|
|
72
|
+
- **✅ Legacy Support** - Backward compatible with Android 9 and below using legacy storage
|
|
73
|
+
- **✅ Smart Notifications** - Download completion notifications with "Open Folder" action
|
|
74
|
+
- **✅ Text Search & Statistics** - Advanced text extraction with search and statistics features
|
|
75
|
+
- **✅ Production Ready** - All development features now available in stable release
|
|
76
|
+
|
|
77
|
+
## 🎉 Version 2.2.8 - Android File Download & Management Features!
|
|
78
|
+
|
|
79
|
+
**New Android native modules for file download and folder management with MediaStore API support!**
|
|
80
|
+
|
|
81
|
+
### 🚀 **What's New in v2.2.8:**
|
|
82
|
+
- **📥 FileDownloader Module** - Native Android module for downloading files to public storage using MediaStore API
|
|
83
|
+
- **📂 FileManager Module** - Native Android module for opening Downloads folder with multiple fallback strategies
|
|
84
|
+
- **✅ Android 10+ Support** - Scoped Storage compliant with MediaStore API for Android 10+
|
|
85
|
+
- **✅ Legacy Support** - Backward compatible with Android 9 and below using legacy storage
|
|
86
|
+
- **✅ Smart Notifications** - Download completion notifications with "Open Folder" action
|
|
87
|
+
- **✅ Immediate Visibility** - Files are immediately visible in file managers after export
|
|
88
|
+
- **✅ Multi-Strategy Folder Opening** - Multiple fallback strategies for maximum device compatibility
|
|
89
|
+
|
|
38
90
|
## 🎉 Version 2.2.7 - iOS Codegen Fix & New Architecture Support!
|
|
39
91
|
|
|
40
92
|
**Critical fix for React Native 0.79+ compatibility and iOS codegen integration!**
|
|
@@ -170,9 +222,11 @@ Starting November 1, 2025, Google Play will require apps to support 16KB page si
|
|
|
170
222
|
- **Enhanced Features**: Additional functionality out of the box
|
|
171
223
|
- **Easy Upgrade**: Minimal code changes required
|
|
172
224
|
|
|
173
|
-
## ✨ Features
|
|
225
|
+
## ✨ Features - All FREE!
|
|
226
|
+
|
|
227
|
+
**📚 [Explore All Features in Documentation](https://euphonious-faun-24f4bc.netlify.app/docs/features/core-features)**
|
|
174
228
|
|
|
175
|
-
### Core Features
|
|
229
|
+
### Core Features (FREE)
|
|
176
230
|
* Read a PDF from URL, blob, local file or asset and can cache it
|
|
177
231
|
* Display horizontally or vertically
|
|
178
232
|
* Drag and zoom
|
|
@@ -180,7 +234,7 @@ Starting November 1, 2025, Google Play will require apps to support 16KB page si
|
|
|
180
234
|
* Support password protected PDF
|
|
181
235
|
* Jump to a specific page in the PDF
|
|
182
236
|
|
|
183
|
-
### 🚀 JSI Enhanced Features
|
|
237
|
+
### 🚀 JSI Enhanced Features (FREE)
|
|
184
238
|
* **Zero Bridge Overhead** - Direct JavaScript-to-Native communication
|
|
185
239
|
* **Enhanced Caching** - Multi-level intelligent caching system
|
|
186
240
|
* **Batch Operations** - Process multiple operations efficiently
|
|
@@ -193,167 +247,25 @@ Starting November 1, 2025, Google Play will require apps to support 16KB page si
|
|
|
193
247
|
* **React Hooks** - Easy integration with `usePDFJSI` hook
|
|
194
248
|
* **Enhanced Components** - Drop-in replacement with automatic JSI detection
|
|
195
249
|
|
|
250
|
+
### 🎁 Advanced Features (100% FREE!)
|
|
251
|
+
* **📚 Bookmarks with 10 Colors** - Create, edit, delete bookmarks with custom colors and notes
|
|
252
|
+
* **📊 Reading Analytics** - Track reading sessions, progress, speed, and engagement scores
|
|
253
|
+
* **🖼️ Export to Images** - Export pages to PNG/JPEG with quality control
|
|
254
|
+
* **📝 Export to Text** - Extract text from PDFs with search capabilities
|
|
255
|
+
* **✂️ PDF Operations** - Split, merge, extract, rotate, and delete pages
|
|
256
|
+
* **🗜️ PDF Compression** - Reduce file sizes with 5 smart presets (EMAIL, WEB, MOBILE, PRINT, ARCHIVE)
|
|
257
|
+
* **🔍 Text Extraction** - Extract and search text with statistics and context
|
|
258
|
+
* **📥 File Management** (Android) - Download to public storage, open folders with MediaStore API
|
|
259
|
+
* **🎨 Professional UI Components** - Ready-to-use bookmark, analytics, and export components
|
|
260
|
+
|
|
261
|
+
**All features work immediately - no activation, no license keys, no restrictions!**
|
|
262
|
+
|
|
196
263
|
## 📱 Supported Platforms
|
|
197
264
|
|
|
198
265
|
- ✅ **Android** (with full JSI acceleration - up to 80x faster)
|
|
199
266
|
- ✅ **iOS** (enhanced bridge mode with smart caching and progressive loading)
|
|
200
267
|
- ✅ **Windows** (standard bridge mode)
|
|
201
268
|
|
|
202
|
-
---
|
|
203
|
-
|
|
204
|
-
## 🎬 Pro Features - Coming Soon!
|
|
205
|
-
|
|
206
|
-
> **Production-ready PDF manipulation features launching in the next few weeks!**
|
|
207
|
-
|
|
208
|
-
### Watch the Demo
|
|
209
|
-
|
|
210
|
-
[](https://www.youtube.com/shorts/OmCUq9wLoHo)
|
|
211
|
-
|
|
212
|
-
**[▶️ Watch on YouTube Shorts (60 seconds)](https://www.youtube.com/shorts/OmCUq9wLoHo)**
|
|
213
|
-
|
|
214
|
-
*See bookmark management, export to images, PDF operations, and reading analytics in action!*
|
|
215
|
-
|
|
216
|
-
### 🚀 Features Launching Soon
|
|
217
|
-
|
|
218
|
-
#### 📚 Advanced Bookmark Management
|
|
219
|
-
- ✅ Create bookmarks with custom names, colors (10 options), and notes
|
|
220
|
-
- ✅ Swipeable list with tap-to-navigate functionality
|
|
221
|
-
- ✅ Current page highlighting with visual indicators
|
|
222
|
-
- ✅ Swipe-to-delete with confirmation dialogs
|
|
223
|
-
- ✅ Persistent storage with AsyncStorage
|
|
224
|
-
- ✅ Jump directly to any bookmarked page
|
|
225
|
-
- ✅ Edit bookmarks with full metadata support
|
|
226
|
-
|
|
227
|
-
#### 🖼️ Export to Images
|
|
228
|
-
- ✅ Export PDF pages to PNG or JPEG formats
|
|
229
|
-
- ✅ Three quality levels: High (90%), Medium (75%), Low (50%)
|
|
230
|
-
- ✅ Single page or batch export with progress tracking
|
|
231
|
-
- ✅ Automatic download to public storage (MediaStore API)
|
|
232
|
-
- ✅ Android notifications with "Open Folder" action
|
|
233
|
-
- ✅ Timestamped filenames to prevent overwrites
|
|
234
|
-
- ✅ Share single or multiple exported files
|
|
235
|
-
- ✅ Files immediately visible in file manager
|
|
236
|
-
|
|
237
|
-
#### ✂️ PDF Operations
|
|
238
|
-
- ✅ Split PDF into multiple parts with custom page ranges
|
|
239
|
-
- ✅ Extract specific pages to create new PDF
|
|
240
|
-
- ✅ Merge multiple PDFs (framework ready)
|
|
241
|
-
- ✅ All operations with real-time progress indicators
|
|
242
|
-
- ✅ Auto-save to Downloads/[YourApp] folder
|
|
243
|
-
- ✅ Success dialogs with "Open Folder" and "Share" buttons
|
|
244
|
-
- ✅ Proper file naming with timestamps
|
|
245
|
-
|
|
246
|
-
#### 📊 Reading Analytics
|
|
247
|
-
- ✅ Session tracking (start/end times, duration)
|
|
248
|
-
- ✅ Total time spent reading per PDF
|
|
249
|
-
- ✅ Pages read counter and progress percentage
|
|
250
|
-
- ✅ Reading speed calculation (pages/minute)
|
|
251
|
-
- ✅ Complete session history
|
|
252
|
-
- ✅ AsyncStorage persistence across app restarts
|
|
253
|
-
- ✅ Beautiful analytics panel with real-time stats
|
|
254
|
-
|
|
255
|
-
#### 🔧 Technical Excellence
|
|
256
|
-
- ✅ **JSI Integration** - Leverages existing JSI for native performance
|
|
257
|
-
- ✅ **MediaStore API** - Proper Android file management (Android 10+)
|
|
258
|
-
- ✅ **Runtime Permissions** - Handles Android 13+ notification permissions
|
|
259
|
-
- ✅ **Gesture-Based UI** - PanResponder for swipe gestures
|
|
260
|
-
- ✅ **Material Design** - Professional UI components
|
|
261
|
-
- ✅ **Error Handling** - Comprehensive error recovery
|
|
262
|
-
- ✅ **TypeScript Support** - Full type definitions included
|
|
263
|
-
- ✅ **Production Logging** - Debug-friendly with detailed logs
|
|
264
|
-
|
|
265
|
-
### 💰 Pricing
|
|
266
|
-
|
|
267
|
-
| Plan | Target Users | India Price | Global Price | What's Included |
|
|
268
|
-
|------|--------------|-------------|--------------|-----------------|
|
|
269
|
-
| **Free** | Everyone | ₹0 | $0 | ✅ Basic PDF viewing<br>✅ All core features<br>✅ Community support |
|
|
270
|
-
| **Indie** | Freelancers, Students | **₹2,999/year**<br>($36/year) | **$99/year** | ✅ All Pro features<br>✅ 1 app license<br>✅ Unlimited updates<br>✅ Email support<br>✅ Perfect for freelance projects |
|
|
271
|
-
| **Startup** | Small Teams (2-10 devs) | **₹9,999/year**<br>($120/year) | **$299/year** | ✅ All Pro features<br>✅ Up to 5 apps<br>✅ Priority email support<br>✅ Team license<br>✅ Quarterly feature updates |
|
|
272
|
-
| **Business** | Companies (10+ devs) | **₹24,999/year**<br>($300/year) | **$799/year** | ✅ All Pro features<br>✅ Unlimited apps<br>✅ Priority support (24h response)<br>✅ Custom feature development<br>✅ Source code access option |
|
|
273
|
-
|
|
274
|
-
**🇮🇳 Regional Pricing Available** - Special rates for India, Southeast Asia, Latin America, and emerging markets.
|
|
275
|
-
|
|
276
|
-
**🎁 Launch Offer:** First 50 customers get **30% OFF** any plan! Use code `EARLYBIRD30` at checkout.
|
|
277
|
-
|
|
278
|
-
### 🎯 Early Access
|
|
279
|
-
|
|
280
|
-
**🚀 Launching in the next few weeks!**
|
|
281
|
-
|
|
282
|
-
Want early access or have questions about Pro features?
|
|
283
|
-
|
|
284
|
-
- 📧 **Email:** punithm300@gmail.com (Subject: "Pro Features Early Access")
|
|
285
|
-
- ⭐ **Star this repo** to get notified when we launch
|
|
286
|
-
- 🔔 **Watch** the repository for release announcements
|
|
287
|
-
- 📦 **GitHub:** [react-native-enhanced-pdf](https://github.com/126punith/react-native-enhanced-pdf)
|
|
288
|
-
- 📥 **NPM:** [react-native-pdf-jsi](https://www.npmjs.com/package/react-native-pdf-jsi)
|
|
289
|
-
|
|
290
|
-
### ✨ Why Choose Pro Features?
|
|
291
|
-
|
|
292
|
-
> **Unlike other React Native PDF libraries**, we offer true production-grade features with professional UX patterns, proper file management, and enterprise-level performance.
|
|
293
|
-
|
|
294
|
-
**What makes it different:**
|
|
295
|
-
|
|
296
|
-
| Feature | react-native-pdf-jsi Pro | Other Libraries |
|
|
297
|
-
|---------|--------------------------|-----------------|
|
|
298
|
-
| **File Management** | MediaStore API (files visible immediately) | Cache only (files hidden) |
|
|
299
|
-
| **Bookmarks** | Colors, notes, swipeable list | Basic or none |
|
|
300
|
-
| **Export** | PNG/JPEG with quality control | Limited or none |
|
|
301
|
-
| **PDF Operations** | Split, extract, merge with UI | None |
|
|
302
|
-
| **Analytics** | Full session tracking & history | Page count only |
|
|
303
|
-
| **Notifications** | Native Android notifications | None |
|
|
304
|
-
| **Gestures** | Swipe-to-delete, tap-to-navigate | None |
|
|
305
|
-
| **Share** | Batch sharing with dialogs | Basic or none |
|
|
306
|
-
|
|
307
|
-
**Technical Advantages:**
|
|
308
|
-
- 🚀 **Up to 80x faster** with existing JSI integration
|
|
309
|
-
- 📱 **Proper file storage** - Files appear in Downloads immediately
|
|
310
|
-
- 🎨 **Professional UI** - Material Design with animations
|
|
311
|
-
- 🔔 **System integration** - Notifications, intents, MediaStore
|
|
312
|
-
- 💪 **Battle-tested** - Production-ready code
|
|
313
|
-
- 📖 **Complete docs** - Integration guides included
|
|
314
|
-
|
|
315
|
-
### 🎬 Feature Highlights from Demo
|
|
316
|
-
|
|
317
|
-
**What you'll see in the [60-second demo](https://www.youtube.com/shorts/OmCUq9wLoHo):**
|
|
318
|
-
|
|
319
|
-
1. **Bookmark System** (0:00-0:20)
|
|
320
|
-
- Create bookmark with name, color & notes
|
|
321
|
-
- Swipeable list showing all bookmarks
|
|
322
|
-
- Tap to jump to page 4 → 11 instantly
|
|
323
|
-
- Swipe left to delete
|
|
324
|
-
|
|
325
|
-
2. **Export to Images** (0:20-0:35)
|
|
326
|
-
- Export page as PNG (high quality)
|
|
327
|
-
- Android notification appears
|
|
328
|
-
- File visible in Downloads folder
|
|
329
|
-
- Share exported image
|
|
330
|
-
|
|
331
|
-
3. **PDF Operations** (0:35-0:50)
|
|
332
|
-
- Split PDF into 2 parts (pages 1-10, 11-21)
|
|
333
|
-
- Files automatically downloaded
|
|
334
|
-
- "Open Folder" button works
|
|
335
|
-
|
|
336
|
-
4. **Reading Analytics** (0:50-1:00)
|
|
337
|
-
- Session tracking active
|
|
338
|
-
- Progress percentage shown
|
|
339
|
-
- Reading stats displayed
|
|
340
|
-
|
|
341
|
-
### 📢 Stay Updated
|
|
342
|
-
|
|
343
|
-
**Coming Soon:**
|
|
344
|
-
- 📖 Comprehensive documentation
|
|
345
|
-
- 🎥 Tutorial videos
|
|
346
|
-
- 📱 Example app repository
|
|
347
|
-
- 🔌 Integration templates
|
|
348
|
-
- 💬 Discord community
|
|
349
|
-
|
|
350
|
-
**Follow the journey:**
|
|
351
|
-
- 🐦 Twitter: Share your feedback!
|
|
352
|
-
- ⭐ GitHub Stars help us reach more developers
|
|
353
|
-
- 📧 Direct contact: punithm300@gmail.com
|
|
354
|
-
|
|
355
|
-
---
|
|
356
|
-
|
|
357
269
|
## 🛠 Installation
|
|
358
270
|
|
|
359
271
|
```bash
|
|
@@ -364,8 +276,12 @@ npm install react-native-pdf-jsi react-native-blob-util --save
|
|
|
364
276
|
yarn add react-native-pdf-jsi react-native-blob-util
|
|
365
277
|
```
|
|
366
278
|
|
|
279
|
+
**📚 Need help?** Check our [complete installation guide](https://euphonious-faun-24f4bc.netlify.app/docs/getting-started/installation) with platform-specific instructions.
|
|
280
|
+
|
|
367
281
|
## 🚀 **Quick Start**
|
|
368
282
|
|
|
283
|
+
**📚 [See Quick Start Guide](https://euphonious-faun-24f4bc.netlify.app/docs/getting-started/quick-start)** for detailed instructions and more examples.
|
|
284
|
+
|
|
369
285
|
```jsx
|
|
370
286
|
// Import the Pdf component from react-native-pdf-jsi
|
|
371
287
|
const PdfModule = require('react-native-pdf-jsi');
|
|
@@ -436,7 +352,7 @@ react-native link react-native-pdf-jsi
|
|
|
436
352
|
|
|
437
353
|
### Windows installation
|
|
438
354
|
<details>
|
|
439
|
-
<
|
|
355
|
+
<sumary>Windows details</summary>
|
|
440
356
|
|
|
441
357
|
- Open your solution in Visual Studio 2019 (eg. `windows\yourapp.sln`)
|
|
442
358
|
- Right-click Solution icon in Solution Explorer > Add > Existing Project...
|
|
@@ -500,6 +416,8 @@ protected List<ReactPackage> getPackages() {
|
|
|
500
416
|
|
|
501
417
|
## 📖 Usage
|
|
502
418
|
|
|
419
|
+
**📚 [View Complete Documentation](https://euphonious-faun-24f4bc.netlify.app/)** - Detailed guides, API reference, and working examples
|
|
420
|
+
|
|
503
421
|
### Basic Usage
|
|
504
422
|
|
|
505
423
|
```jsx
|
|
@@ -851,6 +769,213 @@ export default function AdvancedJSIExample() {
|
|
|
851
769
|
}
|
|
852
770
|
```
|
|
853
771
|
|
|
772
|
+
## 📥 **Android File Download & Management** (v2.2.8+)
|
|
773
|
+
|
|
774
|
+
The new Android native modules provide seamless file download and folder management capabilities with full Android 10+ Scoped Storage support.
|
|
775
|
+
|
|
776
|
+
### FileDownloader Module
|
|
777
|
+
|
|
778
|
+
Download files to public storage with automatic MediaStore API integration for Android 10+ and legacy support for older versions.
|
|
779
|
+
|
|
780
|
+
#### **Features:**
|
|
781
|
+
- ✅ **MediaStore API Support** - Android 10+ Scoped Storage compliant
|
|
782
|
+
- ✅ **Legacy Storage** - Backward compatible with Android 9 and below
|
|
783
|
+
- ✅ **Instant Visibility** - Files appear immediately in file managers
|
|
784
|
+
- ✅ **Smart Notifications** - Download completion notifications with "Open Folder" action
|
|
785
|
+
- ✅ **Multiple Formats** - Supports PDF, PNG, and JPEG files
|
|
786
|
+
|
|
787
|
+
#### **Usage:**
|
|
788
|
+
|
|
789
|
+
```jsx
|
|
790
|
+
import { NativeModules } from 'react-native';
|
|
791
|
+
const { FileDownloader } = NativeModules;
|
|
792
|
+
|
|
793
|
+
// Download a file to public Downloads/PDFDemoApp folder
|
|
794
|
+
const downloadFile = async () => {
|
|
795
|
+
try {
|
|
796
|
+
const sourcePath = '/path/to/cached/file.pdf';
|
|
797
|
+
const fileName = 'my-document.pdf';
|
|
798
|
+
const mimeType = 'application/pdf'; // or 'image/png', 'image/jpeg'
|
|
799
|
+
|
|
800
|
+
const publicPath = await FileDownloader.downloadToPublicFolder(
|
|
801
|
+
sourcePath,
|
|
802
|
+
fileName,
|
|
803
|
+
mimeType
|
|
804
|
+
);
|
|
805
|
+
|
|
806
|
+
console.log('✅ File downloaded to:', publicPath);
|
|
807
|
+
// Android 10+: /storage/emulated/0/Download/PDFDemoApp/my-document.pdf
|
|
808
|
+
|
|
809
|
+
} catch (error) {
|
|
810
|
+
console.error('❌ Download failed:', error);
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
#### **API:**
|
|
816
|
+
|
|
817
|
+
```typescript
|
|
818
|
+
FileDownloader.downloadToPublicFolder(
|
|
819
|
+
sourcePath: string, // Path to source file in app's cache/internal storage
|
|
820
|
+
fileName: string, // Desired file name
|
|
821
|
+
mimeType: string // MIME type: 'application/pdf', 'image/png', 'image/jpeg'
|
|
822
|
+
): Promise<string> // Returns public file path
|
|
823
|
+
```
|
|
824
|
+
|
|
825
|
+
#### **How It Works:**
|
|
826
|
+
- **Android 10+**: Uses MediaStore API to create entries in the Downloads collection with proper visibility
|
|
827
|
+
- **Android 9 and below**: Uses legacy `Environment.getExternalStoragePublicDirectory()` with media scanner
|
|
828
|
+
- **Automatic folder creation**: Creates `Downloads/PDFDemoApp` folder if it doesn't exist
|
|
829
|
+
- **Progress notifications**: Shows notification with "Open Folder" action when download completes
|
|
830
|
+
|
|
831
|
+
### FileManager Module
|
|
832
|
+
|
|
833
|
+
Open the Downloads folder with multiple fallback strategies for maximum compatibility across Android devices.
|
|
834
|
+
|
|
835
|
+
#### **Features:**
|
|
836
|
+
- ✅ **Multi-Strategy Opening** - 4 different fallback strategies
|
|
837
|
+
- ✅ **Maximum Compatibility** - Works with various file manager apps
|
|
838
|
+
- ✅ **Graceful Degradation** - Automatically tries next strategy if one fails
|
|
839
|
+
- ✅ **User-Friendly** - Opens specific folder or general file manager
|
|
840
|
+
|
|
841
|
+
#### **Usage:**
|
|
842
|
+
|
|
843
|
+
```jsx
|
|
844
|
+
import { NativeModules, Alert } from 'react-native';
|
|
845
|
+
const { FileManager } = NativeModules;
|
|
846
|
+
|
|
847
|
+
// Open Downloads/PDFDemoApp folder
|
|
848
|
+
const openFolder = async () => {
|
|
849
|
+
try {
|
|
850
|
+
await FileManager.openDownloadsFolder();
|
|
851
|
+
console.log('✅ Folder opened successfully');
|
|
852
|
+
} catch (error) {
|
|
853
|
+
// All strategies failed - no file manager available
|
|
854
|
+
Alert.alert(
|
|
855
|
+
'Info',
|
|
856
|
+
'Please check Downloads/PDFDemoApp folder in your file manager'
|
|
857
|
+
);
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
#### **API:**
|
|
863
|
+
|
|
864
|
+
```typescript
|
|
865
|
+
FileManager.openDownloadsFolder(): Promise<boolean>
|
|
866
|
+
```
|
|
867
|
+
|
|
868
|
+
#### **Fallback Strategies:**
|
|
869
|
+
1. **Strategy 1**: Opens specific `Downloads/PDFDemoApp` folder via DocumentsUI
|
|
870
|
+
2. **Strategy 2**: Opens system Downloads app
|
|
871
|
+
3. **Strategy 3**: Opens generic Files app
|
|
872
|
+
4. **Strategy 4**: Shows file picker to let user choose file manager
|
|
873
|
+
|
|
874
|
+
### Complete Example: Export and Download PDF Pages
|
|
875
|
+
|
|
876
|
+
```jsx
|
|
877
|
+
import React, { useState } from 'react';
|
|
878
|
+
import { View, Button, Alert, NativeModules } from 'react-native';
|
|
879
|
+
|
|
880
|
+
const { PDFExporter, FileDownloader, FileManager } = NativeModules;
|
|
881
|
+
|
|
882
|
+
const ExportAndDownload = () => {
|
|
883
|
+
const [exporting, setExporting] = useState(false);
|
|
884
|
+
|
|
885
|
+
const exportAndDownloadPages = async (pdfPath, pageNumbers) => {
|
|
886
|
+
setExporting(true);
|
|
887
|
+
|
|
888
|
+
try {
|
|
889
|
+
// Step 1: Export pages to images
|
|
890
|
+
const exportedImages = [];
|
|
891
|
+
for (let page of pageNumbers) {
|
|
892
|
+
const imagePath = await PDFExporter.exportPageToImage(
|
|
893
|
+
pdfPath,
|
|
894
|
+
page - 1, // Convert to 0-indexed
|
|
895
|
+
{
|
|
896
|
+
format: 'png',
|
|
897
|
+
quality: 0.9,
|
|
898
|
+
scale: 2.0
|
|
899
|
+
}
|
|
900
|
+
);
|
|
901
|
+
exportedImages.push(imagePath);
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
// Step 2: Download to public storage
|
|
905
|
+
const downloadedFiles = [];
|
|
906
|
+
for (let i = 0; i < exportedImages.length; i++) {
|
|
907
|
+
const publicPath = await FileDownloader.downloadToPublicFolder(
|
|
908
|
+
exportedImages[i],
|
|
909
|
+
`page-${pageNumbers[i]}.png`,
|
|
910
|
+
'image/png'
|
|
911
|
+
);
|
|
912
|
+
downloadedFiles.push(publicPath);
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
setExporting(false);
|
|
916
|
+
|
|
917
|
+
// Step 3: Show success and offer to open folder
|
|
918
|
+
Alert.alert(
|
|
919
|
+
'✅ Export Complete',
|
|
920
|
+
`${downloadedFiles.length} pages saved to Downloads/PDFDemoApp`,
|
|
921
|
+
[
|
|
922
|
+
{ text: 'Done', style: 'cancel' },
|
|
923
|
+
{
|
|
924
|
+
text: 'Open Folder',
|
|
925
|
+
onPress: async () => {
|
|
926
|
+
try {
|
|
927
|
+
await FileManager.openDownloadsFolder();
|
|
928
|
+
} catch (e) {
|
|
929
|
+
Alert.alert('Info', 'Check Downloads/PDFDemoApp folder');
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
]
|
|
934
|
+
);
|
|
935
|
+
|
|
936
|
+
} catch (error) {
|
|
937
|
+
setExporting(false);
|
|
938
|
+
Alert.alert('Export Failed', error.message);
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
|
|
942
|
+
return (
|
|
943
|
+
<View>
|
|
944
|
+
<Button
|
|
945
|
+
title={exporting ? 'Exporting...' : 'Export Pages 1-3'}
|
|
946
|
+
onPress={() => exportAndDownloadPages('/path/to/file.pdf', [1, 2, 3])}
|
|
947
|
+
disabled={exporting}
|
|
948
|
+
/>
|
|
949
|
+
</View>
|
|
950
|
+
);
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
export default ExportAndDownload;
|
|
954
|
+
```
|
|
955
|
+
|
|
956
|
+
### Android Permissions
|
|
957
|
+
|
|
958
|
+
For Android 10+ (API 29+), the MediaStore API doesn't require `WRITE_EXTERNAL_STORAGE` permission for adding files to public Downloads folder. However, for Android 9 and below, you may need to add:
|
|
959
|
+
|
|
960
|
+
```xml
|
|
961
|
+
<!-- android/app/src/main/AndroidManifest.xml -->
|
|
962
|
+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
|
|
963
|
+
```
|
|
964
|
+
|
|
965
|
+
### Customization
|
|
966
|
+
|
|
967
|
+
You can customize the folder name by modifying the `FOLDER_NAME` constant in the native modules:
|
|
968
|
+
|
|
969
|
+
```java
|
|
970
|
+
// android/src/main/java/org/wonday/pdf/FileDownloader.java
|
|
971
|
+
private static final String FOLDER_NAME = "YourAppName"; // Change this
|
|
972
|
+
```
|
|
973
|
+
|
|
974
|
+
```java
|
|
975
|
+
// android/src/main/java/org/wonday/pdf/FileManager.java
|
|
976
|
+
private static final String FOLDER_NAME = "YourAppName"; // Change this
|
|
977
|
+
```
|
|
978
|
+
|
|
854
979
|
## 🛡️ **ProGuard Configuration (Required for Production)**
|
|
855
980
|
|
|
856
981
|
**IMPORTANT**: For production builds, you MUST add ProGuard rules to prevent obfuscation of JSI classes. Without these rules, your app will crash in release mode.
|
|
@@ -979,10 +1104,10 @@ This package is not available in the [Expo Go](https://expo.dev/client) app. Lea
|
|
|
979
1104
|
<summary>FAQ details</summary>
|
|
980
1105
|
|
|
981
1106
|
Q1. After installation and running, I can not see the pdf file.
|
|
982
|
-
A1: maybe you forgot to
|
|
1107
|
+
A1: maybe you forgot to excute ```react-native link``` or it does not run correctly.
|
|
983
1108
|
You can add it manually. For detail you can see the issue [`#24`](https://github.com/wonday/react-native-pdf/issues/24) and [`#2`](https://github.com/wonday/react-native-pdf/issues/2)
|
|
984
1109
|
|
|
985
|
-
Q2. When running, it shows ```'Pdf' has no propType for native prop RCTPdf.
|
|
1110
|
+
Q2. When running, it shows ```'Pdf' has no propType for native prop RCTPdf.acessibilityLabel of native type 'String'```
|
|
986
1111
|
A2. Your react-native version is too old, please upgrade it to 0.47.0+ see also [`#39`](https://github.com/wonday/react-native-pdf/issues/39)
|
|
987
1112
|
|
|
988
1113
|
Q3. When I run the example app I get a white/gray screen / the loading bar isn't progressing .
|
|
@@ -1625,10 +1750,10 @@ export default function LazyLoadingExample() {
|
|
|
1625
1750
|
| style | object | {backgroundColor:"#eee"} | support normal view style, you can use this to set border/spacing color... | ✔ | ✔ | ✔ | <3.0
|
|
1626
1751
|
| progressContainerStyle | object | {backgroundColor:"#eee"} | support normal view style, you can use this to set border/spacing color... | ✔ | ✔ | ✔ | 6.9.0 |
|
|
1627
1752
|
| renderActivityIndicator | (progress) => Component | <ProgressBar/> | when loading show it as an indicator, you can use your component | ✔ | ✔ | ✖ | <3.0 |
|
|
1628
|
-
| enableAntialiasing | bool | true | improve rendering a little bit on low-res screens, but
|
|
1753
|
+
| enableAntialiasing | bool | true | improve rendering a little bit on low-res screens, but maybe course some problem on Android 4.4, so add a switch | ✖ | ✔ | ✖ | <3.0 |
|
|
1629
1754
|
| enablePaging | bool | false | only show one page in screen | ✔ | ✔ | ✔ | 5.0.1 |
|
|
1630
1755
|
| enableRTL | bool | false | scroll page as "page3, page2, page1" | ✔ | ✖ | ✔ | 5.0.1 |
|
|
1631
|
-
| enableAnnotationRendering | bool | true | enable rendering annotation, notice:
|
|
1756
|
+
| enableAnnotationRendering | bool | true | enable rendering annotation, notice:iOS only support initial setting,not support realtime changing | ✔ | ✔ | ✖ | 5.0.3 |
|
|
1632
1757
|
| enableDoubleTapZoom | bool | true | Enable double tap to zoom gesture | ✔ | ✔ | ✖ | 6.8.0 |
|
|
1633
1758
|
| trustAllCerts | bool | true | Allow connections to servers with self-signed certification | ✔ | ✔ | ✖ | 6.0.? |
|
|
1634
1759
|
| singlePage | bool | false | Only show first page, useful for thumbnail views | ✔ | ✔ | ✔ | 6.2.1 |
|
|
@@ -1644,7 +1769,7 @@ export default function LazyLoadingExample() {
|
|
|
1644
1769
|
|
|
1645
1770
|
| parameter | Description | default | iOS | Android | Windows |
|
|
1646
1771
|
| ------------ | ----------- | ------- | --- | ------- | ------- |
|
|
1647
|
-
| uri | pdf source, see the
|
|
1772
|
+
| uri | pdf source, see the forllowing for detail.| required | ✔ | ✔ | ✔ |
|
|
1648
1773
|
| cache | use cache or not | false | ✔ | ✔ | ✖ |
|
|
1649
1774
|
| cacheFileName | specific file name for cached pdf file | SHA1(uri) result | ✔ | ✔ | ✖ |
|
|
1650
1775
|
| expiration | cache file expired seconds (0 is not expired) | 0 | ✔ | ✔ | ✖ |
|
|
@@ -1734,11 +1859,20 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|
|
1734
1859
|
|
|
1735
1860
|
## 📞 Support
|
|
1736
1861
|
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
-
|
|
1741
|
-
-
|
|
1862
|
+
**📚 Documentation Website**: https://euphonious-faun-24f4bc.netlify.app/
|
|
1863
|
+
|
|
1864
|
+
Get help with:
|
|
1865
|
+
- **📖 Complete Guides**: https://euphonious-faun-24f4bc.netlify.app/docs/getting-started/installation
|
|
1866
|
+
- **🔧 API Reference**: https://euphonious-faun-24f4bc.netlify.app/docs/api/pdf-component
|
|
1867
|
+
- **💡 Working Examples**: https://euphonious-faun-24f4bc.netlify.app/docs/examples/basic-viewer
|
|
1868
|
+
- **🐛 GitHub Issues**: https://github.com/126punith/react-native-enhanced-pdf/issues
|
|
1869
|
+
- **💬 Discussions**: https://github.com/126punith/react-native-enhanced-pdf/discussions
|
|
1870
|
+
- **📧 Email**: punithm300@gmail.com
|
|
1871
|
+
|
|
1872
|
+
For bug reports, include:
|
|
1873
|
+
- JSI stats and performance history
|
|
1874
|
+
- CMake logs and Android NDK version
|
|
1875
|
+
- Platform and React Native version
|
|
1742
1876
|
|
|
1743
1877
|
---
|
|
1744
1878
|
|
|
@@ -1747,4 +1881,6 @@ For issues and questions:
|
|
|
1747
1881
|
*Transform your PDF viewing experience with enterprise-grade performance and reliability.*
|
|
1748
1882
|
|
|
1749
1883
|
**v2.2.7 - iOS Codegen Fix & New Architecture Support**
|
|
1750
|
-
**Copyright (c) 2025-present, Punith M (punithm300@gmail.com). All rights reserved.**
|
|
1884
|
+
**Copyright (c) 2025-present, Punith M (punithm300@gmail.com). Enhanced PDF JSI Integration. All rights reserved.**
|
|
1885
|
+
|
|
1886
|
+
*Original work Copyright (c) 2017-present, Wonday (@wonday.org). All rights reserved.*
|