interfaces.d.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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. * @type {boolean}
  196. */
  197. get isInPresentationMode(): boolean;
  198. /**
  199. * @param {boolean} value
  200. */
  201. set externalLinkEnabled(arg: boolean);
  202. /**
  203. * @type {boolean}
  204. */
  205. get externalLinkEnabled(): boolean;
  206. /**
  207. * @param {string|Array} dest - The named, or explicit, PDF destination.
  208. */
  209. goToDestination(dest: string | any[]): Promise<void>;
  210. /**
  211. * @param {number|string} val - The page number, or page label.
  212. */
  213. goToPage(val: number | string): void;
  214. /**
  215. * @param {HTMLAnchorElement} link
  216. * @param {string} url
  217. * @param {boolean} [newWindow]
  218. */
  219. addLinkAttributes(link: HTMLAnchorElement, url: string, newWindow?: boolean | undefined): void;
  220. /**
  221. * @param dest - The PDF destination object.
  222. * @returns {string} The hyperlink to the PDF object.
  223. */
  224. getDestinationHash(dest: any): string;
  225. /**
  226. * @param hash - The PDF parameters/hash.
  227. * @returns {string} The hyperlink to the PDF object.
  228. */
  229. getAnchorUrl(hash: any): string;
  230. /**
  231. * @param {string} hash
  232. */
  233. setHash(hash: string): void;
  234. /**
  235. * @param {string} action
  236. */
  237. executeNamedAction(action: string): void;
  238. /**
  239. * @param {Object} action
  240. */
  241. executeSetOCGState(action: Object): void;
  242. /**
  243. * @param {number} pageNum - page number.
  244. * @param {Object} pageRef - reference to the page.
  245. */
  246. cachePageRef(pageNum: number, pageRef: Object): void;
  247. /**
  248. * @param {number} pageNumber
  249. */
  250. isPageVisible(pageNumber: number): void;
  251. /**
  252. * @param {number} pageNumber
  253. */
  254. isPageCached(pageNumber: number): void;
  255. }
  256. /**
  257. * @interface
  258. */
  259. export class IPDFStructTreeLayerFactory {
  260. /**
  261. * @typedef {Object} CreateStructTreeLayerBuilderParameters
  262. * @property {PDFPageProxy} pdfPage
  263. */
  264. /**
  265. * @param {CreateStructTreeLayerBuilderParameters}
  266. * @returns {StructTreeLayerBuilder}
  267. */
  268. createStructTreeLayerBuilder({ pdfPage }: {
  269. pdfPage: PDFPageProxy;
  270. }): any;
  271. }
  272. /**
  273. * @interface
  274. */
  275. export class IPDFTextLayerFactory {
  276. /**
  277. * @typedef {Object} CreateTextLayerBuilderParameters
  278. * @property {HTMLDivElement} textLayerDiv
  279. * @property {number} pageIndex
  280. * @property {PageViewport} viewport
  281. * @property {EventBus} eventBus
  282. * @property {TextHighlighter} highlighter
  283. * @property {TextAccessibilityManager} [accessibilityManager]
  284. */
  285. /**
  286. * @param {CreateTextLayerBuilderParameters}
  287. * @returns {TextLayerBuilder}
  288. */
  289. createTextLayerBuilder({ textLayerDiv, pageIndex, viewport, eventBus, highlighter, accessibilityManager, }: {
  290. textLayerDiv: HTMLDivElement;
  291. pageIndex: number;
  292. viewport: PageViewport;
  293. eventBus: EventBus;
  294. highlighter: TextHighlighter;
  295. accessibilityManager?: import("./text_accessibility.js").TextAccessibilityManager | undefined;
  296. }): TextLayerBuilder;
  297. }
  298. /**
  299. * @interface
  300. */
  301. export class IPDFXfaLayerFactory {
  302. /**
  303. * @typedef {Object} CreateXfaLayerBuilderParameters
  304. * @property {HTMLDivElement} pageDiv
  305. * @property {PDFPageProxy} pdfPage
  306. * @property {AnnotationStorage} [annotationStorage] - Storage for annotation
  307. * data in forms.
  308. */
  309. /**
  310. * @param {CreateXfaLayerBuilderParameters}
  311. * @returns {XfaLayerBuilder}
  312. */
  313. createXfaLayerBuilder({ pageDiv, pdfPage, annotationStorage }: {
  314. pageDiv: HTMLDivElement;
  315. pdfPage: PDFPageProxy;
  316. /**
  317. * - Storage for annotation
  318. * data in forms.
  319. */
  320. annotationStorage?: any;
  321. }): XfaLayerBuilder;
  322. }
  323. /**
  324. * @interface
  325. */
  326. export class IRenderableView {
  327. /** @type {function | null} */
  328. resume: Function | null;
  329. /**
  330. * @type {string} - Unique ID for rendering queue.
  331. */
  332. get renderingId(): string;
  333. /**
  334. * @type {RenderingStates}
  335. */
  336. get renderingState(): any;
  337. /**
  338. * @returns {Promise} Resolved on draw completion.
  339. */
  340. draw(): Promise<any>;
  341. }