Open mamta-deswal opened 2 years ago
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
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.
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",