react-native-PDFView icon indicating copy to clipboard operation
react-native-PDFView copied to clipboard

Pdf File not found

Open mamta-deswal opened this issue 3 years ago • 2 comments

I'm using react-native-fs for downloading the pdf and saving it.

let url = 'http://samples.leanpub.com/thereactnativebook-sample.pdf';

const getPdfName = () => { return url.split('/').pop(); };

RNFS.downloadFile({ fromUrl: url, toFile: ${RNFS.DocumentDirectoryPath}/${getPdfName()}, }).promise.then(r => { let path = ${RNFS.DocumentDirectoryPath}/${getPdfName()}; setFilePath(path); });

const resourceType = 'file'; const resources = { file: 'thereactnativebook-sample.pdf', };

<PDFView fadeInDuration={250.0} style={styles.pdfStyle} resource={resources[resourceType]} resourceType={resourceType} onLoad={() => console.log(PDF rendered from ${resourceType})} onError={error => console.log('Cannot render PDF', error)} />

Getting error 'Pdf file not found. While code works fine with URL-type resources.

Version:- "react": "18.1.0", "react-native": "0.70.0",

mamta-deswal avatar Oct 16 '22 11:10 mamta-deswal

Hi @mamta-deswal , I do not know react-native-fs, but what is DocumentDirectoryPath? Because looking into your example you give

file: 'thereactnativebook-sample.pdf',

and if you look to demo project, that is the way to define path: https://github.com/rumax/react-native-PDFView/blob/master/demo/src/resources.ts#L19

so what you need is absolute path, or you can also try to debug it and check what you actually get in

https://github.com/rumax/react-native-PDFView/blob/master/android/src/main/java/com/rumax/reactnative/pdfviewer/PDFView.java#L130

rumax avatar Nov 02 '22 09:11 rumax

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 15 '23 07:05 stale[bot]