Skip to main content

🎉 What's New in v3.0.0

Version 3.0.0 is a major release that brings complete feature parity between development and production packages, along with powerful new utilities for PDF text extraction and Android file management.

🚀 Major Features

1. PDFTextExtractor Utility

A comprehensive JavaScript wrapper for native PDF text extraction with advanced search capabilities.

import PDFTextExtractor from 'react-native-pdf-jsi/src/utils/PDFTextExtractor';

// Extract all text from PDF
const textMap = await PDFTextExtractor.extractAllText(filePath);
console.log(textMap);
// Output: { 0: "Page 1 text...", 1: "Page 2 text...", ... }

// Extract from specific pages
const pageText = await PDFTextExtractor.extractTextFromPage(filePath, 0);

// Search within PDF
const results = await PDFTextExtractor.searchText(filePath, 'search term', {
caseSensitive: false
});
// Returns: [{ page: 0, position: 123, context: "...search term..." }]

// Get statistics
const stats = await PDFTextExtractor.getTextStatistics(filePath);
console.log(stats);
// {
// totalPages: 10,
// totalCharacters: 50000,
// totalWords: 8500,
// averageWordsPerPage: 850,
// averageCharactersPerPage: 5000
// }

Features:

  • ✅ Extract text from all pages or specific pages
  • ✅ Single page text extraction
  • ✅ Advanced search with context snippets
  • ✅ Case-sensitive and case-insensitive search
  • ✅ Text statistics (word count, character count)
  • ✅ Search result positioning

2. FileDownloader Module (Android)

Native Android module for downloading files to public storage with MediaStore API support.

import { NativeModules } from 'react-native';
const { FileDownloader } = NativeModules;

// Download file to public Downloads/PDFDemoApp folder
const publicPath = await FileDownloader.downloadToPublicFolder(
sourcePath, // Path in cache/internal storage
'document.pdf',
'application/pdf' // or 'image/png', 'image/jpeg'
);

console.log('✅ Downloaded to:', publicPath);
// Android 10+: /storage/emulated/0/Download/PDFDemoApp/document.pdf

Features:

  • MediaStore API support for Android 10+ (Scoped Storage compliant)
  • Legacy storage support for Android 9 and below
  • Automatic folder creation (Downloads/PDFDemoApp)
  • Smart notifications with "Open Folder" action
  • Immediate visibility in file managers
  • ✅ Supports PDF, PNG, and JPEG files

Supported MIME Types:

  • application/pdf - PDF documents
  • image/png - PNG images
  • image/jpeg - JPEG images

3. FileManager Module (Android)

Native Android module for opening folders with multiple fallback strategies.

import { NativeModules, Alert } from 'react-native';
const { FileManager } = NativeModules;

// Open Downloads/PDFDemoApp folder
try {
await FileManager.openDownloadsFolder();
console.log('✅ Folder opened successfully');
} catch (error) {
Alert.alert('Info', 'Please check Downloads/PDFDemoApp folder');
}

Features:

  • Multi-strategy opening - 4 different fallback strategies
  • Maximum compatibility - Works with various file manager apps
  • Graceful degradation - Automatically tries next strategy if one fails
  • User-friendly - Opens specific folder or general file manager

Fallback Strategies:

  1. Opens specific Downloads/PDFDemoApp folder via DocumentsUI
  2. Opens system Downloads app
  3. Opens generic Files app
  4. Shows file picker for user to choose file manager

💡 Complete Example: Export & Download

Here's a complete example showing how to export PDF pages and download them to public storage:

import React, { useState } from 'react';
import { View, Button, Alert, NativeModules } from 'react-native';

const { PDFExporter, FileDownloader, FileManager } = NativeModules;

const ExportAndDownload = ({ pdfPath }) => {
const [exporting, setExporting] = useState(false);

const exportAndDownloadPages = async (pageNumbers) => {
setExporting(true);

try {
// Step 1: Export pages to images
const exportedImages = [];
for (let page of pageNumbers) {
const imagePath = await PDFExporter.exportPageToImage(
pdfPath,
page - 1, // Convert to 0-indexed
{
format: 'png',
quality: 0.9,
scale: 2.0
}
);
exportedImages.push(imagePath);
}

// Step 2: Download to public storage
const downloadedFiles = [];
for (let i = 0; i < exportedImages.length; i++) {
const publicPath = await FileDownloader.downloadToPublicFolder(
exportedImages[i],
`page-${pageNumbers[i]}.png`,
'image/png'
);
downloadedFiles.push(publicPath);
}

setExporting(false);

// Step 3: Show success and offer to open folder
Alert.alert(
'✅ Export Complete',
`${downloadedFiles.length} pages saved to Downloads/PDFDemoApp`,
[
{ text: 'Done', style: 'cancel' },
{
text: 'Open Folder',
onPress: async () => {
try {
await FileManager.openDownloadsFolder();
} catch (e) {
Alert.alert('Info', 'Check Downloads/PDFDemoApp folder');
}
}
}
]
);

} catch (error) {
setExporting(false);
Alert.alert('Export Failed', error.message);
}
};

return (
<View>
<Button
title={exporting ? 'Exporting...' : 'Export Pages 1-3'}
onPress={() => exportAndDownloadPages([1, 2, 3])}
disabled={exporting}
/>
</View>
);
};

