api.d.ts 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  1. export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
  2. /**
  3. * Document initialization / loading parameters object.
  4. */
  5. export type DocumentInitParameters = {
  6. /**
  7. * - The URL of the PDF.
  8. */
  9. url?: string | URL | undefined;
  10. /**
  11. * - Binary PDF data. Use
  12. * typed arrays (Uint8Array) to improve the memory usage. If PDF data is
  13. * BASE64-encoded, use `atob()` to convert it to a binary string first.
  14. */
  15. data?: string | number[] | TypedArray | undefined;
  16. /**
  17. * - Basic authentication headers.
  18. */
  19. httpHeaders?: Object | undefined;
  20. /**
  21. * - Indicates whether or not
  22. * cross-site Access-Control requests should be made using credentials such
  23. * as cookies or authorization headers. The default is `false`.
  24. */
  25. withCredentials?: boolean | undefined;
  26. /**
  27. * - For decrypting password-protected PDFs.
  28. */
  29. password?: string | undefined;
  30. /**
  31. * - A typed array with the first portion
  32. * or all of the pdf data. Used by the extension since some data is already
  33. * loaded before the switch to range requests.
  34. */
  35. initialData?: TypedArray | undefined;
  36. /**
  37. * - The PDF file length. It's used for progress
  38. * reports and range requests operations.
  39. */
  40. length?: number | undefined;
  41. /**
  42. * - Allows for using a custom range
  43. * transport implementation.
  44. */
  45. range?: PDFDataRangeTransport | undefined;
  46. /**
  47. * - Specify maximum number of bytes fetched
  48. * per range request. The default value is {@link DEFAULT_RANGE_CHUNK_SIZE }.
  49. */
  50. rangeChunkSize?: number | undefined;
  51. /**
  52. * - The worker that will be used for loading and
  53. * parsing the PDF data.
  54. */
  55. worker?: any;
  56. /**
  57. * - Controls the logging level; the constants
  58. * from {@link VerbosityLevel } should be used.
  59. */
  60. verbosity?: number | undefined;
  61. /**
  62. * - The base URL of the document, used when
  63. * attempting to recover valid absolute URLs for annotations, and outline
  64. * items, that (incorrectly) only specify relative URLs.
  65. */
  66. docBaseUrl?: string | undefined;
  67. /**
  68. * - The URL where the predefined Adobe CMaps are
  69. * located. Include the trailing slash.
  70. */
  71. cMapUrl?: string | undefined;
  72. /**
  73. * - Specifies if the Adobe CMaps are binary
  74. * packed or not.
  75. */
  76. cMapPacked?: boolean | undefined;
  77. /**
  78. * - The factory that will be used when
  79. * reading built-in CMap files. Providing a custom factory is useful for
  80. * environments without Fetch API or `XMLHttpRequest` support, such as
  81. * Node.js. The default value is {DOMCMapReaderFactory}.
  82. */
  83. CMapReaderFactory?: Object | undefined;
  84. /**
  85. * - Reject certain promises, e.g.
  86. * `getOperatorList`, `getTextContent`, and `RenderTask`, when the associated
  87. * PDF data cannot be successfully parsed, instead of attempting to recover
  88. * whatever possible of the data. The default value is `false`.
  89. */
  90. stopAtErrors?: boolean | undefined;
  91. /**
  92. * - The maximum allowed image size in total
  93. * pixels, i.e. width * height. Images above this value will not be rendered.
  94. * Use -1 for no limit, which is also the default value.
  95. */
  96. maxImageSize?: number | undefined;
  97. /**
  98. * - Determines if we can evaluate strings
  99. * as JavaScript. Primarily used to improve performance of font rendering, and
  100. * when parsing PDF functions. The default value is `true`.
  101. */
  102. isEvalSupported?: boolean | undefined;
  103. /**
  104. * - By default fonts are converted to
  105. * OpenType fonts and loaded via `@font-face` rules. If disabled, fonts will
  106. * be rendered using a built-in font renderer that constructs the glyphs with
  107. * primitive path commands. The default value is `false`.
  108. */
  109. disableFontFace?: boolean | undefined;
  110. /**
  111. * - Include additional properties,
  112. * which are unused during rendering of PDF documents, when exporting the
  113. * parsed font data from the worker-thread. This may be useful for debugging
  114. * purposes (and backwards compatibility), but note that it will lead to
  115. * increased memory usage. The default value is `false`.
  116. */
  117. fontExtraProperties?: boolean | undefined;
  118. /**
  119. * - Render Xfa forms if any.
  120. * The default value is `false`.
  121. */
  122. enableXfa?: boolean | undefined;
  123. /**
  124. * - Specify an explicit document
  125. * context to create elements with and to load resources, such as fonts,
  126. * into. Defaults to the current document.
  127. */
  128. ownerDocument?: HTMLDocument | undefined;
  129. /**
  130. * - Disable range request loading of PDF
  131. * files. When enabled, and if the server supports partial content requests,
  132. * then the PDF will be fetched in chunks. The default value is `false`.
  133. */
  134. disableRange?: boolean | undefined;
  135. /**
  136. * - Disable streaming of PDF file data.
  137. * By default PDF.js attempts to load PDF files in chunks. The default value
  138. * is `false`.
  139. */
  140. disableStream?: boolean | undefined;
  141. /**
  142. * - Disable pre-fetching of PDF file
  143. * data. When range requests are enabled PDF.js will automatically keep
  144. * fetching more data even if it isn't needed to display the current page.
  145. * The default value is `false`.
  146. *
  147. * NOTE: It is also necessary to disable streaming, see above, in order for
  148. * disabling of pre-fetching to work correctly.
  149. */
  150. disableAutoFetch?: boolean | undefined;
  151. /**
  152. * - Enables special hooks for debugging PDF.js
  153. * (see `web/debugger.js`). The default value is `false`.
  154. */
  155. pdfBug?: boolean | undefined;
  156. };
  157. export type IPDFStreamFactory = Function;
  158. /**
  159. * The loading task controls the operations required to load a PDF document
  160. * (such as network requests) and provides a way to listen for completion,
  161. * after which individual pages can be rendered.
  162. */
  163. export type PDFDocumentLoadingTask = {
  164. /**
  165. * - Unique identifier for the document loading task.
  166. */
  167. docId: string;
  168. /**
  169. * - Whether the loading task is destroyed or not.
  170. */
  171. destroyed: boolean;
  172. /**
  173. * - Callback to request a password if a wrong
  174. * or no password was provided. The callback receives two parameters: a
  175. * function that should be called with the new password, and a reason (see
  176. * {@link PasswordResponses }).
  177. */
  178. onPassword?: Function | undefined;
  179. /**
  180. * - Callback to be able to monitor the
  181. * loading progress of the PDF file (necessary to implement e.g. a loading
  182. * bar). The callback receives an {Object} with the properties `loaded`
  183. * ({number}) and `total` ({number}) that indicate how many bytes are loaded.
  184. */
  185. onProgress?: Function | undefined;
  186. /**
  187. * - Callback for when an
  188. * unsupported feature is used in the PDF document. The callback receives an
  189. * {@link UNSUPPORTED_FEATURES } argument.
  190. */
  191. onUnsupportedFeature?: Function | undefined;
  192. /**
  193. * - Promise for document loading
  194. * task completion.
  195. */
  196. promise: Promise<PDFDocumentProxy>;
  197. /**
  198. * - Abort all network requests and destroy
  199. * the worker. Returns a promise that is resolved when destruction is
  200. * completed.
  201. */
  202. destroy: Function;
  203. };
  204. /**
  205. * Page getViewport parameters.
  206. */
  207. export type GetViewportParameters = {
  208. /**
  209. * - The desired scale of the viewport.
  210. */
  211. scale: number;
  212. /**
  213. * - The desired rotation, in degrees, of
  214. * the viewport. If omitted it defaults to the page rotation.
  215. */
  216. rotation?: number | undefined;
  217. /**
  218. * - The horizontal, i.e. x-axis, offset.
  219. * The default value is `0`.
  220. */
  221. offsetX?: number | undefined;
  222. /**
  223. * - The vertical, i.e. y-axis, offset.
  224. * The default value is `0`.
  225. */
  226. offsetY?: number | undefined;
  227. /**
  228. * - If true, the y-axis will not be
  229. * flipped. The default value is `false`.
  230. */
  231. dontFlip?: boolean | undefined;
  232. };
  233. /**
  234. * Page getTextContent parameters.
  235. */
  236. export type getTextContentParameters = {
  237. /**
  238. * - Replaces all occurrences of
  239. * whitespace with standard spaces (0x20). The default value is `false`.
  240. */
  241. normalizeWhitespace: boolean;
  242. /**
  243. * - Do not attempt to combine
  244. * same line {@link TextItem }'s. The default value is `false`.
  245. */
  246. disableCombineTextItems: boolean;
  247. /**
  248. * - When true include marked
  249. * content items in the items array of TextContent. The default is `false`.
  250. */
  251. includeMarkedContent?: boolean | undefined;
  252. };
  253. /**
  254. * Page text content.
  255. */
  256. export type TextContent = {
  257. /**
  258. * - Array of
  259. * {@link TextItem } and {@link TextMarkedContent } objects. TextMarkedContent
  260. * items are included when includeMarkedContent is true.
  261. */
  262. items: Array<TextItem | TextMarkedContent>;
  263. /**
  264. * - {@link TextStyle } objects,
  265. * indexed by font name.
  266. */
  267. styles: {
  268. [x: string]: TextStyle;
  269. };
  270. };
  271. /**
  272. * Page text content part.
  273. */
  274. export type TextItem = {
  275. /**
  276. * - Text content.
  277. */
  278. str: string;
  279. /**
  280. * - Text direction: 'ttb', 'ltr' or 'rtl'.
  281. */
  282. dir: string;
  283. /**
  284. * - Transformation matrix.
  285. */
  286. transform: Array<any>;
  287. /**
  288. * - Width in device space.
  289. */
  290. width: number;
  291. /**
  292. * - Height in device space.
  293. */
  294. height: number;
  295. /**
  296. * - Font name used by PDF.js for converted font.
  297. */
  298. fontName: string;
  299. };
  300. /**
  301. * Page text marked content part.
  302. */
  303. export type TextMarkedContent = {
  304. /**
  305. * - Either 'beginMarkedContent',
  306. * 'beginMarkedContentProps', or 'endMarkedContent'.
  307. */
  308. type: string;
  309. /**
  310. * - The marked content identifier. Only used for type
  311. * 'beginMarkedContentProps'.
  312. */
  313. id: string;
  314. };
  315. /**
  316. * Text style.
  317. */
  318. export type TextStyle = {
  319. /**
  320. * - Font ascent.
  321. */
  322. ascent: number;
  323. /**
  324. * - Font descent.
  325. */
  326. descent: number;
  327. /**
  328. * - Whether or not the text is in vertical mode.
  329. */
  330. vertical: boolean;
  331. /**
  332. * - The possible font family.
  333. */
  334. fontFamily: string;
  335. };
  336. /**
  337. * Page annotation parameters.
  338. */
  339. export type GetAnnotationsParameters = {
  340. /**
  341. * - Determines the annotations that will be fetched,
  342. * can be either 'display' (viewable annotations) or 'print' (printable
  343. * annotations). If the parameter is omitted, all annotations are fetched.
  344. */
  345. intent: string;
  346. };
  347. /**
  348. * Page render parameters.
  349. */
  350. export type RenderParameters = {
  351. /**
  352. * - A 2D context of a DOM Canvas object.
  353. */
  354. canvasContext: Object;
  355. /**
  356. * - Rendering viewport obtained by calling
  357. * the `PDFPageProxy.getViewport` method.
  358. */
  359. viewport: PageViewport;
  360. /**
  361. * - Rendering intent, can be 'display' or 'print'.
  362. * The default value is 'display'.
  363. */
  364. intent?: string | undefined;
  365. /**
  366. * - Whether or not interactive
  367. * form elements are rendered in the display layer. If so, we do not render
  368. * them on the canvas as well. The default value is `false`.
  369. */
  370. renderInteractiveForms?: boolean | undefined;
  371. /**
  372. * - Additional transform, applied just
  373. * before viewport transform.
  374. */
  375. transform?: any[] | undefined;
  376. /**
  377. * - An object that has `beginLayout`,
  378. * `endLayout` and `appendImage` functions.
  379. */
  380. imageLayer?: Object | undefined;
  381. /**
  382. * - The factory instance that will be used
  383. * when creating canvases. The default value is {new DOMCanvasFactory()}.
  384. */
  385. canvasFactory?: Object | undefined;
  386. /**
  387. * - Background to use for the canvas.
  388. * Any valid `canvas.fillStyle` can be used: a `DOMString` parsed as CSS
  389. * <color> value, a `CanvasGradient` object (a linear or radial gradient) or
  390. * a `CanvasPattern` object (a repetitive image). The default value is
  391. * 'rgb(255,255,255)'.
  392. */
  393. background?: string | Object | undefined;
  394. /**
  395. * - Render stored interactive
  396. * form element data, from the {@link AnnotationStorage }-instance, onto the
  397. * canvas itself; useful e.g. for printing. The default value is `false`.
  398. */
  399. includeAnnotationStorage?: boolean | undefined;
  400. /**
  401. * -
  402. * A promise that should resolve with an {@link OptionalContentConfig }created from `PDFDocumentProxy.getOptionalContentConfig`. If `null`,
  403. * the configuration will be fetched automatically with the default visibility
  404. * states set.
  405. */
  406. optionalContentConfigPromise?: Promise<OptionalContentConfig> | undefined;
  407. };
  408. /**
  409. * Structure tree node. The root node will have a role "Root".
  410. */
  411. export type StructTreeNode = {
  412. /**
  413. * - Array of
  414. * {@link StructTreeNode } and {@link StructTreeContent } objects.
  415. */
  416. children: Array<StructTreeNode | StructTreeContent>;
  417. /**
  418. * - element's role, already mapped if a role map exists
  419. * in the PDF.
  420. */
  421. role: string;
  422. };
  423. /**
  424. * Structure tree content.
  425. */
  426. export type StructTreeContent = {
  427. /**
  428. * - either "content" for page and stream structure
  429. * elements or "object" for object references.
  430. */
  431. type: string;
  432. /**
  433. * - unique id that will map to the text layer.
  434. */
  435. id: string;
  436. };
  437. /**
  438. * PDF page operator list.
  439. */
  440. export type PDFOperatorList = {
  441. /**
  442. * - Array containing the operator functions.
  443. */
  444. fnArray: Array<number>;
  445. /**
  446. * - Array containing the arguments of the
  447. * functions.
  448. */
  449. argsArray: Array<any>;
  450. };
  451. export type PDFWorkerParameters = {
  452. /**
  453. * - The name of the worker.
  454. */
  455. name?: string | undefined;
  456. /**
  457. * - The `workerPort` object.
  458. */
  459. port?: Object | undefined;
  460. /**
  461. * - Controls the logging level; the
  462. * constants from {@link VerbosityLevel } should be used.
  463. */
  464. verbosity?: number | undefined;
  465. };
  466. /** @type {string} */
  467. export const build: string;
  468. export const DefaultCanvasFactory: typeof DOMCanvasFactory | {
  469. new (): {};
  470. };
  471. export const DefaultCMapReaderFactory: typeof DOMCMapReaderFactory | {
  472. new (): {};
  473. };
  474. /**
  475. * @typedef { Int8Array | Uint8Array | Uint8ClampedArray |
  476. * Int16Array | Uint16Array |
  477. * Int32Array | Uint32Array | Float32Array |
  478. * Float64Array
  479. * } TypedArray
  480. */
  481. /**
  482. * Document initialization / loading parameters object.
  483. *
  484. * @typedef {Object} DocumentInitParameters
  485. * @property {string|URL} [url] - The URL of the PDF.
  486. * @property {TypedArray|Array<number>|string} [data] - Binary PDF data. Use
  487. * typed arrays (Uint8Array) to improve the memory usage. If PDF data is
  488. * BASE64-encoded, use `atob()` to convert it to a binary string first.
  489. * @property {Object} [httpHeaders] - Basic authentication headers.
  490. * @property {boolean} [withCredentials] - Indicates whether or not
  491. * cross-site Access-Control requests should be made using credentials such
  492. * as cookies or authorization headers. The default is `false`.
  493. * @property {string} [password] - For decrypting password-protected PDFs.
  494. * @property {TypedArray} [initialData] - A typed array with the first portion
  495. * or all of the pdf data. Used by the extension since some data is already
  496. * loaded before the switch to range requests.
  497. * @property {number} [length] - The PDF file length. It's used for progress
  498. * reports and range requests operations.
  499. * @property {PDFDataRangeTransport} [range] - Allows for using a custom range
  500. * transport implementation.
  501. * @property {number} [rangeChunkSize] - Specify maximum number of bytes fetched
  502. * per range request. The default value is {@link DEFAULT_RANGE_CHUNK_SIZE}.
  503. * @property {PDFWorker} [worker] - The worker that will be used for loading and
  504. * parsing the PDF data.
  505. * @property {number} [verbosity] - Controls the logging level; the constants
  506. * from {@link VerbosityLevel} should be used.
  507. * @property {string} [docBaseUrl] - The base URL of the document, used when
  508. * attempting to recover valid absolute URLs for annotations, and outline
  509. * items, that (incorrectly) only specify relative URLs.
  510. * @property {string} [cMapUrl] - The URL where the predefined Adobe CMaps are
  511. * located. Include the trailing slash.
  512. * @property {boolean} [cMapPacked] - Specifies if the Adobe CMaps are binary
  513. * packed or not.
  514. * @property {Object} [CMapReaderFactory] - The factory that will be used when
  515. * reading built-in CMap files. Providing a custom factory is useful for
  516. * environments without Fetch API or `XMLHttpRequest` support, such as
  517. * Node.js. The default value is {DOMCMapReaderFactory}.
  518. * @property {boolean} [stopAtErrors] - Reject certain promises, e.g.
  519. * `getOperatorList`, `getTextContent`, and `RenderTask`, when the associated
  520. * PDF data cannot be successfully parsed, instead of attempting to recover
  521. * whatever possible of the data. The default value is `false`.
  522. * @property {number} [maxImageSize] - The maximum allowed image size in total
  523. * pixels, i.e. width * height. Images above this value will not be rendered.
  524. * Use -1 for no limit, which is also the default value.
  525. * @property {boolean} [isEvalSupported] - Determines if we can evaluate strings
  526. * as JavaScript. Primarily used to improve performance of font rendering, and
  527. * when parsing PDF functions. The default value is `true`.
  528. * @property {boolean} [disableFontFace] - By default fonts are converted to
  529. * OpenType fonts and loaded via `@font-face` rules. If disabled, fonts will
  530. * be rendered using a built-in font renderer that constructs the glyphs with
  531. * primitive path commands. The default value is `false`.
  532. * @property {boolean} [fontExtraProperties] - Include additional properties,
  533. * which are unused during rendering of PDF documents, when exporting the
  534. * parsed font data from the worker-thread. This may be useful for debugging
  535. * purposes (and backwards compatibility), but note that it will lead to
  536. * increased memory usage. The default value is `false`.
  537. * @property {boolean} [enableXfa] - Render Xfa forms if any.
  538. * The default value is `false`.
  539. * @property {HTMLDocument} [ownerDocument] - Specify an explicit document
  540. * context to create elements with and to load resources, such as fonts,
  541. * into. Defaults to the current document.
  542. * @property {boolean} [disableRange] - Disable range request loading of PDF
  543. * files. When enabled, and if the server supports partial content requests,
  544. * then the PDF will be fetched in chunks. The default value is `false`.
  545. * @property {boolean} [disableStream] - Disable streaming of PDF file data.
  546. * By default PDF.js attempts to load PDF files in chunks. The default value
  547. * is `false`.
  548. * @property {boolean} [disableAutoFetch] - Disable pre-fetching of PDF file
  549. * data. When range requests are enabled PDF.js will automatically keep
  550. * fetching more data even if it isn't needed to display the current page.
  551. * The default value is `false`.
  552. *
  553. * NOTE: It is also necessary to disable streaming, see above, in order for
  554. * disabling of pre-fetching to work correctly.
  555. * @property {boolean} [pdfBug] - Enables special hooks for debugging PDF.js
  556. * (see `web/debugger.js`). The default value is `false`.
  557. */
  558. /**
  559. * This is the main entry point for loading a PDF and interacting with it.
  560. *
  561. * NOTE: If a URL is used to fetch the PDF data a standard Fetch API call (or
  562. * XHR as fallback) is used, which means it must follow same origin rules,
  563. * e.g. no cross-domain requests without CORS.
  564. *
  565. * @param {string|URL|TypedArray|PDFDataRangeTransport|DocumentInitParameters}
  566. * src - Can be a URL where a PDF file is located, a typed array (Uint8Array)
  567. * already populated with data, or a parameter object.
  568. * @returns {PDFDocumentLoadingTask}
  569. */
  570. export function getDocument(src: string | URL | TypedArray | PDFDataRangeTransport | DocumentInitParameters): PDFDocumentLoadingTask;
  571. export class LoopbackPort {
  572. _listeners: any[];
  573. _deferred: Promise<undefined>;
  574. postMessage(obj: any, transfers: any): void;
  575. addEventListener(name: any, listener: any): void;
  576. removeEventListener(name: any, listener: any): void;
  577. terminate(): void;
  578. }
  579. /**
  580. * Abstract class to support range requests file loading.
  581. */
  582. export class PDFDataRangeTransport {
  583. /**
  584. * @param {number} length
  585. * @param {Uint8Array} initialData
  586. * @param {boolean} [progressiveDone]
  587. * @param {string} [contentDispositionFilename]
  588. */
  589. constructor(length: number, initialData: Uint8Array, progressiveDone?: boolean | undefined, contentDispositionFilename?: string | undefined);
  590. length: number;
  591. initialData: Uint8Array;
  592. progressiveDone: boolean;
  593. contentDispositionFilename: string;
  594. _rangeListeners: any[];
  595. _progressListeners: any[];
  596. _progressiveReadListeners: any[];
  597. _progressiveDoneListeners: any[];
  598. _readyCapability: import("../shared/util.js").PromiseCapability;
  599. addRangeListener(listener: any): void;
  600. addProgressListener(listener: any): void;
  601. addProgressiveReadListener(listener: any): void;
  602. addProgressiveDoneListener(listener: any): void;
  603. onDataRange(begin: any, chunk: any): void;
  604. onDataProgress(loaded: any, total: any): void;
  605. onDataProgressiveRead(chunk: any): void;
  606. onDataProgressiveDone(): void;
  607. transportReady(): void;
  608. requestDataRange(begin: any, end: any): void;
  609. abort(): void;
  610. }
  611. /**
  612. * Proxy to a `PDFDocument` in the worker thread.
  613. */
  614. export class PDFDocumentProxy {
  615. constructor(pdfInfo: any, transport: any);
  616. _pdfInfo: any;
  617. _transport: any;
  618. /**
  619. * @type {AnnotationStorage} Storage for annotation data in forms.
  620. */
  621. get annotationStorage(): AnnotationStorage;
  622. /**
  623. * @type {number} Total number of pages in the PDF file.
  624. */
  625. get numPages(): number;
  626. /**
  627. * @type {string} A (not guaranteed to be) unique ID to identify a PDF.
  628. */
  629. get fingerprint(): string;
  630. /**
  631. * @type {boolean} True if only XFA form.
  632. */
  633. get isPureXfa(): boolean;
  634. /**
  635. * @param {number} pageNumber - The page number to get. The first page is 1.
  636. * @returns {Promise<PDFPageProxy>} A promise that is resolved with
  637. * a {@link PDFPageProxy} object.
  638. */
  639. getPage(pageNumber: number): Promise<PDFPageProxy>;
  640. /**
  641. * @typedef {Object} RefProxy
  642. * @property {number} num
  643. * @property {number} gen
  644. */
  645. /**
  646. * @param {RefProxy} ref - The page reference.
  647. * @returns {Promise<number>} A promise that is resolved with the page index,
  648. * starting from zero, that is associated with the reference.
  649. */
  650. getPageIndex(ref: {
  651. num: number;
  652. gen: number;
  653. }): Promise<number>;
  654. /**
  655. * @returns {Promise<Object<string, Array<any>>>} A promise that is resolved
  656. * with a mapping from named destinations to references.
  657. *
  658. * This can be slow for large documents. Use `getDestination` instead.
  659. */
  660. getDestinations(): Promise<{
  661. [x: string]: Array<any>;
  662. }>;
  663. /**
  664. * @param {string} id - The named destination to get.
  665. * @returns {Promise<Array<any> | null>} A promise that is resolved with all
  666. * information of the given named destination, or `null` when the named
  667. * destination is not present in the PDF file.
  668. */
  669. getDestination(id: string): Promise<Array<any> | null>;
  670. /**
  671. * @returns {Promise<Array<string> | null>} A promise that is resolved with
  672. * an {Array} containing the page labels that correspond to the page
  673. * indexes, or `null` when no page labels are present in the PDF file.
  674. */
  675. getPageLabels(): Promise<Array<string> | null>;
  676. /**
  677. * @returns {Promise<string>} A promise that is resolved with a {string}
  678. * containing the page layout name.
  679. */
  680. getPageLayout(): Promise<string>;
  681. /**
  682. * @returns {Promise<string>} A promise that is resolved with a {string}
  683. * containing the page mode name.
  684. */
  685. getPageMode(): Promise<string>;
  686. /**
  687. * @returns {Promise<Object | null>} A promise that is resolved with an
  688. * {Object} containing the viewer preferences, or `null` when no viewer
  689. * preferences are present in the PDF file.
  690. */
  691. getViewerPreferences(): Promise<Object | null>;
  692. /**
  693. * @returns {Promise<any | null>} A promise that is resolved with an {Array}
  694. * containing the destination, or `null` when no open action is present
  695. * in the PDF.
  696. */
  697. getOpenAction(): Promise<any | null>;
  698. /**
  699. * @returns {Promise<any>} A promise that is resolved with a lookup table
  700. * for mapping named attachments to their content.
  701. */
  702. getAttachments(): Promise<any>;
  703. /**
  704. * @returns {Promise<Array<string> | null>} A promise that is resolved with
  705. * an {Array} of all the JavaScript strings in the name tree, or `null`
  706. * if no JavaScript exists.
  707. */
  708. getJavaScript(): Promise<Array<string> | null>;
  709. /**
  710. * @returns {Promise<Object | null>} A promise that is resolved with
  711. * an {Object} with the JavaScript actions:
  712. * - from the name tree (like getJavaScript);
  713. * - from A or AA entries in the catalog dictionary.
  714. * , or `null` if no JavaScript exists.
  715. */
  716. getJSActions(): Promise<Object | null>;
  717. /**
  718. * @typedef {Object} OutlineNode
  719. * @property {string} title
  720. * @property {boolean} bold
  721. * @property {boolean} italic
  722. * @property {Uint8ClampedArray} color - The color in RGB format to use for
  723. * display purposes.
  724. * @property {string | Array<any> | null} dest
  725. * @property {string | null} url
  726. * @property {string | undefined} unsafeUrl
  727. * @property {boolean | undefined} newWindow
  728. * @property {number | undefined} count
  729. * @property {Array<OutlineNode>} items
  730. */
  731. /**
  732. * @returns {Promise<Array<OutlineNode>>} A promise that is resolved with an
  733. * {Array} that is a tree outline (if it has one) of the PDF file.
  734. */
  735. getOutline(): Promise<{
  736. title: string;
  737. bold: boolean;
  738. italic: boolean;
  739. /**
  740. * - The color in RGB format to use for
  741. * display purposes.
  742. */
  743. color: Uint8ClampedArray;
  744. dest: string | Array<any> | null;
  745. url: string | null;
  746. unsafeUrl: string | undefined;
  747. newWindow: boolean | undefined;
  748. count: number | undefined;
  749. items: any[];
  750. }[]>;
  751. /**
  752. * @returns {Promise<OptionalContentConfig>} A promise that is resolved with
  753. * an {@link OptionalContentConfig} that contains all the optional content
  754. * groups (assuming that the document has any).
  755. */
  756. getOptionalContentConfig(): Promise<OptionalContentConfig>;
  757. /**
  758. * @returns {Promise<Array<number> | null>} A promise that is resolved with
  759. * an {Array} that contains the permission flags for the PDF document, or
  760. * `null` when no permissions are present in the PDF file.
  761. */
  762. getPermissions(): Promise<Array<number> | null>;
  763. /**
  764. * @returns {Promise<{ info: Object, metadata: Metadata }>} A promise that is
  765. * resolved with an {Object} that has `info` and `metadata` properties.
  766. * `info` is an {Object} filled with anything available in the information
  767. * dictionary and similarly `metadata` is a {Metadata} object with
  768. * information from the metadata section of the PDF.
  769. */
  770. getMetadata(): Promise<{
  771. info: Object;
  772. metadata: Metadata;
  773. }>;
  774. /**
  775. * @typedef {Object} MarkInfo
  776. * Properties correspond to Table 321 of the PDF 32000-1:2008 spec.
  777. * @property {boolean} Marked
  778. * @property {boolean} UserProperties
  779. * @property {boolean} Suspects
  780. */
  781. /**
  782. * @returns {Promise<MarkInfo | null>} A promise that is resolved with
  783. * a {MarkInfo} object that contains the MarkInfo flags for the PDF
  784. * document, or `null` when no MarkInfo values are present in the PDF file.
  785. */
  786. getMarkInfo(): Promise<{
  787. Marked: boolean;
  788. UserProperties: boolean;
  789. Suspects: boolean;
  790. } | null>;
  791. /**
  792. * @returns {Promise<TypedArray>} A promise that is resolved with a
  793. * {TypedArray} that has the raw data from the PDF.
  794. */
  795. getData(): Promise<TypedArray>;
  796. /**
  797. * @returns {Promise<{ length: number }>} A promise that is resolved when the
  798. * document's data is loaded. It is resolved with an {Object} that contains
  799. * the `length` property that indicates size of the PDF data in bytes.
  800. */
  801. getDownloadInfo(): Promise<{
  802. length: number;
  803. }>;
  804. /**
  805. * @typedef {Object} PDFDocumentStats
  806. * @property {Object<string, boolean>} streamTypes - Used stream types in the
  807. * document (an item is set to true if specific stream ID was used in the
  808. * document).
  809. * @property {Object<string, boolean>} fontTypes - Used font types in the
  810. * document (an item is set to true if specific font ID was used in the
  811. * document).
  812. */
  813. /**
  814. * @returns {Promise<PDFDocumentStats>} A promise this is resolved with
  815. * current statistics about document structures (see
  816. * {@link PDFDocumentStats}).
  817. */
  818. getStats(): Promise<{
  819. /**
  820. * - Used stream types in the
  821. * document (an item is set to true if specific stream ID was used in the
  822. * document).
  823. */
  824. streamTypes: {
  825. [x: string]: boolean;
  826. };
  827. /**
  828. * - Used font types in the
  829. * document (an item is set to true if specific font ID was used in the
  830. * document).
  831. */
  832. fontTypes: {
  833. [x: string]: boolean;
  834. };
  835. }>;
  836. /**
  837. * Cleans up resources allocated by the document on both the main and worker
  838. * threads.
  839. *
  840. * NOTE: Do not, under any circumstances, call this method when rendering is
  841. * currently ongoing since that may lead to rendering errors.
  842. *
  843. * @param {boolean} [keepLoadedFonts] - Let fonts remain attached to the DOM.
  844. * NOTE: This will increase persistent memory usage, hence don't use this
  845. * option unless absolutely necessary. The default value is `false`.
  846. * @returns {Promise} A promise that is resolved when clean-up has finished.
  847. */
  848. cleanup(keepLoadedFonts?: boolean | undefined): Promise<any>;
  849. /**
  850. * Destroys the current document instance and terminates the worker.
  851. */
  852. destroy(): any;
  853. /**
  854. * @type {DocumentInitParameters} A subset of the current
  855. * {DocumentInitParameters}, which are either needed in the viewer and/or
  856. * whose default values may be affected by the `apiCompatibilityParams`.
  857. */
  858. get loadingParams(): DocumentInitParameters;
  859. /**
  860. * @type {PDFDocumentLoadingTask} The loadingTask for the current document.
  861. */
  862. get loadingTask(): PDFDocumentLoadingTask;
  863. /**
  864. * @returns {Promise<Uint8Array>} A promise that is resolved with a
  865. * {Uint8Array} containing the full data of the saved document.
  866. */
  867. saveDocument(...args: any[]): Promise<Uint8Array>;
  868. /**
  869. * @returns {Promise<Array<Object> | null>} A promise that is resolved with an
  870. * {Array<Object>} containing /AcroForm field data for the JS sandbox,
  871. * or `null` when no field data is present in the PDF file.
  872. */
  873. getFieldObjects(): Promise<Array<Object> | null>;
  874. /**
  875. * @returns {Promise<boolean>} A promise that is resolved with `true`
  876. * if some /AcroForm fields have JavaScript actions.
  877. */
  878. hasJSActions(): Promise<boolean>;
  879. /**
  880. * @returns {Promise<Array<string> | null>} A promise that is resolved with an
  881. * {Array<string>} containing IDs of annotations that have a calculation
  882. * action, or `null` when no such annotations are present in the PDF file.
  883. */
  884. getCalculationOrderIds(): Promise<Array<string> | null>;
  885. }
  886. /**
  887. * Page getViewport parameters.
  888. *
  889. * @typedef {Object} GetViewportParameters
  890. * @property {number} scale - The desired scale of the viewport.
  891. * @property {number} [rotation] - The desired rotation, in degrees, of
  892. * the viewport. If omitted it defaults to the page rotation.
  893. * @property {number} [offsetX] - The horizontal, i.e. x-axis, offset.
  894. * The default value is `0`.
  895. * @property {number} [offsetY] - The vertical, i.e. y-axis, offset.
  896. * The default value is `0`.
  897. * @property {boolean} [dontFlip] - If true, the y-axis will not be
  898. * flipped. The default value is `false`.
  899. */
  900. /**
  901. * Page getTextContent parameters.
  902. *
  903. * @typedef {Object} getTextContentParameters
  904. * @property {boolean} normalizeWhitespace - Replaces all occurrences of
  905. * whitespace with standard spaces (0x20). The default value is `false`.
  906. * @property {boolean} disableCombineTextItems - Do not attempt to combine
  907. * same line {@link TextItem}'s. The default value is `false`.
  908. * @property {boolean} [includeMarkedContent] - When true include marked
  909. * content items in the items array of TextContent. The default is `false`.
  910. */
  911. /**
  912. * Page text content.
  913. *
  914. * @typedef {Object} TextContent
  915. * @property {Array<TextItem | TextMarkedContent>} items - Array of
  916. * {@link TextItem} and {@link TextMarkedContent} objects. TextMarkedContent
  917. * items are included when includeMarkedContent is true.
  918. * @property {Object<string, TextStyle>} styles - {@link TextStyle} objects,
  919. * indexed by font name.
  920. */
  921. /**
  922. * Page text content part.
  923. *
  924. * @typedef {Object} TextItem
  925. * @property {string} str - Text content.
  926. * @property {string} dir - Text direction: 'ttb', 'ltr' or 'rtl'.
  927. * @property {Array<any>} transform - Transformation matrix.
  928. * @property {number} width - Width in device space.
  929. * @property {number} height - Height in device space.
  930. * @property {string} fontName - Font name used by PDF.js for converted font.
  931. *
  932. */
  933. /**
  934. * Page text marked content part.
  935. *
  936. * @typedef {Object} TextMarkedContent
  937. * @property {string} type - Either 'beginMarkedContent',
  938. * 'beginMarkedContentProps', or 'endMarkedContent'.
  939. * @property {string} id - The marked content identifier. Only used for type
  940. * 'beginMarkedContentProps'.
  941. */
  942. /**
  943. * Text style.
  944. *
  945. * @typedef {Object} TextStyle
  946. * @property {number} ascent - Font ascent.
  947. * @property {number} descent - Font descent.
  948. * @property {boolean} vertical - Whether or not the text is in vertical mode.
  949. * @property {string} fontFamily - The possible font family.
  950. */
  951. /**
  952. * Page annotation parameters.
  953. *
  954. * @typedef {Object} GetAnnotationsParameters
  955. * @property {string} intent - Determines the annotations that will be fetched,
  956. * can be either 'display' (viewable annotations) or 'print' (printable
  957. * annotations). If the parameter is omitted, all annotations are fetched.
  958. */
  959. /**
  960. * Page render parameters.
  961. *
  962. * @typedef {Object} RenderParameters
  963. * @property {Object} canvasContext - A 2D context of a DOM Canvas object.
  964. * @property {PageViewport} viewport - Rendering viewport obtained by calling
  965. * the `PDFPageProxy.getViewport` method.
  966. * @property {string} [intent] - Rendering intent, can be 'display' or 'print'.
  967. * The default value is 'display'.
  968. * @property {boolean} [renderInteractiveForms] - Whether or not interactive
  969. * form elements are rendered in the display layer. If so, we do not render
  970. * them on the canvas as well. The default value is `false`.
  971. * @property {Array<any>} [transform] - Additional transform, applied just
  972. * before viewport transform.
  973. * @property {Object} [imageLayer] - An object that has `beginLayout`,
  974. * `endLayout` and `appendImage` functions.
  975. * @property {Object} [canvasFactory] - The factory instance that will be used
  976. * when creating canvases. The default value is {new DOMCanvasFactory()}.
  977. * @property {Object | string} [background] - Background to use for the canvas.
  978. * Any valid `canvas.fillStyle` can be used: a `DOMString` parsed as CSS
  979. * <color> value, a `CanvasGradient` object (a linear or radial gradient) or
  980. * a `CanvasPattern` object (a repetitive image). The default value is
  981. * 'rgb(255,255,255)'.
  982. * @property {boolean} [includeAnnotationStorage] - Render stored interactive
  983. * form element data, from the {@link AnnotationStorage}-instance, onto the
  984. * canvas itself; useful e.g. for printing. The default value is `false`.
  985. * @property {Promise<OptionalContentConfig>} [optionalContentConfigPromise] -
  986. * A promise that should resolve with an {@link OptionalContentConfig}
  987. * created from `PDFDocumentProxy.getOptionalContentConfig`. If `null`,
  988. * the configuration will be fetched automatically with the default visibility
  989. * states set.
  990. */
  991. /**
  992. * Structure tree node. The root node will have a role "Root".
  993. *
  994. * @typedef {Object} StructTreeNode
  995. * @property {Array<StructTreeNode | StructTreeContent>} children - Array of
  996. * {@link StructTreeNode} and {@link StructTreeContent} objects.
  997. * @property {string} role - element's role, already mapped if a role map exists
  998. * in the PDF.
  999. */
  1000. /**
  1001. * Structure tree content.
  1002. *
  1003. * @typedef {Object} StructTreeContent
  1004. * @property {string} type - either "content" for page and stream structure
  1005. * elements or "object" for object references.
  1006. * @property {string} id - unique id that will map to the text layer.
  1007. */
  1008. /**
  1009. * PDF page operator list.
  1010. *
  1011. * @typedef {Object} PDFOperatorList
  1012. * @property {Array<number>} fnArray - Array containing the operator functions.
  1013. * @property {Array<any>} argsArray - Array containing the arguments of the
  1014. * functions.
  1015. */
  1016. /**
  1017. * Proxy to a `PDFPage` in the worker thread.
  1018. */
  1019. export class PDFPageProxy {
  1020. constructor(pageIndex: any, pageInfo: any, transport: any, ownerDocument: any, pdfBug?: boolean);
  1021. _pageIndex: any;
  1022. _pageInfo: any;
  1023. _ownerDocument: any;
  1024. _transport: any;
  1025. _stats: StatTimer | null;
  1026. _pdfBug: boolean;
  1027. commonObjs: any;
  1028. objs: PDFObjects;
  1029. cleanupAfterRender: boolean;
  1030. pendingCleanup: boolean;
  1031. _intentStates: Map<any, any>;
  1032. destroyed: boolean;
  1033. /**
  1034. * @type {number} Page number of the page. First page is 1.
  1035. */
  1036. get pageNumber(): number;
  1037. /**
  1038. * @type {number} The number of degrees the page is rotated clockwise.
  1039. */
  1040. get rotate(): number;
  1041. /**
  1042. * @type {Object} The reference that points to this page. It has `num` and
  1043. * `gen` properties.
  1044. */
  1045. get ref(): Object;
  1046. /**
  1047. * @type {number} The default size of units in 1/72nds of an inch.
  1048. */
  1049. get userUnit(): number;
  1050. /**
  1051. * @type {Array<number>} An array of the visible portion of the PDF page in
  1052. * user space units [x1, y1, x2, y2].
  1053. */
  1054. get view(): number[];
  1055. /**
  1056. * @param {GetViewportParameters} params - Viewport parameters.
  1057. * @returns {PageViewport} Contains 'width' and 'height' properties
  1058. * along with transforms required for rendering.
  1059. */
  1060. getViewport({ scale, rotation, offsetX, offsetY, dontFlip, }?: GetViewportParameters): PageViewport;
  1061. /**
  1062. * @param {GetAnnotationsParameters} params - Annotation parameters.
  1063. * @returns {Promise<Array<any>>} A promise that is resolved with an
  1064. * {Array} of the annotation objects.
  1065. */
  1066. getAnnotations({ intent }?: GetAnnotationsParameters): Promise<Array<any>>;
  1067. _annotationsPromise: any;
  1068. _annotationsIntent: string | undefined;
  1069. /**
  1070. * @returns {Promise<Object>} A promise that is resolved with an
  1071. * {Object} with JS actions.
  1072. */
  1073. getJSActions(): Promise<Object>;
  1074. /**
  1075. * @returns {Promise<Object | null>} A promise that is resolved with
  1076. * an {Object} with a fake DOM object (a tree structure where elements
  1077. * are {Object} with a name, attributes (class, style, ...), value and
  1078. * children, very similar to a HTML DOM tree), or `null` if no XFA exists.
  1079. */
  1080. getXfa(): Promise<Object | null>;
  1081. /**
  1082. * Begins the process of rendering a page to the desired context.
  1083. *
  1084. * @param {RenderParameters} params Page render parameters.
  1085. * @returns {RenderTask} An object that contains a promise that is
  1086. * resolved when the page finishes rendering.
  1087. */
  1088. render({ canvasContext, viewport, intent, renderInteractiveForms, transform, imageLayer, canvasFactory, background, includeAnnotationStorage, optionalContentConfigPromise, }: RenderParameters, ...args: any[]): RenderTask;
  1089. /**
  1090. * @returns {Promise<PDFOperatorList>} A promise resolved with an
  1091. * {@link PDFOperatorList} object that represents page's operator list.
  1092. */
  1093. getOperatorList(): Promise<PDFOperatorList>;
  1094. /**
  1095. * @param {getTextContentParameters} params - getTextContent parameters.
  1096. * @returns {ReadableStream} Stream for reading text content chunks.
  1097. */
  1098. streamTextContent({ normalizeWhitespace, disableCombineTextItems, includeMarkedContent, }?: getTextContentParameters): ReadableStream;
  1099. /**
  1100. * @param {getTextContentParameters} params - getTextContent parameters.
  1101. * @returns {Promise<TextContent>} A promise that is resolved with a
  1102. * {@link TextContent} object that represents the page's text content.
  1103. */
  1104. getTextContent(params?: getTextContentParameters): Promise<TextContent>;
  1105. /**
  1106. * @returns {Promise<StructTreeNode>} A promise that is resolved with a
  1107. * {@link StructTreeNode} object that represents the page's structure tree,
  1108. * or `null` when no structure tree is present for the current page.
  1109. */
  1110. getStructTree(): Promise<StructTreeNode>;
  1111. /**
  1112. * Destroys the page object.
  1113. * @private
  1114. */
  1115. private _destroy;
  1116. _jsActionsPromise: any;
  1117. _xfaPromise: any;
  1118. _structTreePromise: any;
  1119. /**
  1120. * Cleans up resources allocated by the page.
  1121. *
  1122. * @param {boolean} [resetStats] - Reset page stats, if enabled.
  1123. * The default value is `false`.
  1124. * @returns {boolean} Indicates if clean-up was successfully run.
  1125. */
  1126. cleanup(resetStats?: boolean | undefined): boolean;
  1127. /**
  1128. * Attempts to clean up if rendering is in a state where that's possible.
  1129. * @private
  1130. */
  1131. private _tryCleanup;
  1132. /**
  1133. * @private
  1134. */
  1135. private _startRenderPage;
  1136. /**
  1137. * @private
  1138. */
  1139. private _renderPageChunk;
  1140. /**
  1141. * @private
  1142. */
  1143. private _pumpOperatorList;
  1144. /**
  1145. * @private
  1146. */
  1147. private _abortOperatorList;
  1148. /**
  1149. * @type {Object} Returns page stats, if enabled; returns `null` otherwise.
  1150. */
  1151. get stats(): Object;
  1152. }
  1153. /**
  1154. * @typedef {Object} PDFWorkerParameters
  1155. * @property {string} [name] - The name of the worker.
  1156. * @property {Object} [port] - The `workerPort` object.
  1157. * @property {number} [verbosity] - Controls the logging level; the
  1158. * constants from {@link VerbosityLevel} should be used.
  1159. */
  1160. /** @type {any} */
  1161. export const PDFWorker: any;
  1162. /**
  1163. * Sets the function that instantiates an {IPDFStream} as an alternative PDF
  1164. * data transport.
  1165. *
  1166. * @param {IPDFStreamFactory} pdfNetworkStreamFactory - The factory function
  1167. * that takes document initialization parameters (including a "url") and
  1168. * returns a promise which is resolved with an instance of {IPDFStream}.
  1169. * @ignore
  1170. */
  1171. export function setPDFNetworkStreamFactory(pdfNetworkStreamFactory: IPDFStreamFactory): void;
  1172. /** @type {string} */
  1173. export const version: string;
  1174. import { PageViewport } from "./display_utils.js";
  1175. import { OptionalContentConfig } from "./optional_content_config.js";
  1176. import { DOMCanvasFactory } from "./display_utils.js";
  1177. import { DOMCMapReaderFactory } from "./display_utils.js";
  1178. /**
  1179. * The loading task controls the operations required to load a PDF document
  1180. * (such as network requests) and provides a way to listen for completion,
  1181. * after which individual pages can be rendered.
  1182. *
  1183. * @typedef {Object} PDFDocumentLoadingTask
  1184. * @property {string} docId - Unique identifier for the document loading task.
  1185. * @property {boolean} destroyed - Whether the loading task is destroyed or not.
  1186. * @property {function} [onPassword] - Callback to request a password if a wrong
  1187. * or no password was provided. The callback receives two parameters: a
  1188. * function that should be called with the new password, and a reason (see
  1189. * {@link PasswordResponses}).
  1190. * @property {function} [onProgress] - Callback to be able to monitor the
  1191. * loading progress of the PDF file (necessary to implement e.g. a loading
  1192. * bar). The callback receives an {Object} with the properties `loaded`
  1193. * ({number}) and `total` ({number}) that indicate how many bytes are loaded.
  1194. * @property {function} [onUnsupportedFeature] - Callback for when an
  1195. * unsupported feature is used in the PDF document. The callback receives an
  1196. * {@link UNSUPPORTED_FEATURES} argument.
  1197. * @property {Promise<PDFDocumentProxy>} promise - Promise for document loading
  1198. * task completion.
  1199. * @property {function} destroy - Abort all network requests and destroy
  1200. * the worker. Returns a promise that is resolved when destruction is
  1201. * completed.
  1202. */
  1203. /**
  1204. * @type {any}
  1205. * @ignore
  1206. */
  1207. declare const PDFDocumentLoadingTask: any;
  1208. import { AnnotationStorage } from "./annotation_storage.js";
  1209. import { info } from "../shared/util.js";
  1210. import { Metadata } from "./metadata.js";
  1211. import { StatTimer } from "./display_utils.js";
  1212. /**
  1213. * A PDF document and page is built of many objects. E.g. there are objects for
  1214. * fonts, images, rendering code, etc. These objects may get processed inside of
  1215. * a worker. This class implements some basic methods to manage these objects.
  1216. * @ignore
  1217. */
  1218. declare class PDFObjects {
  1219. _objs: any;
  1220. /**
  1221. * Ensures there is an object defined for `objId`.
  1222. * @private
  1223. */
  1224. private _ensureObj;
  1225. /**
  1226. * If called *without* callback, this returns the data of `objId` but the
  1227. * object needs to be resolved. If it isn't, this method throws.
  1228. *
  1229. * If called *with* a callback, the callback is called with the data of the
  1230. * object once the object is resolved. That means, if you call this method
  1231. * and the object is already resolved, the callback gets called right away.
  1232. */
  1233. get(objId: any, callback?: any): any;
  1234. has(objId: any): any;
  1235. /**
  1236. * Resolves the object `objId` with optional `data`.
  1237. */
  1238. resolve(objId: any, data: any): void;
  1239. clear(): void;
  1240. }
  1241. /**
  1242. * Allows controlling of the rendering tasks.
  1243. */
  1244. declare class RenderTask {
  1245. constructor(internalRenderTask: any);
  1246. _internalRenderTask: any;
  1247. /**
  1248. * Callback for incremental rendering -- a function that will be called
  1249. * each time the rendering is paused. To continue rendering call the
  1250. * function that is the first argument to the callback.
  1251. * @type {function}
  1252. */
  1253. onContinue: Function;
  1254. /**
  1255. * Promise for rendering task completion.
  1256. * @type {Promise<void>}
  1257. */
  1258. get promise(): Promise<void>;
  1259. /**
  1260. * Cancels the rendering task. If the task is currently rendering it will
  1261. * not be cancelled until graphics pauses with a timeout. The promise that
  1262. * this object extends will be rejected when cancelled.
  1263. */
  1264. cancel(): void;
  1265. }
  1266. export {};