I am using the handy react-pdf library to render/display/download pdf's in my React site. I have my PDF's stored on the server. I have a call to the server that sends back the PDF in blob form. Now I want to display that PDF in the browser in a modal when the user clicks a link. I'm not finding and concrete examples on their site, https://react-pdf.org/ . I'm not sure if I should be using PDFViewer, https://react-pdf.org/components#pdfviewer or BlobProvider, https://react-pdf.org/components#blobprovider
I'm sure this is a fairly easy task, but I'm just not able to find any good examples anywhere.
I fee like the closest example would be here from their site:
import { BlobProvider, Document, Page } from '@react-pdf/renderer';
const MyDoc = (
<Document>
<Page>
// My document data
</Page>
</Document>
);
const App = () => (
<div>
<BlobProvider document={MyDoc}>
{({ blob, url, loading, error }) => {
// Do whatever you need with blob here
return <div>There's something going on on the fly</div>
}}
</BlobProvider>
</div>
);
<Modal> <iframe src={YourUrlToThePDF}></iframe> </Modal>
– Coptic