123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266 |
- export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
- /**
- * Document initialization / loading parameters object.
- */
- export type DocumentInitParameters = {
- /**
- * - The URL of the PDF.
- */
- url?: string | URL | undefined;
- /**
- * - Binary PDF data. Use
- * typed arrays (Uint8Array) to improve the memory usage. If PDF data is
- * BASE64-encoded, use `atob()` to convert it to a binary string first.
- */
- data?: string | number[] | TypedArray | undefined;
- /**
- * - Basic authentication headers.
- */
- httpHeaders?: Object | undefined;
- /**
- * - Indicates whether or not
- * cross-site Access-Control requests should be made using credentials such
- * as cookies or authorization headers. The default is `false`.
- */
- withCredentials?: boolean | undefined;
- /**
- * - For decrypting password-protected PDFs.
- */
- password?: string | undefined;
- /**
- * - A typed array with the first portion
- * or all of the pdf data. Used by the extension since some data is already
- * loaded before the switch to range requests.
- */
- initialData?: TypedArray | undefined;
- /**
- * - The PDF file length. It's used for progress
- * reports and range requests operations.
- */
- length?: number | undefined;
- /**
- * - Allows for using a custom range
- * transport implementation.
- */
- range?: PDFDataRangeTransport | undefined;
- /**
- * - Specify maximum number of bytes fetched
- * per range request. The default value is {@link DEFAULT_RANGE_CHUNK_SIZE }.
- */
- rangeChunkSize?: number | undefined;
- /**
- * - The worker that will be used for loading and
- * parsing the PDF data.
- */
- worker?: any;
- /**
- * - Controls the logging level; the constants
- * from {@link VerbosityLevel } should be used.
- */
- verbosity?: number | undefined;
- /**
- * - The base URL of the document, used when
- * attempting to recover valid absolute URLs for annotations, and outline
- * items, that (incorrectly) only specify relative URLs.
- */
- docBaseUrl?: string | undefined;
- /**
- * - The URL where the predefined Adobe CMaps are
- * located. Include the trailing slash.
- */
- cMapUrl?: string | undefined;
- /**
- * - Specifies if the Adobe CMaps are binary
- * packed or not.
- */
- cMapPacked?: boolean | undefined;
- /**
- * - The factory that will be used when
- * reading built-in CMap files. Providing a custom factory is useful for
- * environments without Fetch API or `XMLHttpRequest` support, such as
- * Node.js. The default value is {DOMCMapReaderFactory}.
- */
- CMapReaderFactory?: Object | undefined;
- /**
- * - Reject certain promises, e.g.
- * `getOperatorList`, `getTextContent`, and `RenderTask`, when the associated
- * PDF data cannot be successfully parsed, instead of attempting to recover
- * whatever possible of the data. The default value is `false`.
- */
- stopAtErrors?: boolean | undefined;
- /**
- * - The maximum allowed image size in total
- * pixels, i.e. width * height. Images above this value will not be rendered.
- * Use -1 for no limit, which is also the default value.
- */
- maxImageSize?: number | undefined;
- /**
- * - Determines if we can evaluate strings
- * as JavaScript. Primarily used to improve performance of font rendering, and
- * when parsing PDF functions. The default value is `true`.
- */
- isEvalSupported?: boolean | undefined;
- /**
- * - By default fonts are converted to
- * OpenType fonts and loaded via `@font-face` rules. If disabled, fonts will
- * be rendered using a built-in font renderer that constructs the glyphs with
- * primitive path commands. The default value is `false`.
- */
- disableFontFace?: boolean | undefined;
- /**
- * - Include additional properties,
- * which are unused during rendering of PDF documents, when exporting the
- * parsed font data from the worker-thread. This may be useful for debugging
- * purposes (and backwards compatibility), but note that it will lead to
- * increased memory usage. The default value is `false`.
- */
- fontExtraProperties?: boolean | undefined;
- /**
- * - Render Xfa forms if any.
- * The default value is `false`.
- */
- enableXfa?: boolean | undefined;
- /**
- * - Specify an explicit document
- * context to create elements with and to load resources, such as fonts,
- * into. Defaults to the current document.
- */
- ownerDocument?: HTMLDocument | undefined;
- /**
- * - Disable range request loading of PDF
- * files. When enabled, and if the server supports partial content requests,
- * then the PDF will be fetched in chunks. The default value is `false`.
- */
- disableRange?: boolean | undefined;
- /**
- * - Disable streaming of PDF file data.
- * By default PDF.js attempts to load PDF files in chunks. The default value
- * is `false`.
- */
- disableStream?: boolean | undefined;
- /**
- * - Disable pre-fetching of PDF file
- * data. When range requests are enabled PDF.js will automatically keep
- * fetching more data even if it isn't needed to display the current page.
- * The default value is `false`.
- *
- * NOTE: It is also necessary to disable streaming, see above, in order for
- * disabling of pre-fetching to work correctly.
- */
- disableAutoFetch?: boolean | undefined;
- /**
- * - Enables special hooks for debugging PDF.js
- * (see `web/debugger.js`). The default value is `false`.
- */
- pdfBug?: boolean | undefined;
- };
- export type IPDFStreamFactory = Function;
- /**
- * The loading task controls the operations required to load a PDF document
- * (such as network requests) and provides a way to listen for completion,
- * after which individual pages can be rendered.
- */
- export type PDFDocumentLoadingTask = {
- /**
- * - Unique identifier for the document loading task.
- */
- docId: string;
- /**
- * - Whether the loading task is destroyed or not.
- */
- destroyed: boolean;
- /**
- * - Callback to request a password if a wrong
- * or no password was provided. The callback receives two parameters: a
- * function that should be called with the new password, and a reason (see
- * {@link PasswordResponses }).
- */
- onPassword?: Function | undefined;
- /**
- * - Callback to be able to monitor the
- * loading progress of the PDF file (necessary to implement e.g. a loading
- * bar). The callback receives an {Object} with the properties `loaded`
- * ({number}) and `total` ({number}) that indicate how many bytes are loaded.
- */
- onProgress?: Function | undefined;
- /**
- * - Callback for when an
- * unsupported feature is used in the PDF document. The callback receives an
- * {@link UNSUPPORTED_FEATURES } argument.
- */
- onUnsupportedFeature?: Function | undefined;
- /**
- * - Promise for document loading
- * task completion.
- */
- promise: Promise<PDFDocumentProxy>;
- /**
- * - Abort all network requests and destroy
- * the worker. Returns a promise that is resolved when destruction is
- * completed.
- */
- destroy: Function;
- };
- /**
- * Page getViewport parameters.
- */
- export type GetViewportParameters = {
- /**
- * - The desired scale of the viewport.
- */
- scale: number;
- /**
- * - The desired rotation, in degrees, of
- * the viewport. If omitted it defaults to the page rotation.
- */
- rotation?: number | undefined;
- /**
- * - The horizontal, i.e. x-axis, offset.
- * The default value is `0`.
- */
- offsetX?: number | undefined;
- /**
- * - The vertical, i.e. y-axis, offset.
- * The default value is `0`.
- */
- offsetY?: number | undefined;
- /**
- * - If true, the y-axis will not be
- * flipped. The default value is `false`.
- */
- dontFlip?: boolean | undefined;
- };
- /**
- * Page getTextContent parameters.
- */
- export type getTextContentParameters = {
- /**
- * - Replaces all occurrences of
- * whitespace with standard spaces (0x20). The default value is `false`.
- */
- normalizeWhitespace: boolean;
- /**
- * - Do not attempt to combine
- * same line {@link TextItem }'s. The default value is `false`.
- */
- disableCombineTextItems: boolean;
- /**
- * - When true include marked
- * content items in the items array of TextContent. The default is `false`.
- */
- includeMarkedContent?: boolean | undefined;
- };
- /**
- * Page text content.
- */
- export type TextContent = {
- /**
- * - Array of
- * {@link TextItem } and {@link TextMarkedContent } objects. TextMarkedContent
- * items are included when includeMarkedContent is true.
- */
- items: Array<TextItem | TextMarkedContent>;
- /**
- * - {@link TextStyle } objects,
- * indexed by font name.
- */
- styles: {
- [x: string]: TextStyle;
- };
- };
- /**
- * Page text content part.
- */
- export type TextItem = {
- /**
- * - Text content.
- */
- str: string;
- /**
- * - Text direction: 'ttb', 'ltr' or 'rtl'.
- */
- dir: string;
- /**
- * - Transformation matrix.
- */
- transform: Array<any>;
- /**
- * - Width in device space.
- */
- width: number;
- /**
- * - Height in device space.
- */
- height: number;
- /**
- * - Font name used by PDF.js for converted font.
- */
- fontName: string;
- };
- /**
- * Page text marked content part.
- */
- export type TextMarkedContent = {
- /**
- * - Either 'beginMarkedContent',
- * 'beginMarkedContentProps', or 'endMarkedContent'.
- */
- type: string;
- /**
- * - The marked content identifier. Only used for type
- * 'beginMarkedContentProps'.
- */
- id: string;
- };
- /**
- * Text style.
- */
- export type TextStyle = {
- /**
- * - Font ascent.
- */
- ascent: number;
- /**
- * - Font descent.
- */
- descent: number;
- /**
- * - Whether or not the text is in vertical mode.
- */
- vertical: boolean;
- /**
- * - The possible font family.
- */
- fontFamily: string;
- };
- /**
- * Page annotation parameters.
- */
- export type GetAnnotationsParameters = {
- /**
- * - Determines the annotations that will be fetched,
- * can be either 'display' (viewable annotations) or 'print' (printable
- * annotations). If the parameter is omitted, all annotations are fetched.
- */
- intent: string;
- };
- /**
- * Page render parameters.
- */
- export type RenderParameters = {
- /**
- * - A 2D context of a DOM Canvas object.
- */
- canvasContext: Object;
- /**
- * - Rendering viewport obtained by calling
- * the `PDFPageProxy.getViewport` method.
- */
- viewport: PageViewport;
- /**
- * - Rendering intent, can be 'display' or 'print'.
- * The default value is 'display'.
- */
- intent?: string | undefined;
- /**
- * - Whether or not interactive
- * form elements are rendered in the display layer. If so, we do not render
- * them on the canvas as well. The default value is `false`.
- */
- renderInteractiveForms?: boolean | undefined;
- /**
- * - Additional transform, applied just
- * before viewport transform.
- */
- transform?: any[] | undefined;
- /**
- * - An object that has `beginLayout`,
- * `endLayout` and `appendImage` functions.
- */
- imageLayer?: Object | undefined;
- /**
- * - The factory instance that will be used
- * when creating canvases. The default value is {new DOMCanvasFactory()}.
- */
- canvasFactory?: Object | undefined;
- /**
- * - Background to use for the canvas.
- * Any valid `canvas.fillStyle` can be used: a `DOMString` parsed as CSS
- * <color> value, a `CanvasGradient` object (a linear or radial gradient) or
- * a `CanvasPattern` object (a repetitive image). The default value is
- * 'rgb(255,255,255)'.
- */
- background?: string | Object | undefined;
- /**
- * - Render stored interactive
- * form element data, from the {@link AnnotationStorage }-instance, onto the
- * canvas itself; useful e.g. for printing. The default value is `false`.
- */
- includeAnnotationStorage?: boolean | undefined;
- /**
- * -
- * A promise that should resolve with an {@link OptionalContentConfig }created from `PDFDocumentProxy.getOptionalContentConfig`. If `null`,
- * the configuration will be fetched automatically with the default visibility
- * states set.
- */
- optionalContentConfigPromise?: Promise<OptionalContentConfig> | undefined;
- };
- /**
- * Structure tree node. The root node will have a role "Root".
- */
- export type StructTreeNode = {
- /**
- * - Array of
- * {@link StructTreeNode } and {@link StructTreeContent } objects.
- */
- children: Array<StructTreeNode | StructTreeContent>;
- /**
- * - element's role, already mapped if a role map exists
- * in the PDF.
- */
- role: string;
- };
- /**
- * Structure tree content.
- */
- export type StructTreeContent = {
- /**
- * - either "content" for page and stream structure
- * elements or "object" for object references.
- */
- type: string;
- /**
- * - unique id that will map to the text layer.
- */
- id: string;
- };
- /**
- * PDF page operator list.
- */
- export type PDFOperatorList = {
- /**
- * - Array containing the operator functions.
- */
- fnArray: Array<number>;
- /**
- * - Array containing the arguments of the
- * functions.
- */
- argsArray: Array<any>;
- };
- export type PDFWorkerParameters = {
- /**
- * - The name of the worker.
- */
- name?: string | undefined;
- /**
- * - The `workerPort` object.
- */
- port?: Object | undefined;
- /**
- * - Controls the logging level; the
- * constants from {@link VerbosityLevel } should be used.
- */
- verbosity?: number | undefined;
- };
- /** @type {string} */
- export const build: string;
- export const DefaultCanvasFactory: typeof DOMCanvasFactory | {
- new (): {};
- };
- export const DefaultCMapReaderFactory: typeof DOMCMapReaderFactory | {
- new (): {};
- };
- /**
- * @typedef { Int8Array | Uint8Array | Uint8ClampedArray |
- * Int16Array | Uint16Array |
- * Int32Array | Uint32Array | Float32Array |
- * Float64Array
- * } TypedArray
- */
- /**
- * Document initialization / loading parameters object.
- *
- * @typedef {Object} DocumentInitParameters
- * @property {string|URL} [url] - The URL of the PDF.
- * @property {TypedArray|Array<number>|string} [data] - Binary PDF data. Use
- * typed arrays (Uint8Array) to improve the memory usage. If PDF data is
- * BASE64-encoded, use `atob()` to convert it to a binary string first.
- * @property {Object} [httpHeaders] - Basic authentication headers.
- * @property {boolean} [withCredentials] - Indicates whether or not
- * cross-site Access-Control requests should be made using credentials such
- * as cookies or authorization headers. The default is `false`.
- * @property {string} [password] - For decrypting password-protected PDFs.
- * @property {TypedArray} [initialData] - A typed array with the first portion
- * or all of the pdf data. Used by the extension since some data is already
- * loaded before the switch to range requests.
- * @property {number} [length] - The PDF file length. It's used for progress
- * reports and range requests operations.
- * @property {PDFDataRangeTransport} [range] - Allows for using a custom range
- * transport implementation.
- * @property {number} [rangeChunkSize] - Specify maximum number of bytes fetched
- * per range request. The default value is {@link DEFAULT_RANGE_CHUNK_SIZE}.
- * @property {PDFWorker} [worker] - The worker that will be used for loading and
- * parsing the PDF data.
- * @property {number} [verbosity] - Controls the logging level; the constants
- * from {@link VerbosityLevel} should be used.
- * @property {string} [docBaseUrl] - The base URL of the document, used when
- * attempting to recover valid absolute URLs for annotations, and outline
- * items, that (incorrectly) only specify relative URLs.
- * @property {string} [cMapUrl] - The URL where the predefined Adobe CMaps are
- * located. Include the trailing slash.
- * @property {boolean} [cMapPacked] - Specifies if the Adobe CMaps are binary
- * packed or not.
- * @property {Object} [CMapReaderFactory] - The factory that will be used when
- * reading built-in CMap files. Providing a custom factory is useful for
- * environments without Fetch API or `XMLHttpRequest` support, such as
- * Node.js. The default value is {DOMCMapReaderFactory}.
- * @property {boolean} [stopAtErrors] - Reject certain promises, e.g.
- * `getOperatorList`, `getTextContent`, and `RenderTask`, when the associated
- * PDF data cannot be successfully parsed, instead of attempting to recover
- * whatever possible of the data. The default value is `false`.
- * @property {number} [maxImageSize] - The maximum allowed image size in total
- * pixels, i.e. width * height. Images above this value will not be rendered.
- * Use -1 for no limit, which is also the default value.
- * @property {boolean} [isEvalSupported] - Determines if we can evaluate strings
- * as JavaScript. Primarily used to improve performance of font rendering, and
- * when parsing PDF functions. The default value is `true`.
- * @property {boolean} [disableFontFace] - By default fonts are converted to
- * OpenType fonts and loaded via `@font-face` rules. If disabled, fonts will
- * be rendered using a built-in font renderer that constructs the glyphs with
- * primitive path commands. The default value is `false`.
- * @property {boolean} [fontExtraProperties] - Include additional properties,
- * which are unused during rendering of PDF documents, when exporting the
- * parsed font data from the worker-thread. This may be useful for debugging
- * purposes (and backwards compatibility), but note that it will lead to
- * increased memory usage. The default value is `false`.
- * @property {boolean} [enableXfa] - Render Xfa forms if any.
- * The default value is `false`.
- * @property {HTMLDocument} [ownerDocument] - Specify an explicit document
- * context to create elements with and to load resources, such as fonts,
- * into. Defaults to the current document.
- * @property {boolean} [disableRange] - Disable range request loading of PDF
- * files. When enabled, and if the server supports partial content requests,
- * then the PDF will be fetched in chunks. The default value is `false`.
- * @property {boolean} [disableStream] - Disable streaming of PDF file data.
- * By default PDF.js attempts to load PDF files in chunks. The default value
- * is `false`.
- * @property {boolean} [disableAutoFetch] - Disable pre-fetching of PDF file
- * data. When range requests are enabled PDF.js will automatically keep
- * fetching more data even if it isn't needed to display the current page.
- * The default value is `false`.
- *
- * NOTE: It is also necessary to disable streaming, see above, in order for
- * disabling of pre-fetching to work correctly.
- * @property {boolean} [pdfBug] - Enables special hooks for debugging PDF.js
- * (see `web/debugger.js`). The default value is `false`.
- */
- /**
- * This is the main entry point for loading a PDF and interacting with it.
- *
- * NOTE: If a URL is used to fetch the PDF data a standard Fetch API call (or
- * XHR as fallback) is used, which means it must follow same origin rules,
- * e.g. no cross-domain requests without CORS.
- *
- * @param {string|URL|TypedArray|PDFDataRangeTransport|DocumentInitParameters}
- * src - Can be a URL where a PDF file is located, a typed array (Uint8Array)
- * already populated with data, or a parameter object.
- * @returns {PDFDocumentLoadingTask}
- */
- export function getDocument(src: string | URL | TypedArray | PDFDataRangeTransport | DocumentInitParameters): PDFDocumentLoadingTask;
- export class LoopbackPort {
- _listeners: any[];
- _deferred: Promise<undefined>;
- postMessage(obj: any, transfers: any): void;
- addEventListener(name: any, listener: any): void;
- removeEventListener(name: any, listener: any): void;
- terminate(): void;
- }
- /**
- * Abstract class to support range requests file loading.
- */
- export class PDFDataRangeTransport {
- /**
- * @param {number} length
- * @param {Uint8Array} initialData
- * @param {boolean} [progressiveDone]
- * @param {string} [contentDispositionFilename]
- */
- constructor(length: number, initialData: Uint8Array, progressiveDone?: boolean | undefined, contentDispositionFilename?: string | undefined);
- length: number;
- initialData: Uint8Array;
- progressiveDone: boolean;
- contentDispositionFilename: string;
- _rangeListeners: any[];
- _progressListeners: any[];
- _progressiveReadListeners: any[];
- _progressiveDoneListeners: any[];
- _readyCapability: import("../shared/util.js").PromiseCapability;
- addRangeListener(listener: any): void;
- addProgressListener(listener: any): void;
- addProgressiveReadListener(listener: any): void;
- addProgressiveDoneListener(listener: any): void;
- onDataRange(begin: any, chunk: any): void;
- onDataProgress(loaded: any, total: any): void;
- onDataProgressiveRead(chunk: any): void;
- onDataProgressiveDone(): void;
- transportReady(): void;
- requestDataRange(begin: any, end: any): void;
- abort(): void;
- }
- /**
- * Proxy to a `PDFDocument` in the worker thread.
- */
- export class PDFDocumentProxy {
- constructor(pdfInfo: any, transport: any);
- _pdfInfo: any;
- _transport: any;
- /**
- * @type {AnnotationStorage} Storage for annotation data in forms.
- */
- get annotationStorage(): AnnotationStorage;
- /**
- * @type {number} Total number of pages in the PDF file.
- */
- get numPages(): number;
- /**
- * @type {string} A (not guaranteed to be) unique ID to identify a PDF.
- */
- get fingerprint(): string;
- /**
- * @type {boolean} True if only XFA form.
- */
- get isPureXfa(): boolean;
- /**
- * @param {number} pageNumber - The page number to get. The first page is 1.
- * @returns {Promise<PDFPageProxy>} A promise that is resolved with
- * a {@link PDFPageProxy} object.
- */
- getPage(pageNumber: number): Promise<PDFPageProxy>;
- /**
- * @typedef {Object} RefProxy
- * @property {number} num
- * @property {number} gen
- */
- /**
- * @param {RefProxy} ref - The page reference.
- * @returns {Promise<number>} A promise that is resolved with the page index,
- * starting from zero, that is associated with the reference.
- */
- getPageIndex(ref: {
- num: number;
- gen: number;
- }): Promise<number>;
- /**
- * @returns {Promise<Object<string, Array<any>>>} A promise that is resolved
- * with a mapping from named destinations to references.
- *
- * This can be slow for large documents. Use `getDestination` instead.
- */
- getDestinations(): Promise<{
- [x: string]: Array<any>;
- }>;
- /**
- * @param {string} id - The named destination to get.
- * @returns {Promise<Array<any> | null>} A promise that is resolved with all
- * information of the given named destination, or `null` when the named
- * destination is not present in the PDF file.
- */
- getDestination(id: string): Promise<Array<any> | null>;
- /**
- * @returns {Promise<Array<string> | null>} A promise that is resolved with
- * an {Array} containing the page labels that correspond to the page
- * indexes, or `null` when no page labels are present in the PDF file.
- */
- getPageLabels(): Promise<Array<string> | null>;
- /**
- * @returns {Promise<string>} A promise that is resolved with a {string}
- * containing the page layout name.
- */
- getPageLayout(): Promise<string>;
- /**
- * @returns {Promise<string>} A promise that is resolved with a {string}
- * containing the page mode name.
- */
- getPageMode(): Promise<string>;
- /**
- * @returns {Promise<Object | null>} A promise that is resolved with an
- * {Object} containing the viewer preferences, or `null` when no viewer
- * preferences are present in the PDF file.
- */
- getViewerPreferences(): Promise<Object | null>;
- /**
- * @returns {Promise<any | null>} A promise that is resolved with an {Array}
- * containing the destination, or `null` when no open action is present
- * in the PDF.
- */
- getOpenAction(): Promise<any | null>;
- /**
- * @returns {Promise<any>} A promise that is resolved with a lookup table
- * for mapping named attachments to their content.
- */
- getAttachments(): Promise<any>;
- /**
- * @returns {Promise<Array<string> | null>} A promise that is resolved with
- * an {Array} of all the JavaScript strings in the name tree, or `null`
- * if no JavaScript exists.
- */
- getJavaScript(): Promise<Array<string> | null>;
- /**
- * @returns {Promise<Object | null>} A promise that is resolved with
- * an {Object} with the JavaScript actions:
- * - from the name tree (like getJavaScript);
- * - from A or AA entries in the catalog dictionary.
- * , or `null` if no JavaScript exists.
- */
- getJSActions(): Promise<Object | null>;
- /**
- * @typedef {Object} OutlineNode
- * @property {string} title
- * @property {boolean} bold
- * @property {boolean} italic
- * @property {Uint8ClampedArray} color - The color in RGB format to use for
- * display purposes.
- * @property {string | Array<any> | null} dest
- * @property {string | null} url
- * @property {string | undefined} unsafeUrl
- * @property {boolean | undefined} newWindow
- * @property {number | undefined} count
- * @property {Array<OutlineNode>} items
- */
- /**
- * @returns {Promise<Array<OutlineNode>>} A promise that is resolved with an
- * {Array} that is a tree outline (if it has one) of the PDF file.
- */
- getOutline(): Promise<{
- title: string;
- bold: boolean;
- italic: boolean;
- /**
- * - The color in RGB format to use for
- * display purposes.
- */
- color: Uint8ClampedArray;
- dest: string | Array<any> | null;
- url: string | null;
- unsafeUrl: string | undefined;
- newWindow: boolean | undefined;
- count: number | undefined;
- items: any[];
- }[]>;
- /**
- * @returns {Promise<OptionalContentConfig>} A promise that is resolved with
- * an {@link OptionalContentConfig} that contains all the optional content
- * groups (assuming that the document has any).
- */
- getOptionalContentConfig(): Promise<OptionalContentConfig>;
- /**
- * @returns {Promise<Array<number> | null>} A promise that is resolved with
- * an {Array} that contains the permission flags for the PDF document, or
- * `null` when no permissions are present in the PDF file.
- */
- getPermissions(): Promise<Array<number> | null>;
- /**
- * @returns {Promise<{ info: Object, metadata: Metadata }>} A promise that is
- * resolved with an {Object} that has `info` and `metadata` properties.
- * `info` is an {Object} filled with anything available in the information
- * dictionary and similarly `metadata` is a {Metadata} object with
- * information from the metadata section of the PDF.
- */
- getMetadata(): Promise<{
- info: Object;
- metadata: Metadata;
- }>;
- /**
- * @typedef {Object} MarkInfo
- * Properties correspond to Table 321 of the PDF 32000-1:2008 spec.
- * @property {boolean} Marked
- * @property {boolean} UserProperties
- * @property {boolean} Suspects
- */
- /**
- * @returns {Promise<MarkInfo | null>} A promise that is resolved with
- * a {MarkInfo} object that contains the MarkInfo flags for the PDF
- * document, or `null` when no MarkInfo values are present in the PDF file.
- */
- getMarkInfo(): Promise<{
- Marked: boolean;
- UserProperties: boolean;
- Suspects: boolean;
- } | null>;
- /**
- * @returns {Promise<TypedArray>} A promise that is resolved with a
- * {TypedArray} that has the raw data from the PDF.
- */
- getData(): Promise<TypedArray>;
- /**
- * @returns {Promise<{ length: number }>} A promise that is resolved when the
- * document's data is loaded. It is resolved with an {Object} that contains
- * the `length` property that indicates size of the PDF data in bytes.
- */
- getDownloadInfo(): Promise<{
- length: number;
- }>;
- /**
- * @typedef {Object} PDFDocumentStats
- * @property {Object<string, boolean>} streamTypes - Used stream types in the
- * document (an item is set to true if specific stream ID was used in the
- * document).
- * @property {Object<string, boolean>} fontTypes - Used font types in the
- * document (an item is set to true if specific font ID was used in the
- * document).
- */
- /**
- * @returns {Promise<PDFDocumentStats>} A promise this is resolved with
- * current statistics about document structures (see
- * {@link PDFDocumentStats}).
- */
- getStats(): Promise<{
- /**
- * - Used stream types in the
- * document (an item is set to true if specific stream ID was used in the
- * document).
- */
- streamTypes: {
- [x: string]: boolean;
- };
- /**
- * - Used font types in the
- * document (an item is set to true if specific font ID was used in the
- * document).
- */
- fontTypes: {
- [x: string]: boolean;
- };
- }>;
- /**
- * Cleans up resources allocated by the document on both the main and worker
- * threads.
- *
- * NOTE: Do not, under any circumstances, call this method when rendering is
- * currently ongoing since that may lead to rendering errors.
- *
- * @param {boolean} [keepLoadedFonts] - Let fonts remain attached to the DOM.
- * NOTE: This will increase persistent memory usage, hence don't use this
- * option unless absolutely necessary. The default value is `false`.
- * @returns {Promise} A promise that is resolved when clean-up has finished.
- */
- cleanup(keepLoadedFonts?: boolean | undefined): Promise<any>;
- /**
- * Destroys the current document instance and terminates the worker.
- */
- destroy(): any;
- /**
- * @type {DocumentInitParameters} A subset of the current
- * {DocumentInitParameters}, which are either needed in the viewer and/or
- * whose default values may be affected by the `apiCompatibilityParams`.
- */
- get loadingParams(): DocumentInitParameters;
- /**
- * @type {PDFDocumentLoadingTask} The loadingTask for the current document.
- */
- get loadingTask(): PDFDocumentLoadingTask;
- /**
- * @returns {Promise<Uint8Array>} A promise that is resolved with a
- * {Uint8Array} containing the full data of the saved document.
- */
- saveDocument(...args: any[]): Promise<Uint8Array>;
- /**
- * @returns {Promise<Array<Object> | null>} A promise that is resolved with an
- * {Array<Object>} containing /AcroForm field data for the JS sandbox,
- * or `null` when no field data is present in the PDF file.
- */
- getFieldObjects(): Promise<Array<Object> | null>;
- /**
- * @returns {Promise<boolean>} A promise that is resolved with `true`
- * if some /AcroForm fields have JavaScript actions.
- */
- hasJSActions(): Promise<boolean>;
- /**
- * @returns {Promise<Array<string> | null>} A promise that is resolved with an
- * {Array<string>} containing IDs of annotations that have a calculation
- * action, or `null` when no such annotations are present in the PDF file.
- */
- getCalculationOrderIds(): Promise<Array<string> | null>;
- }
- /**
- * Page getViewport parameters.
- *
- * @typedef {Object} GetViewportParameters
- * @property {number} scale - The desired scale of the viewport.
- * @property {number} [rotation] - The desired rotation, in degrees, of
- * the viewport. If omitted it defaults to the page rotation.
- * @property {number} [offsetX] - The horizontal, i.e. x-axis, offset.
- * The default value is `0`.
- * @property {number} [offsetY] - The vertical, i.e. y-axis, offset.
- * The default value is `0`.
- * @property {boolean} [dontFlip] - If true, the y-axis will not be
- * flipped. The default value is `false`.
- */
- /**
- * Page getTextContent parameters.
- *
- * @typedef {Object} getTextContentParameters
- * @property {boolean} normalizeWhitespace - Replaces all occurrences of
- * whitespace with standard spaces (0x20). The default value is `false`.
- * @property {boolean} disableCombineTextItems - Do not attempt to combine
- * same line {@link TextItem}'s. The default value is `false`.
- * @property {boolean} [includeMarkedContent] - When true include marked
- * content items in the items array of TextContent. The default is `false`.
- */
- /**
- * Page text content.
- *
- * @typedef {Object} TextContent
- * @property {Array<TextItem | TextMarkedContent>} items - Array of
- * {@link TextItem} and {@link TextMarkedContent} objects. TextMarkedContent
- * items are included when includeMarkedContent is true.
- * @property {Object<string, TextStyle>} styles - {@link TextStyle} objects,
- * indexed by font name.
- */
- /**
- * Page text content part.
- *
- * @typedef {Object} TextItem
- * @property {string} str - Text content.
- * @property {string} dir - Text direction: 'ttb', 'ltr' or 'rtl'.
- * @property {Array<any>} transform - Transformation matrix.
- * @property {number} width - Width in device space.
- * @property {number} height - Height in device space.
- * @property {string} fontName - Font name used by PDF.js for converted font.
- *
- */
- /**
- * Page text marked content part.
- *
- * @typedef {Object} TextMarkedContent
- * @property {string} type - Either 'beginMarkedContent',
- * 'beginMarkedContentProps', or 'endMarkedContent'.
- * @property {string} id - The marked content identifier. Only used for type
- * 'beginMarkedContentProps'.
- */
- /**
- * Text style.
- *
- * @typedef {Object} TextStyle
- * @property {number} ascent - Font ascent.
- * @property {number} descent - Font descent.
- * @property {boolean} vertical - Whether or not the text is in vertical mode.
- * @property {string} fontFamily - The possible font family.
- */
- /**
- * Page annotation parameters.
- *
- * @typedef {Object} GetAnnotationsParameters
- * @property {string} intent - Determines the annotations that will be fetched,
- * can be either 'display' (viewable annotations) or 'print' (printable
- * annotations). If the parameter is omitted, all annotations are fetched.
- */
- /**
- * Page render parameters.
- *
- * @typedef {Object} RenderParameters
- * @property {Object} canvasContext - A 2D context of a DOM Canvas object.
- * @property {PageViewport} viewport - Rendering viewport obtained by calling
- * the `PDFPageProxy.getViewport` method.
- * @property {string} [intent] - Rendering intent, can be 'display' or 'print'.
- * The default value is 'display'.
- * @property {boolean} [renderInteractiveForms] - Whether or not interactive
- * form elements are rendered in the display layer. If so, we do not render
- * them on the canvas as well. The default value is `false`.
- * @property {Array<any>} [transform] - Additional transform, applied just
- * before viewport transform.
- * @property {Object} [imageLayer] - An object that has `beginLayout`,
- * `endLayout` and `appendImage` functions.
- * @property {Object} [canvasFactory] - The factory instance that will be used
- * when creating canvases. The default value is {new DOMCanvasFactory()}.
- * @property {Object | string} [background] - Background to use for the canvas.
- * Any valid `canvas.fillStyle` can be used: a `DOMString` parsed as CSS
- * <color> value, a `CanvasGradient` object (a linear or radial gradient) or
- * a `CanvasPattern` object (a repetitive image). The default value is
- * 'rgb(255,255,255)'.
- * @property {boolean} [includeAnnotationStorage] - Render stored interactive
- * form element data, from the {@link AnnotationStorage}-instance, onto the
- * canvas itself; useful e.g. for printing. The default value is `false`.
- * @property {Promise<OptionalContentConfig>} [optionalContentConfigPromise] -
- * A promise that should resolve with an {@link OptionalContentConfig}
- * created from `PDFDocumentProxy.getOptionalContentConfig`. If `null`,
- * the configuration will be fetched automatically with the default visibility
- * states set.
- */
- /**
- * Structure tree node. The root node will have a role "Root".
- *
- * @typedef {Object} StructTreeNode
- * @property {Array<StructTreeNode | StructTreeContent>} children - Array of
- * {@link StructTreeNode} and {@link StructTreeContent} objects.
- * @property {string} role - element's role, already mapped if a role map exists
- * in the PDF.
- */
- /**
- * Structure tree content.
- *
- * @typedef {Object} StructTreeContent
- * @property {string} type - either "content" for page and stream structure
- * elements or "object" for object references.
- * @property {string} id - unique id that will map to the text layer.
- */
- /**
- * PDF page operator list.
- *
- * @typedef {Object} PDFOperatorList
- * @property {Array<number>} fnArray - Array containing the operator functions.
- * @property {Array<any>} argsArray - Array containing the arguments of the
- * functions.
- */
- /**
- * Proxy to a `PDFPage` in the worker thread.
- */
- export class PDFPageProxy {
- constructor(pageIndex: any, pageInfo: any, transport: any, ownerDocument: any, pdfBug?: boolean);
- _pageIndex: any;
- _pageInfo: any;
- _ownerDocument: any;
- _transport: any;
- _stats: StatTimer | null;
- _pdfBug: boolean;
- commonObjs: any;
- objs: PDFObjects;
- cleanupAfterRender: boolean;
- pendingCleanup: boolean;
- _intentStates: Map<any, any>;
- destroyed: boolean;
- /**
- * @type {number} Page number of the page. First page is 1.
- */
- get pageNumber(): number;
- /**
- * @type {number} The number of degrees the page is rotated clockwise.
- */
- get rotate(): number;
- /**
- * @type {Object} The reference that points to this page. It has `num` and
- * `gen` properties.
- */
- get ref(): Object;
- /**
- * @type {number} The default size of units in 1/72nds of an inch.
- */
- get userUnit(): number;
- /**
- * @type {Array<number>} An array of the visible portion of the PDF page in
- * user space units [x1, y1, x2, y2].
- */
- get view(): number[];
- /**
- * @param {GetViewportParameters} params - Viewport parameters.
- * @returns {PageViewport} Contains 'width' and 'height' properties
- * along with transforms required for rendering.
- */
- getViewport({ scale, rotation, offsetX, offsetY, dontFlip, }?: GetViewportParameters): PageViewport;
- /**
- * @param {GetAnnotationsParameters} params - Annotation parameters.
- * @returns {Promise<Array<any>>} A promise that is resolved with an
- * {Array} of the annotation objects.
- */
- getAnnotations({ intent }?: GetAnnotationsParameters): Promise<Array<any>>;
- _annotationsPromise: any;
- _annotationsIntent: string | undefined;
- /**
- * @returns {Promise<Object>} A promise that is resolved with an
- * {Object} with JS actions.
- */
- getJSActions(): Promise<Object>;
- /**
- * @returns {Promise<Object | null>} A promise that is resolved with
- * an {Object} with a fake DOM object (a tree structure where elements
- * are {Object} with a name, attributes (class, style, ...), value and
- * children, very similar to a HTML DOM tree), or `null` if no XFA exists.
- */
- getXfa(): Promise<Object | null>;
- /**
- * Begins the process of rendering a page to the desired context.
- *
- * @param {RenderParameters} params Page render parameters.
- * @returns {RenderTask} An object that contains a promise that is
- * resolved when the page finishes rendering.
- */
- render({ canvasContext, viewport, intent, renderInteractiveForms, transform, imageLayer, canvasFactory, background, includeAnnotationStorage, optionalContentConfigPromise, }: RenderParameters, ...args: any[]): RenderTask;
- /**
- * @returns {Promise<PDFOperatorList>} A promise resolved with an
- * {@link PDFOperatorList} object that represents page's operator list.
- */
- getOperatorList(): Promise<PDFOperatorList>;
- /**
- * @param {getTextContentParameters} params - getTextContent parameters.
- * @returns {ReadableStream} Stream for reading text content chunks.
- */
- streamTextContent({ normalizeWhitespace, disableCombineTextItems, includeMarkedContent, }?: getTextContentParameters): ReadableStream;
- /**
- * @param {getTextContentParameters} params - getTextContent parameters.
- * @returns {Promise<TextContent>} A promise that is resolved with a
- * {@link TextContent} object that represents the page's text content.
- */
- getTextContent(params?: getTextContentParameters): Promise<TextContent>;
- /**
- * @returns {Promise<StructTreeNode>} A promise that is resolved with a
- * {@link StructTreeNode} object that represents the page's structure tree,
- * or `null` when no structure tree is present for the current page.
- */
- getStructTree(): Promise<StructTreeNode>;
- /**
- * Destroys the page object.
- * @private
- */
- private _destroy;
- _jsActionsPromise: any;
- _xfaPromise: any;
- _structTreePromise: any;
- /**
- * Cleans up resources allocated by the page.
- *
- * @param {boolean} [resetStats] - Reset page stats, if enabled.
- * The default value is `false`.
- * @returns {boolean} Indicates if clean-up was successfully run.
- */
- cleanup(resetStats?: boolean | undefined): boolean;
- /**
- * Attempts to clean up if rendering is in a state where that's possible.
- * @private
- */
- private _tryCleanup;
- /**
- * @private
- */
- private _startRenderPage;
- /**
- * @private
- */
- private _renderPageChunk;
- /**
- * @private
- */
- private _pumpOperatorList;
- /**
- * @private
- */
- private _abortOperatorList;
- /**
- * @type {Object} Returns page stats, if enabled; returns `null` otherwise.
- */
- get stats(): Object;
- }
- /**
- * @typedef {Object} PDFWorkerParameters
- * @property {string} [name] - The name of the worker.
- * @property {Object} [port] - The `workerPort` object.
- * @property {number} [verbosity] - Controls the logging level; the
- * constants from {@link VerbosityLevel} should be used.
- */
- /** @type {any} */
- export const PDFWorker: any;
- /**
- * Sets the function that instantiates an {IPDFStream} as an alternative PDF
- * data transport.
- *
- * @param {IPDFStreamFactory} pdfNetworkStreamFactory - The factory function
- * that takes document initialization parameters (including a "url") and
- * returns a promise which is resolved with an instance of {IPDFStream}.
- * @ignore
- */
- export function setPDFNetworkStreamFactory(pdfNetworkStreamFactory: IPDFStreamFactory): void;
- /** @type {string} */
- export const version: string;
- import { PageViewport } from "./display_utils.js";
- import { OptionalContentConfig } from "./optional_content_config.js";
- import { DOMCanvasFactory } from "./display_utils.js";
- import { DOMCMapReaderFactory } from "./display_utils.js";
- /**
- * The loading task controls the operations required to load a PDF document
- * (such as network requests) and provides a way to listen for completion,
- * after which individual pages can be rendered.
- *
- * @typedef {Object} PDFDocumentLoadingTask
- * @property {string} docId - Unique identifier for the document loading task.
- * @property {boolean} destroyed - Whether the loading task is destroyed or not.
- * @property {function} [onPassword] - Callback to request a password if a wrong
- * or no password was provided. The callback receives two parameters: a
- * function that should be called with the new password, and a reason (see
- * {@link PasswordResponses}).
- * @property {function} [onProgress] - Callback to be able to monitor the
- * loading progress of the PDF file (necessary to implement e.g. a loading
- * bar). The callback receives an {Object} with the properties `loaded`
- * ({number}) and `total` ({number}) that indicate how many bytes are loaded.
- * @property {function} [onUnsupportedFeature] - Callback for when an
- * unsupported feature is used in the PDF document. The callback receives an
- * {@link UNSUPPORTED_FEATURES} argument.
- * @property {Promise<PDFDocumentProxy>} promise - Promise for document loading
- * task completion.
- * @property {function} destroy - Abort all network requests and destroy
- * the worker. Returns a promise that is resolved when destruction is
- * completed.
- */
- /**
- * @type {any}
- * @ignore
- */
- declare const PDFDocumentLoadingTask: any;
- import { AnnotationStorage } from "./annotation_storage.js";
- import { info } from "../shared/util.js";
- import { Metadata } from "./metadata.js";
- import { StatTimer } from "./display_utils.js";
- /**
- * A PDF document and page is built of many objects. E.g. there are objects for
- * fonts, images, rendering code, etc. These objects may get processed inside of
- * a worker. This class implements some basic methods to manage these objects.
- * @ignore
- */
- declare class PDFObjects {
- _objs: any;
- /**
- * Ensures there is an object defined for `objId`.
- * @private
- */
- private _ensureObj;
- /**
- * If called *without* callback, this returns the data of `objId` but the
- * object needs to be resolved. If it isn't, this method throws.
- *
- * If called *with* a callback, the callback is called with the data of the
- * object once the object is resolved. That means, if you call this method
- * and the object is already resolved, the callback gets called right away.
- */
- get(objId: any, callback?: any): any;
- has(objId: any): any;
- /**
- * Resolves the object `objId` with optional `data`.
- */
- resolve(objId: any, data: any): void;
- clear(): void;
- }
- /**
- * Allows controlling of the rendering tasks.
- */
- declare class RenderTask {
- constructor(internalRenderTask: any);
- _internalRenderTask: any;
- /**
- * Callback for incremental rendering -- a function that will be called
- * each time the rendering is paused. To continue rendering call the
- * function that is the first argument to the callback.
- * @type {function}
- */
- onContinue: Function;
- /**
- * Promise for rendering task completion.
- * @type {Promise<void>}
- */
- get promise(): Promise<void>;
- /**
- * Cancels the rendering task. If the task is currently rendering it will
- * not be cancelled until graphics pauses with a timeout. The promise that
- * this object extends will be rejected when cancelled.
- */
- cancel(): void;
- }
- export {};
|