xcarpentier / rn-pdf-reader-js

📄 PDF reader in JavaScript only for Expo - Android & iOS capable
MIT License
388 stars 164 forks source link

not working in android and iOS both #195

Open SayaliEdulab opened 1 year ago

SayaliEdulab commented 1 year ago

Issue Description

while loading pdf in this package we getting error in android and white screen in the IOS

In android

image

Steps to Reproduce / Code Snippets

//import libraries import { NavigationContainer } from '@react-navigation/native'; import React, { Component } from 'react'; import { View, Text, StyleSheet } from 'react-native'; import PDFReader from 'rn-pdf-reader-js'

// create a component const PdfViewer = (props) => {

return (

    <View style={{ backgroundColor: '#fff', width: '100%', height: '100%' }}>
        <PDFReader
            source={{
                uri: props.route.params.pdfUri,
            }}
            withPinchZoom={true}
            withScroll={true}
        />
    </View>

);

};

//make this component available to the app export default PdfViewer;

Expected Results

view pdf

Additional Information

SBRKH commented 1 year ago

Exact same problem here...

I tried to do the same trick as this issue : https://github.com/react-native-webview/react-native-webview/issues/2920 But didn't work for me.

dev-jaydeep commented 1 year ago

Create your own component name PdfReader and copy the all code from rn-pdf-reader-js\lib\index.js replace the line source: renderedOnce || !isAndroid ? source : undefined with source: renderedOnce || !isAndroid ? source : { uri: undefined }

copy the bundleContainer.js to components directory

Checkout Example Here

Its working well in IOS and Android

<PdfReader
        style={{ flexGrow: 1 }}
        source={{
          uri: pdfUrl,
        }}
/>

Happy Coding!

rss14 commented 1 year ago

Create your own component name PdfReader and copy the all code from rn-pdf-reader-js\lib\index.js replace the line source: renderedOnce || !isAndroid ? source : undefined with source: renderedOnce || !isAndroid ? source : { uri: undefined }

copy the bundleContainer.js to components directory

Checkout Example Here

Its working well in IOS and Android

<PdfReader
        style={{ flexGrow: 1 }}
        source={{
          uri: pdfUrl,
        }}
/>

Happy Coding!

Resolveu, muito obrigado!

Tibze commented 11 months ago

Create your own component name PdfReader and copy the all code from rn-pdf-reader-js\lib\index.js replace the line source: renderedOnce || !isAndroid ? source : undefined with source: renderedOnce || !isAndroid ? source : { uri: undefined }

copy the bundleContainer.js to components directory

Checkout Example Here

Its working well in IOS and Android

<PdfReader
        style={{ flexGrow: 1 }}
        source={{
          uri: pdfUrl,
        }}
/>

Happy Coding!

Thanks for the solution ! @xcarpentier hi, can you merge this fix on Master ?