Read PDF with Expo (ios & android)

how can I make pdfReader work if the user upload a pdf file?

thanks it’s working with me :slight_smile:

I am not able to install and it says it is not supported to the Expo SDK 44
Could you please help which supports the Expo SDK 44 version

Thank you,

Regards,
Sasanka M

2 Likes

Any package available to view pdf with react native expo web ?
I used this to view pdf

<object
        data={`data:application/pdf;base64,${base64Content}`}
        width="100%"
        height="100%"
 />

but not working when pdf size is more than 5 MB

@kirtikk perhaps you can use an IFRAME?

Yes, I also tried IFRAME but not working.
Its working now with below solution :

export const base64toBlob = (b64Data, contentType = '', sliceSize = 512) => {
  const byteCharacters = atob(b64Data);
  const byteArrays = [];

  for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
    const slice = byteCharacters.slice(offset, offset + sliceSize);

    const byteNumbers = new Array(slice.length);
    for (let i = 0; i < slice.length; i += 1) {
      byteNumbers[i] = slice.charCodeAt(i);
    }

    const byteArray = new Uint8Array(byteNumbers);
    byteArrays.push(byteArray);
  }

  const blob = new Blob(byteArrays, { type: contentType });
  return blob;
};

 const blobUrl = URL.createObjectURL(blob);

<object data={blobUrl} width="100%" height="100%" />