ngx-extended-pdf-viewer
Version:
Embedding PDF files in your Angular application. Highly configurable viewer including the toolbar, sidebar, and all the features you're used to.
47 lines (46 loc) • 2.37 kB
TypeScript
import { OnDestroy } from '@angular/core';
import { IPDFViewerApplication } from './options/pdf-viewer-application';
import { IPDFViewerApplicationOptions } from './options/pdf-viewer-application-options';
import { PdfCspPolicyService } from './pdf-csp-policy.service';
import * as i0 from "@angular/core";
/** What a loaded copy of the viewer module (`viewer-*.mjs`) hands over in its `ngxViewerFileHasBeenLoaded` event. */
export interface PdfJsModuleCopy {
PDFViewerApplication: IPDFViewerApplication;
PDFViewerApplicationOptions: IPDFViewerApplicationOptions;
webViewerLoad: (cspPolicyService: PdfCspPolicyService, options?: {
root?: HTMLElement;
}) => void;
}
/**
* Multiple viewers on one page: every live viewer needs its own copy of the viewer module.
*
* pdf.js keeps its state at module level (PDFViewerApplication, AppOptions, the print
* service, ...). The browser evaluates a module once per URL, so a different query string
* gives an independent copy: the first copy loads `viewer-*.mjs` as before, further copies
* load `viewer-*.mjs?instance=N`.
*
* A viewer returns its copy after its cleanup has finished. The next viewer reuses it, the
* same way a single viewer always reused the one module after a route change. A viewer
* mounted while another one is still cleaning up gets a copy of its own instead.
*
* Loads run one at a time: the module announces itself with a document-wide event that
* doesn't say which copy sent it.
*
* Internal - not part of the public API.
*/
export declare class PdfJsModulePool implements OnDestroy {
private readonly copies;
/** serializes the loads */
private queue;
/**
* Hands out a free copy of the module at `path`, or loads a new one.
* @param load loads the module from the given URL and resolves with what it announced
*/
acquire(path: string, forceReload: boolean, load: (url: string) => Promise<PdfJsModuleCopy>): Promise<PdfJsModuleCopy>;
/** Called when a viewer has finished its cleanup. */
release(copy: PdfJsModuleCopy | undefined): void;
/** Runs when the application shuts down (this used to be the root PDFScriptLoaderService's ngOnDestroy). */
ngOnDestroy(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<PdfJsModulePool, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<PdfJsModulePool>;
}