Videos
What is React PDF Viewer SDK?
How does React PDF Viewer SDK compare to other solutions?
What developer resources are available for React PDF Viewer SDK?
» npm install react-pdf
Hey, I wanted to find out a library in react which can display a pdf from a url. So far I have tried react-pdf from wojtekmaj, it works just fine but I wanted a free library which can provide toolbars also. Let me know if you know any library or a way to build it.
Thanks
» npm install @pdf-viewer/react
» npm install pdf-viewer-reactjs
» npm install @react-pdf-viewer/core
If you goal is just to view the pdf in your application, the easiest way is using the object tag in HTML. You don't need to import any libraries and works most of the browsers. But this is lack of customization and styles.
<object data="http://africau.edu/images/default/sample.pdf" type="application/pdf" width="100%" height="100%">
<p>Alternative text - include a link <a href="http://africau.edu/images/default/sample.pdf">to the PDF!</a></p>
</object>
it looks like you're passing the PDF data directly to the <ReactPDF> component as the value of the file prop. But according to the docs you need to use an object containing a data property:
<ReactPDF
file={{
data: renderPdf
}}
/>
it seems you can also set file to an object containing a url property, to let ReactPDF fetch the pdf from your backend by itself, if that's easier:
<ReactPDF
file={{
url: 'http://www.example.com/sample.pdf'
}}
/>