interfaces.d.ts 10 KB

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