interfaces.d.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. export type PDFPageProxy = import("../src/display/api").PDFPageProxy;
  2. export type PageViewport = import("../src/display/display_utils").PageViewport;
  3. export type AnnotationLayerBuilder = import("./annotation_layer_builder").AnnotationLayerBuilder;
  4. export type AnnotationEditorLayerBuilder = import("./annotation_editor_layer_builder").AnnotationEditorLayerBuilder;
  5. export type EventBus = import("./event_utils").EventBus;
  6. export type StructTreeLayerBuilder = any;
  7. export type TextHighlighter = import("./text_highlighter").TextHighlighter;
  8. export type TextLayerBuilder = import("./text_layer_builder").TextLayerBuilder;
  9. export type RenderingStates = any;
  10. export type XfaLayerBuilder = import("./xfa_layer_builder").XfaLayerBuilder;
  11. export type TextAccessibilityManager = import("./text_accessibility.js").TextAccessibilityManager;
  12. /**
  13. * @interface
  14. */
  15. export class IDownloadManager {
  16. /**
  17. * @param {string} url
  18. * @param {string} filename
  19. */
  20. downloadUrl(url: string, filename: string): void;
  21. /**
  22. * @param {Uint8Array} data
  23. * @param {string} filename
  24. * @param {string} [contentType]
  25. */
  26. downloadData(data: Uint8Array, filename: string, contentType?: string | undefined): void;
  27. /**
  28. * @param {HTMLElement} element
  29. * @param {Uint8Array} data
  30. * @param {string} filename
  31. * @returns {boolean} Indicating if the data was opened.
  32. */
  33. openOrDownloadData(element: HTMLElement, data: Uint8Array, filename: string): boolean;
  34. /**
  35. * @param {Blob} blob
  36. * @param {string} url
  37. * @param {string} filename
  38. */
  39. download(blob: Blob, url: string, filename: string): void;
  40. }
  41. /**
  42. * @interface
  43. */
  44. export class IL10n {
  45. /**
  46. * @returns {Promise<string>} - Resolves to the current locale.
  47. */
  48. getLanguage(): Promise<string>;
  49. /**
  50. * @returns {Promise<string>} - Resolves to 'rtl' or 'ltr'.
  51. */
  52. getDirection(): Promise<string>;
  53. /**
  54. * Translates text identified by the key and adds/formats data using the args
  55. * property bag. If the key was not found, translation falls back to the
  56. * fallback text.
  57. * @param {string} key
  58. * @param {Object | null} [args]
  59. * @param {string} [fallback]
  60. * @returns {Promise<string>}
  61. */
  62. get(key: string, args?: Object | null | undefined, fallback?: string | undefined): Promise<string>;
  63. /**
  64. * Translates HTML element.
  65. * @param {HTMLElement} element
  66. * @returns {Promise<void>}
  67. */
  68. translate(element: HTMLElement): Promise<void>;
  69. }
  70. /**
  71. * @interface
  72. */
  73. export class IPDFAnnotationEditorLayerFactory {
  74. /**
  75. * @typedef {Object} CreateAnnotationEditorLayerBuilderParameters
  76. * @property {AnnotationEditorUIManager} [uiManager]
  77. * @property {HTMLDivElement} pageDiv
  78. * @property {PDFPageProxy} pdfPage
  79. * @property {IL10n} l10n
  80. * @property {AnnotationStorage} [annotationStorage] - Storage for annotation
  81. * @property {TextAccessibilityManager} [accessibilityManager]
  82. * data in forms.
  83. */
  84. /**
  85. * @param {CreateAnnotationEditorLayerBuilderParameters}
  86. * @returns {AnnotationEditorLayerBuilder}
  87. */
  88. createAnnotationEditorLayerBuilder({ uiManager, pageDiv, pdfPage, l10n, annotationStorage, accessibilityManager, }: {
  89. uiManager?: any;
  90. pageDiv: HTMLDivElement;
  91. pdfPage: PDFPageProxy;
  92. l10n: IL10n;
  93. /**
  94. * - Storage for annotation
  95. */
  96. annotationStorage?: any;
  97. /**
  98. * data in forms.
  99. */
  100. accessibilityManager?: import("./text_accessibility.js").TextAccessibilityManager | undefined;
  101. }): AnnotationEditorLayerBuilder;
  102. }
  103. /**
  104. * @interface
  105. */
  106. export class IPDFAnnotationLayerFactory {
  107. /**
  108. * @typedef {Object} CreateAnnotationLayerBuilderParameters
  109. * @property {HTMLDivElement} pageDiv
  110. * @property {PDFPageProxy} pdfPage
  111. * @property {AnnotationStorage} [annotationStorage] - Storage for annotation
  112. * data in forms.
  113. * @property {string} [imageResourcesPath] - Path for image resources, mainly
  114. * for annotation icons. Include trailing slash.
  115. * @property {boolean} renderForms
  116. * @property {IL10n} l10n
  117. * @property {boolean} [enableScripting]
  118. * @property {Promise<boolean>} [hasJSActionsPromise]
  119. * @property {Object} [mouseState]
  120. * @property {Promise<Object<string, Array<Object>> | null>}
  121. * [fieldObjectsPromise]
  122. * @property {Map<string, HTMLCanvasElement>} [annotationCanvasMap] - Map some
  123. * annotation ids with canvases used to render them.
  124. * @property {TextAccessibilityManager} [accessibilityManager]
  125. */
  126. /**
  127. * @param {CreateAnnotationLayerBuilderParameters}
  128. * @returns {AnnotationLayerBuilder}
  129. */
  130. createAnnotationLayerBuilder({ pageDiv, pdfPage, annotationStorage, imageResourcesPath, renderForms, l10n, enableScripting, hasJSActionsPromise, mouseState, fieldObjectsPromise, annotationCanvasMap, accessibilityManager, }: {
  131. pageDiv: HTMLDivElement;
  132. pdfPage: PDFPageProxy;
  133. /**
  134. * - Storage for annotation
  135. * data in forms.
  136. */
  137. annotationStorage?: any;
  138. /**
  139. * - Path for image resources, mainly
  140. * for annotation icons. Include trailing slash.
  141. */
  142. imageResourcesPath?: string | undefined;
  143. renderForms: boolean;
  144. l10n: IL10n;
  145. enableScripting?: boolean | undefined;
  146. hasJSActionsPromise?: Promise<boolean> | undefined;
  147. mouseState?: Object | undefined;
  148. fieldObjectsPromise?: Promise<{
  149. [x: string]: Object[];
  150. } | null> | undefined;
  151. /**
  152. * - Map some
  153. * annotation ids with canvases used to render them.
  154. */
  155. annotationCanvasMap?: Map<string, HTMLCanvasElement> | undefined;
  156. accessibilityManager?: import("./text_accessibility.js").TextAccessibilityManager | undefined;
  157. }): AnnotationLayerBuilder;
  158. }
  159. /** @typedef {import("../src/display/api").PDFPageProxy} PDFPageProxy */
  160. /** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
  161. /** @typedef {import("./annotation_layer_builder").AnnotationLayerBuilder} AnnotationLayerBuilder */
  162. /** @typedef {import("./annotation_editor_layer_builder").AnnotationEditorLayerBuilder} AnnotationEditorLayerBuilder */
  163. /** @typedef {import("./event_utils").EventBus} EventBus */
  164. /** @typedef {import("./struct_tree_builder").StructTreeLayerBuilder} StructTreeLayerBuilder */
  165. /** @typedef {import("./text_highlighter").TextHighlighter} TextHighlighter */
  166. /** @typedef {import("./text_layer_builder").TextLayerBuilder} TextLayerBuilder */
  167. /** @typedef {import("./ui_utils").RenderingStates} RenderingStates */
  168. /** @typedef {import("./xfa_layer_builder").XfaLayerBuilder} XfaLayerBuilder */
  169. /** @typedef {import("./text_accessibility.js").TextAccessibilityManager} TextAccessibilityManager */
  170. /**
  171. * @interface
  172. */
  173. export class IPDFLinkService {
  174. /**
  175. * @type {number}
  176. */
  177. get pagesCount(): number;
  178. /**
  179. * @param {number} value
  180. */
  181. set page(arg: number);
  182. /**
  183. * @type {number}
  184. */
  185. get page(): number;
  186. /**
  187. * @param {number} value
  188. */
  189. set rotation(arg: number);
  190. /**
  191. * @type {number}
  192. */
  193. get rotation(): number;
  194. /**
  195. * @param {boolean} value
  196. */
  197. set externalLinkEnabled(arg: boolean);
  198. /**
  199. * @type {boolean}
  200. */
  201. get externalLinkEnabled(): boolean;
  202. /**
  203. * @param {string|Array} dest - The named, or explicit, PDF destination.
  204. */
  205. goToDestination(dest: string | any[]): Promise<void>;
  206. /**
  207. * @param {number|string} val - The page number, or page label.
  208. */
  209. goToPage(val: number | string): void;
  210. /**
  211. * @param {HTMLAnchorElement} link
  212. * @param {string} url
  213. * @param {boolean} [newWindow]
  214. */
  215. addLinkAttributes(link: HTMLAnchorElement, url: string, newWindow?: boolean | undefined): void;
  216. /**
  217. * @param dest - The PDF destination object.
  218. * @returns {string} The hyperlink to the PDF object.
  219. */
  220. getDestinationHash(dest: any): string;
  221. /**
  222. * @param hash - The PDF parameters/hash.
  223. * @returns {string} The hyperlink to the PDF object.
  224. */
  225. getAnchorUrl(hash: any): string;
  226. /**
  227. * @param {string} hash
  228. */
  229. setHash(hash: string): void;
  230. /**
  231. * @param {string} action
  232. */
  233. executeNamedAction(action: string): void;
  234. /**
  235. * @param {number} pageNum - page number.
  236. * @param {Object} pageRef - reference to the page.
  237. */
  238. cachePageRef(pageNum: number, pageRef: Object): void;
  239. /**
  240. * @param {number} pageNumber
  241. */
  242. isPageVisible(pageNumber: number): void;
  243. /**
  244. * @param {number} pageNumber
  245. */
  246. isPageCached(pageNumber: number): void;
  247. }
  248. /**
  249. * @interface
  250. */
  251. export class IPDFStructTreeLayerFactory {
  252. /**
  253. * @typedef {Object} CreateStructTreeLayerBuilderParameters
  254. * @property {PDFPageProxy} pdfPage
  255. */
  256. /**
  257. * @param {CreateStructTreeLayerBuilderParameters}
  258. * @returns {StructTreeLayerBuilder}
  259. */
  260. createStructTreeLayerBuilder({ pdfPage }: {
  261. pdfPage: PDFPageProxy;
  262. }): any;
  263. }
  264. /**
  265. * @interface
  266. */
  267. export class IPDFTextLayerFactory {
  268. /**
  269. * @typedef {Object} CreateTextLayerBuilderParameters
  270. * @property {HTMLDivElement} textLayerDiv
  271. * @property {number} pageIndex
  272. * @property {PageViewport} viewport
  273. * @property {boolean} [enhanceTextSelection]
  274. * @property {EventBus} eventBus
  275. * @property {TextHighlighter} highlighter
  276. * @property {TextAccessibilityManager} [accessibilityManager]
  277. */
  278. /**
  279. * @param {CreateTextLayerBuilderParameters}
  280. * @returns {TextLayerBuilder}
  281. */
  282. createTextLayerBuilder({ textLayerDiv, pageIndex, viewport, enhanceTextSelection, eventBus, highlighter, accessibilityManager, }: {
  283. textLayerDiv: HTMLDivElement;
  284. pageIndex: number;
  285. viewport: PageViewport;
  286. enhanceTextSelection?: boolean | undefined;
  287. eventBus: EventBus;
  288. highlighter: TextHighlighter;
  289. accessibilityManager?: import("./text_accessibility.js").TextAccessibilityManager | undefined;
  290. }): TextLayerBuilder;
  291. }
  292. /**
  293. * @interface
  294. */
  295. export class IPDFXfaLayerFactory {
  296. /**
  297. * @typedef {Object} CreateXfaLayerBuilderParameters
  298. * @property {HTMLDivElement} pageDiv
  299. * @property {PDFPageProxy} pdfPage
  300. * @property {AnnotationStorage} [annotationStorage] - Storage for annotation
  301. * data in forms.
  302. */
  303. /**
  304. * @param {CreateXfaLayerBuilderParameters}
  305. * @returns {XfaLayerBuilder}
  306. */
  307. createXfaLayerBuilder({ pageDiv, pdfPage, annotationStorage }: {
  308. pageDiv: HTMLDivElement;
  309. pdfPage: PDFPageProxy;
  310. /**
  311. * - Storage for annotation
  312. * data in forms.
  313. */
  314. annotationStorage?: any;
  315. }): XfaLayerBuilder;
  316. }
  317. /**
  318. * @interface
  319. */
  320. export class IRenderableView {
  321. /** @type {function | null} */
  322. resume: Function | null;
  323. /**
  324. * @type {string} - Unique ID for rendering queue.
  325. */
  326. get renderingId(): string;
  327. /**
  328. * @type {RenderingStates}
  329. */
  330. get renderingState(): any;
  331. /**
  332. * @returns {Promise} Resolved on draw completion.
  333. */
  334. draw(): Promise<any>;
  335. }