hoist-react
hoist-react copied to clipboard
New `PdfViewer` component
We typically render PDF documents within an app by embedding an iframe and rendering a PDF link or blob directly, leveraging the PDF viewer component built into the browser.
This has many advantages, but in some contexts all of the browser chrome around the PDF can be jarring from a styling perspective, take up more room than is desired, or provide more options than is desired. The viewer has gained some new features recently that have made this more of an issue (specifically a mode where it displays multiple pages in a gutter along the left).
To provide more control over PDF rendering - and to button up the pattern - we could consider a library such as https://github.com/wojtekmaj/react-pdf. (I did a bit of searching and this seems most promising.)
This might be a good candidate for a dedicated package that encapsulates the library dependency and a wrapper Hoist component that includes support for things like a toolbar to navigate from page-to-page or download the file. One reason to consider a distinct library is that this depends on pdfjs and is a pretty heavyweight dependency. Even if tree-shaking excluded it from app bundles (that weren't using PDFs) it might be nice to have it not even download with a core hoist-react install. And it might be a nice pattern to have available with a real project. Just a thought - happy to fold it in as well if we find ourselves wanting that.