mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-11-30 16:37:18 +01:00
This is a left-over from very old code[1], before there were a lot of `getDocument` options and when most of the library configuration was done via the (since removed) `PDFJS` global. Given all the functionality added through the years, which require configuration[2], in practice it's now unlikely that calling `getDocument` without additional options will work except for the most trivial PDFs. --- [1] If the `getDocument` function was added today, there's no chance that it'd support anything other than a parameter object. [2] Note things such as CMaps, standard fonts, wasm-based image decoders, and ICC-based colour spaces.
24 lines
663 B
TypeScript
24 lines
663 B
TypeScript
import { getDocument } from "pdfjs-dist";
|
|
import { EventBus } from "pdfjs-dist/web/pdf_viewer.mjs";
|
|
|
|
class MainTest {
|
|
eventBus: EventBus;
|
|
task: ReturnType<typeof getDocument> | undefined;
|
|
|
|
constructor(public file: string) {
|
|
this.eventBus = new EventBus();
|
|
}
|
|
|
|
loadPdf() {
|
|
this.task = getDocument({ url: "file://" + this.file });
|
|
return this.task.promise;
|
|
}
|
|
}
|
|
|
|
// This is actually never called, as the test only consists in compiling the file.
|
|
// The compilation will crawl through all files and make sure that the types are consistent.
|
|
const mt = new MainTest("../pdfs/basicapi.pdf");
|
|
mt.loadPdf().then(() => {
|
|
console.log("loaded");
|
|
});
|