PDF Embed
ProNewAn inline document viewer with a file header, page field, zoom, thumbnails, download and full screen, from supplied pages or the browser's own PDF viewer. Use File Embed for PDF lists and grids.
Installation
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
Props
| Prop | Type | Default |
|---|---|---|
| title* | stringShown in the header and used to name the viewer. | — |
| src | stringThe PDF itself. Used for download, print and open; shown in the browser's own viewer when `pages` is not given. | — |
| pages | PdfPage[]Rendered pages. With these the viewer draws its own toolbar, thumbnails and zoom. | — |
| size | number | stringFile size in bytes, or a ready-made label such as "2.4 MB". | — |
| height | numberHeight of the reading area, in pixels. It shrinks in narrow containers. | 640 |
| aspect | numberPage width divided by page height. 0.707 is A4 portrait. | 0.707 |
| header | booleanShow the title bar with the file name and download button. | true |
| toolbar | booleanShow the dark toolbar with page, zoom and full screen controls. | true |
| thumbnails | booleanOffer the thumbnail sidebar. | true |
| defaultSidebar | booleanStart with the thumbnail sidebar open when there is room for it. | false |
| download | booleanOffer a download button. Needs `src`. | true |
booleanOffer a print button. Needs `src`. | true | |
| icon | React.ReactNodeReplaces the PDF mark in the header. | — |
| loading | booleanShows page placeholders while the document is being fetched. | false |
| error | boolean | stringShows the error state. Pass a string to explain what went wrong. | false |
| onRetry | () => voidAdds a Try again button to the error state. | — |
| onPageChange | (page: number) => voidCalled with the page in view, counted from 1. | — |
| onDownload | () => void | — |
| className | string | — |
Accessibility
- The reading area is a focusable, natively scrolling region named with the document and page; Home and End jump to the first and last page, plus and minus zoom.
- Toolbar controls are named buttons and a labelled page field; page and zoom changes are announced politely.
- Thumbnails are a list of buttons with the current page marked.
- Loading is a status and failure is an alert; invalid PDF URLs never reach iframe, print or download controls.
- Jumping between pages does not smooth-scroll under reduced motion.