Extend UI Svelte

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 isDark and onIsDarkChange; the viewer renders no dark toggle.
  • renderPageOverlay is the pageOverlay snippet and toolbarActions is a snippet.
  • class and className are 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 as PDFViewer) and the framework-free zoom, rotation, download-name and page-layout helpers clampZoom, 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's PDFViewerProps, PDFViewerPageOverlayProps and PDFViewerZoomLevel are exported too). Upstream's PDFViewerHandle and PDFViewerScrollAreaViewportResolver types are not exported, since the handle and resolveScrollAreaViewport are not ported.

Back to all components