I am following this package https://www.npmjs.com/package/react-pdf
I got the entire raw pdf data from backend so I was trying with code below.
I solved the problem. I convert the binary data that I received from backend into ArrayBuffer.
axios.post(//fire your API).then(response =>
(response.status === 200? response.data : null))
.then(pdfdata => {
var len = pdfdata.length;
var bytes = new Uint8Array( len );
for (var i = 0; i < len; i++){
bytes[i] = pdfdata.charCodeAt(i);
}
const renderPdf = bytes.buffer
Then I actually assign bytes.buffer to renderPDF to perform the rendering. Now it is working flawlessly!
In rendering html from react,
import PDF from 'react-pdf-scroll'