A react library to render pdf document in html
Install the component using NPM:
$ npm install --save react-pdfjs-dist
Install the component using YARN:
$ yarn add react-pdfjs-dist
import React, { useEffect, useRef } from 'react';
import { useReactPdf } from 'react-pdfjs-dist';
const App = () => {
const ref = useRef(null);
const { renderPdf } = useReactPdf({ containerRef: ref });
useEffect(() => {
renderPdf('http://localhost:3000/sample_document.pdf');
}, [renderPdf]);
return (
<div className="App">
<div className="pdf-container" ref={ref} />
</div>
);
}