Coder Social home page Coder Social logo

expo-pdf-reader's Introduction

expo-pdf-reader

[PROJECT DISCONTINUED]

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

Simply import PDFReader from '@hashiprobr/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 @hashiprobr/expo-pdf-reader

With yarn:

yarn add @hashiprobr/expo-pdf-reader

With expo:

expo install @hashiprobr/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: [
                '@hashiprobr/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 '@hashiprobr/expo-pdf-reader';

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.