Reputation: 3
I'm trying to display a document file and download it in pdf in React, the document is uploaded it a file I used express-file-upload to do that, but I don't know how to fetch the document and display it in my react app, this is how my data look like :
{
"Document": {
"type": "Buffer",
"data": [91, 111, 98, 106, 101, 99, 116, 32, 79, 98, 106, 101, 99, 116, 93]
},
}
Upvotes: 0
Views: 9602
Reputation: 2453
const Buffer = require('buffer').Buffer;
const buff = Buffer.from('something cool');
console.log(buff);
console.log(buff.toString());
Call .toString()
on the Buffer object, this will convert it into a string value.
<Buffer 73 6f 6d 65 74 68 69 6e 67 20 63 6f 6f 6c>
something cool
how can i display a buffer data as Pdf Document in my react app?
With something like this: https://www.npmjs.com/package/react-pdf
I also came across another question that's similar to yours and is using the react-pdf library, I thought it may be useful: https://stackoverflow.com/a/45604439/2932298.
Upvotes: 1