export default ExportAndDownload;

🔧 Build Fixes Included

This release includes all Android build fixes from the development package:

Fixed Compilation Errors:

  1. threadPool.poolSize() → Removed invalid call
  2. getBitmapFromPool() → Used Bitmap.createBitmap()
  3. recycleBitmap() → Used bitmap.recycle()
  4. page.render(Canvas) → Fixed to render to Bitmap (3 locations in PDFExporter.java)

Updated Files:

  • PDFExporter.java (768 lines) - Complete with all fixes
  • LicenseVerifier.java (311 lines) - Updated implementation
  • PDFCompressor.java (729 lines) - Build optimizations

📦 Installation

# Using npm
npm install react-native-pdf-jsi@3.0.0 react-native-blob-util

# or using yarn
yarn add react-native-pdf-jsi@3.0.0 react-native-blob-util

# iOS - run pod install
cd ios && pod install

🔄 Migration Guide

Good News: This is a feature-additive release with NO breaking changes!

From v2.2.8 to v3.0.0

No code changes required
All existing APIs remain compatible
New features are additive

Simply upgrade:

npm install react-native-pdf-jsi@3.0.0

New Features You Can Use

// 1. Text Extraction (NEW!)
import PDFTextExtractor from 'react-native-pdf-jsi/src/utils/PDFTextExtractor';
const text = await PDFTextExtractor.extractAllText(filePath);

// 2. File Download (Android, if not using already)
import { NativeModules } from 'react-native';
const { FileDownloader } = NativeModules;
await FileDownloader.downloadToPublicFolder(path, name, mime);

// 3. Folder Management (Android)
const { FileManager } = NativeModules;
await FileManager.openDownloadsFolder();

📱 Android Permissions

Android 10+ (API 29+)

No permissions required! MediaStore API doesn't need WRITE_EXTERNAL_STORAGE for adding files to public Downloads folder.

Android 9 and Below

Add to AndroidManifest.xml:

<uses-permission 
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28"
/>

🎨 TypeScript Support

Full TypeScript definitions included:

// PDFTextExtractor
interface PDFTextExtractorStatic {
isTextExtractionAvailable(): Promise<boolean>;
extractAllText(filePath: string): Promise<{[page: number]: string}>;
extractTextFromPages(filePath: string, pageNumbers: number[]): Promise<{[page: number]: string}>;
extractTextFromPage(filePath: string, pageNumber: number): Promise<string>;
searchText(
filePath: string,
searchQuery: string,
options?: { caseSensitive?: boolean }
): Promise<Array<{
page: number;
position: number;
context: string;
}>>;
getTextStatistics(filePath: string): Promise<{
totalPages: number;
totalCharacters: number;
totalWords: number;
averageWordsPerPage: number;
averageCharactersPerPage: number;
}>;
}

// FileDownloader (Android)
interface FileDownloaderStatic {
downloadToPublicFolder(
sourcePath: string,
fileName: string,
mimeType: 'application/pdf' | 'image/png' | 'image/jpeg' | string
): Promise<string>;
}

// FileManager (Android)
interface FileManagerStatic {
openDownloadsFolder(): Promise<boolean>;
}

🌟 Why Version 3.0.0?

This major version bump signifies:

  1. Complete Feature Parity - Development and production packages fully aligned
  2. Major Milestone - All planned core features now available
  3. Stable Foundation - Ready for production use at scale
  4. Comprehensive Feature Set - Everything from text extraction to file management
  5. No Breaking Changes - Despite major version, fully backward compatible

📊 Performance

  • Text Extraction: ~50-100ms per page
  • Search: ~80ms per page (with caching)
  • File Download: < 1s for typical images/docs
  • Memory Usage: Minimal - streaming with 8KB buffers
  • JSI Acceleration: Up to 80x faster than bridge

🔗 Learn More


🙏 Credits

Author: Punith M (@126punith)
Repository: react-native-enhanced-pdf
NPM: react-native-pdf-jsi


Enjoy react-native-pdf-jsi v3.0.0! 🚀