Docs / Viewers / PDF Viewer
PDF Viewer
Svelte 5 port of the Extend UI pdf-viewer. Rendering runs on the client with PDF.js.
Fixture document
Loading PDF…
Dark mode, fit width
Dark mode is controlled by the parent through isDark and onIsDarkChange; this switch lives on the page, outside the viewer.
Loading PDF…
Empty source
Upload a PDF to preview
Pass a PDF URL with the src prop or use the upload control.
Differences from upstream
- Renders with PDF.js through the shared engine instead of EmbedPDF; zoom modes use EmbedPDF's formulas.
- Dark mode is parent-controlled with
isDarkandonIsDarkChange; the viewer renders no dark toggle. renderPageOverlayis thepageOverlaysnippet andtoolbarActionsis a snippet.classandclassNameare both accepted.- Extra props:
height,pageWidth/pageHeight(fallback page size),pageGap,overscan. - The toolbar adds previous/next page buttons and a plain page indicator (no inline page-number input); Download and Upload are buttons instead of a menu.
- Not ported yet: thumbnail sidebar and multi-page selection (rotate applies to the active page), text search, text selection and copy, tiling, page pointer callbacks,
resolveScrollAreaViewport, and the imperative handle (scrollToPage,scrollToPageArea). - Port-only exports:
PdfViewer(the same component asPDFViewer) and the framework-free zoom, rotation, download-name and page-layout helpersclampZoom,computeFitZoom,computePageLayout,DEFAULT_ZOOM,ensurePdfExtension,formatZoomPercent,getPdfDownloadFileName,getRotatedPdfDownloadFileName,isZoomMode,MAX_ZOOM,MIN_ZOOM,normalizeRotation,pageAtOffset,pageWindow,resolveZoom,rotateClockwise,rotateCounterClockwise,rotatedPageSize,ZOOM_MODES,ZOOM_OPTIONS,zoomSelectOptions,zoomSelectValue,zoomStepIn,zoomStepOut. Port-only types:PdfViewerProps,PdfViewerPageOverlayProps,PdfViewerZoomLevel,PdfViewerZoomMode,PdfLayoutSize,PdfPageLayout,ZoomViewport(upstream'sPDFViewerProps,PDFViewerPageOverlayPropsandPDFViewerZoomLevelare exported too). Upstream'sPDFViewerHandleandPDFViewerScrollAreaViewportResolvertypes are not exported, since the handle andresolveScrollAreaViewportare not ported.