1.1.3 • Published 7 months ago

@zachlove/expo-pdf-reader v1.1.3

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

expo-pdf-reader

A wrapper around Xavier Carpentier's rn-pdf-reader-js that gracefully degrades in the web

Simply import PDFReader from '@zachlove/expo-pdf-reader' instead of 'rn-pdf-reader-js'. In the web, the component gracefully degrades to an object that uses the browser built-in PDF viewer if available. While much more limited, this allows Expo to preview the app in a browser without errors.

This is for development purposes only. Projects that need a proper PDF viewer for the web should use better solutions like React-PDF instead.

Peer dependencies

{
    "expo": "45.0.0",
    "expo-constants": "13.1.1",
    "expo-file-system": "14.0.0",
    "react": "17.0.2",
    "react-native": "0.68.2",
    "react-native-webview": "11.18.1",
    "rn-pdf-reader-js": "4.1.1"
}

Install

With npm:

npm install @zachlove/expo-pdf-reader

With yarn:

yarn add @zachlove/expo-pdf-reader

With expo:

expo install @zachlove/expo-pdf-reader

If using Expo, add the module to webpack.config.js:

const createExpoWebpackConfigAsync = require('@expo/webpack-config');

module.exports = async function (env, argv) {
    const config = await createExpoWebpackConfigAsync({
        ...env,
        babel: {
            dangerouslyAddModulePathsToTranspile: [
                '@zachlove/expo-pdf-reader',
            ],
        },
    }, argv);
    return config;
};

If webpack.config.js does not exist, create it with:

expo customize:web

Example

import React from 'react';

import PDFReader from '@zachlove/expo-pdf-reader';

export default function MyComponent(props) {
    return (
        <PDFReader source={{ uri: 'uri/to/a/pdf' }} />
    );
}
1.1.3

7 months ago

1.1.2

7 months ago

1.1.1

7 months ago

1.1.0

7 months ago

1.0.28

7 months ago

1.0.27

7 months ago

1.0.26

7 months ago

1.0.25

7 months ago

1.0.24

7 months ago

1.0.23

7 months ago

1.0.22

7 months ago

1.0.21

7 months ago

1.0.20

7 months ago

1.0.19

7 months ago

1.0.18

7 months ago

1.0.17

7 months ago

1.0.16

7 months ago

1.0.15

7 months ago

1.0.13

7 months ago

1.0.12

7 months ago

1.0.11

7 months ago

1.0.10

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago