Appearance
usePdfJsViewer Composable ​
File Information ​
- Path:
app/composables/core/miscellaneous/usePdfJsViewer.ts - Purpose: Full PDF viewer logic for the PdfJsViewer component: load document, zoom/rotate/fit, thumbnails, find-in-page, and cross-origin via /api/pdf/proxy
- Type: Core Composable (Miscellaneous)
Overview ​
Accepts props.src and provides loading state, document reference, page count, current page, zoom, rotation, fit mode, sidebar thumbnails, and find-in-page state. Resolves cross-origin PDF URLs to the server proxy (/api/pdf/proxy?url=...) when needed. Uses usePdfJs() for the shared PDF.js instance. Emits loaded and error.
Parameters ​
- props:
{ src: string } - emit:
(event: 'loaded' | 'error', payload) => void
Return Type ​
Large object including: loading, pdfReady, refs (pdfContainer, pdfViewerRoot, pdfSidebar, pdfPageInput, pdfSearchInput), sidebarOpen, pdfTotalPages, pdfCurrentPage, pdfZoom, pdfZoomLabel, pdfFitMode, pdfSearchOpen/Query/MatchIndex/MatchCount, and methods: toggleSidebar, goToPrevPage, goToNextPage, goToPage, goToPageFromInput, focusPageInput, fitToPage, fitToWidth, zoomIn, zoomOut, resetZoom, rotateClockwise, rotateCounterClockwise, togglePdfSearch, findPrev, findNext, closePdfSearch, setThumbCanvasRef, onPdfScroll.
Usage ​
Used by the PdfJsViewer component. The component passes src (asset URL) and the composable handles proxy resolution and PDF.js viewer setup.
Related ​
- usePdfJs - Shared PDF.js instance
- Server API - PDF proxy
- Components - PdfJsViewer