import type { PDFDocumentProxy } from "pdfjs-dist"; export type PdfDocument = Pick; /** * Loads a PDF with pdf.js. The library and its worker are imported on demand, * so pages without a PDF never download them. */ export async function loadPdf(src: string): Promise { const pdfjs = await import("pdfjs-dist"); pdfjs.GlobalWorkerOptions.workerSrc = new URL("pdfjs-dist/build/pdf.worker.min.mjs", import.meta.url).toString(); return pdfjs.getDocument({ url: src }).promise; }