Appearance
usePdfJs Composable ​
File Information ​
- Path:
app/composables/core/miscellaneous/usePdfJs.ts - Purpose: Single shared PDF.js library instance across the application to avoid private field errors (#pagesMapper)
- Type: Core Composable (Miscellaneous)
Overview ​
Lazily imports pdfjs-dist/build/pdf.mjs once and caches the module. On the client, sets GlobalWorkerOptions.workerSrc to /pdfjs/pdf.worker.min.mjs (so the plugin or this composable can guarantee worker path). Used by usePdfJsViewer and any other code that needs the PDF.js API.
Return Type ​
- Promise resolving to the PDF.js library instance (same reference on subsequent calls)
Usage ​
typescript
const pdfjsLib = await usePdfJs()
const loadingTask = pdfjsLib.getDocument({ url, ... })Related ​
- usePdfJsViewer - Viewer composable that uses usePdfJs
- Plugins - PDF.js - Client plugin for PDF.js
- Components - PdfJsViewer