Skip to content

📄 PDF reader in JavaScript only for Expo - Android & iOS capable

License

Notifications You must be signed in to change notification settings

xcarpentier/rn-pdf-reader-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDF reader for Expo

Android support 🚀





npm version

💥 DEMO 💥

Read a PDF just with JS (no native libs needed)

Example

import React from 'react';
import { StyleSheet, View } from 'react-native';
import PDFReader from 'rn-pdf-reader-js';
import { Constants } from 'expo';

export default class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <PDFReader
          source={{ uri: "http://gahp.net/wp-content/uploads/2017/09/sample.pdf" }}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    paddingTop: Constants.statusBarHeight,
    backgroundColor: '#ecf0f1',
  },
});

Props

  • source: Object
    • uri?: string - can be local or served on the web (ie. start withs https:// or file://)
    • base64?: string - should start with data

Requirements

  • Use it into Expo app (from expo client, Standalone app or ExpoKit app).
  • Because we need to have access to Expo.FileSystem

Features

  • For Android, use react-pdf / pdfjs in the webview
  • For iOS devices, display file directly to the WebView

What rn-pdf-reader-js use

  • react-pdf (pdf.js)
  • WebView
  • Expo FileSystem API
  • Base64