wonday / react-native-pdf

A <Pdf /> component for react-native
MIT License
1.6k stars 555 forks source link

I'm tring to display pdf but PDF shows blank screen, I'm using base64 data in source #835

Open Rahmathirshad opened 6 months ago

Rahmathirshad commented 6 months ago
  1. I recieved this response -> {"_data": {"__collector": {}, "blobId": "23ffc5c3-ace3-492b-864f-ae04780955bc", "offset": 0, "size": 3028}}

  2. then I convert response to base64: const reader = new FileReader; reader.onerror = () => console.log("reject"); reader.onload = () => { console.log(reader.result); // data:application/octetstream;base64,JVBERi0xLjMNCiXi48/TDQoNCjE.... setPdfData(reader.result); }; reader.readAsDataURL(response.data);

  3. const source = {uri: pdfData, cache: true};

after all of this I'm getting white blank screen

jaraujo-ob commented 4 months ago

You need to replace data:application/octet-stream with data:application/pdf