12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- "use strict";
- if (!pdfjsLib.getDocument || !pdfjsViewer.PDFViewer) {
-
- alert("Please build the pdfjs-dist library using\n `gulp dist-install`");
- }
- pdfjsLib.GlobalWorkerOptions.workerSrc =
- "../../node_modules/pdfjs-dist/build/pdf.worker.js";
- const CMAP_URL = "../../node_modules/pdfjs-dist/cmaps/";
- const CMAP_PACKED = true;
- const DEFAULT_URL = "../../web/compressed.tracemonkey-pldi-09.pdf";
- const ENABLE_XFA = true;
- const SEARCH_FOR = "";
- const SANDBOX_BUNDLE_SRC = "../../node_modules/pdfjs-dist/build/pdf.sandbox.js";
- const container = document.getElementById("viewerContainer");
- const eventBus = new pdfjsViewer.EventBus();
- const pdfLinkService = new pdfjsViewer.PDFLinkService({
- eventBus,
- });
- const pdfFindController = new pdfjsViewer.PDFFindController({
- eventBus,
- linkService: pdfLinkService,
- });
- const pdfScriptingManager = new pdfjsViewer.PDFScriptingManager({
- eventBus,
- sandboxBundleSrc: SANDBOX_BUNDLE_SRC,
- });
- const pdfViewer = new pdfjsViewer.PDFViewer({
- container,
- eventBus,
- linkService: pdfLinkService,
- findController: pdfFindController,
- scriptingManager: pdfScriptingManager,
- });
- pdfLinkService.setViewer(pdfViewer);
- pdfScriptingManager.setViewer(pdfViewer);
- eventBus.on("pagesinit", function () {
-
- pdfViewer.currentScaleValue = "page-width";
-
- if (SEARCH_FOR) {
- eventBus.dispatch("find", { type: "", query: SEARCH_FOR });
- }
- });
- const loadingTask = pdfjsLib.getDocument({
- url: DEFAULT_URL,
- cMapUrl: CMAP_URL,
- cMapPacked: CMAP_PACKED,
- enableXfa: ENABLE_XFA,
- });
- (async function () {
- const pdfDocument = await loadingTask.promise;
-
-
- pdfViewer.setDocument(pdfDocument);
- pdfLinkService.setDocument(pdfDocument, null);
- })();
|