alpha0010/react-native-pdf-viewer

uri is not dipalying

swaroopaillinda opened this issue · 4 comments

Hi,

I am using u r module I need to display pdf with specific page number
but the pdf is a Uri format

How Can I display that
Here is my code:

<PdfView resizeMode={"contain"} source={"..."} page={parseInt(item)} onError={(error)=>console.log("ffff",error)}/>

the errror is cannot open the pdf file

Can u help me with this

Could you explain what you mean by "Uri format"? Do you have an example I can see?

This library does not include networking code, so you will have to use a different library to download the pdf first. react-native-file-access is a library I created that can be used like:

import {Dirs, FileSystem} from 'react-native-file-access';

const cachePath = Dirs.CacheDir + '/name.pdf';
await FileSystem.fetch('https://example.com/name.pdf', {path: cachePath});

// ...

<PdfView resizeMode={"contain"} source={cachePath} page={parseInt(item)} onError={(error) => console.log("ffff", error)} />

However, any library that can download files should work. Other examples:

  • expo-file-system
  • rn-fetch-blob
  • react-native-fs
  • react-native-blob-courier

Assuming resolved.