interfaces.d.ts 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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 EventBus = import("./event_utils").EventBus;
  5. export type StructTreeLayerBuilder = any;
  6. export type TextHighlighter = import("./text_highlighter").TextHighlighter;
  7. export type TextLayerBuilder = import("./text_layer_builder").TextLayerBuilder;
  8. export type RenderingStates = any;
  9. export type XfaLayerBuilder = import("./xfa_layer_builder").XfaLayerBuilder;
  10. /**
  11. * @interface
  12. */
  13. export class IDownloadManager {
  14. /**
  15. * @param {string} url
  16. * @param {string} filename
  17. */
  18. downloadUrl(url: string, filename: string): void;
  19. /**
  20. * @param {Uint8Array} data
  21. * @param {string} filename
  22. * @param {string} [contentType]
  23. */
  24. downloadData(data: Uint8Array, filename: string, contentType?: string | undefined): void;
  25. /**
  26. * @param {HTMLElement} element
  27. * @param {Uint8Array} data
  28. * @param {string} filename
  29. * @returns {boolean} Indicating if the data was opened.
  30. */
  31. openOrDownloadData(element: HTMLElement, data: Uint8Array, filename: string): boolean;
  32. /**
  33. * @param {Blob} blob
  34. * @param {string} url
  35. * @param {string} filename
  36. * @param {string} [sourceEventType]
  37. */
  38. download(blob: Blob, url: string, filename: string, sourceEventType?: string | undefined): 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 IPDFAnnotationLayerFactory {
  73. /**
  74. * @param {HTMLDivElement} pageDiv
  75. * @param {PDFPageProxy} pdfPage
  76. * @param {AnnotationStorage} [annotationStorage] - Storage for annotation
  77. * data in forms.
  78. * @param {string} [imageResourcesPath] - Path for image resources, mainly
  79. * for annotation icons. Include trailing slash.
  80. * @param {boolean} renderForms
  81. * @param {IL10n} l10n
  82. * @param {boolean} [enableScripting]
  83. * @param {Promise<boolean>} [hasJSActionsPromise]
  84. * @param {Object} [mouseState]
  85. * @param {Promise<Object<string, Array<Object>> | null>}
  86. * [fieldObjectsPromise]
  87. * @param {Map<string, HTMLCanvasElement>} [annotationCanvasMap] - Map some
  88. * annotation ids with canvases used to render them.
  89. * @returns {AnnotationLayerBuilder}
  90. */
  91. createAnnotationLayerBuilder(pageDiv: HTMLDivElement, pdfPage: PDFPageProxy, annotationStorage?: any, imageResourcesPath?: string | undefined, renderForms?: boolean, l10n?: IL10n, enableScripting?: boolean | undefined, hasJSActionsPromise?: Promise<boolean> | undefined, mouseState?: Object | undefined, fieldObjectsPromise?: Promise<{
  92. [x: string]: Object[];
  93. } | null> | undefined, annotationCanvasMap?: Map<string, HTMLCanvasElement> | undefined): AnnotationLayerBuilder;
  94. }
  95. /** @typedef {import("../src/display/api").PDFPageProxy} PDFPageProxy */
  96. /** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
  97. /** @typedef {import("./annotation_layer_builder").AnnotationLayerBuilder} AnnotationLayerBuilder */
  98. /** @typedef {import("./event_utils").EventBus} EventBus */
  99. /** @typedef {import("./struct_tree_builder").StructTreeLayerBuilder} StructTreeLayerBuilder */
  100. /** @typedef {import("./text_highlighter").TextHighlighter} TextHighlighter */
  101. /** @typedef {import("./text_layer_builder").TextLayerBuilder} TextLayerBuilder */
  102. /** @typedef {import("./ui_utils").RenderingStates} RenderingStates */
  103. /** @typedef {import("./xfa_layer_builder").XfaLayerBuilder} XfaLayerBuilder */
  104. /**
  105. * @interface
  106. */
  107. export class IPDFLinkService {
  108. /**
  109. * @type {number}
  110. */
  111. get pagesCount(): number;
  112. /**
  113. * @param {number} value
  114. */
  115. set page(arg: number);
  116. /**
  117. * @type {number}
  118. */
  119. get page(): number;
  120. /**
  121. * @param {number} value
  122. */
  123. set rotation(arg: number);
  124. /**
  125. * @type {number}
  126. */
  127. get rotation(): number;
  128. /**
  129. * @param {boolean} value
  130. */
  131. set externalLinkEnabled(arg: boolean);
  132. /**
  133. * @type {boolean}
  134. */
  135. get externalLinkEnabled(): boolean;
  136. /**
  137. * @param {string|Array} dest - The named, or explicit, PDF destination.
  138. */
  139. goToDestination(dest: string | any[]): Promise<void>;
  140. /**
  141. * @param {number|string} val - The page number, or page label.
  142. */
  143. goToPage(val: number | string): void;
  144. /**
  145. * @param {HTMLAnchorElement} link
  146. * @param {string} url
  147. * @param {boolean} [newWindow]
  148. */
  149. addLinkAttributes(link: HTMLAnchorElement, url: string, newWindow?: boolean | undefined): void;
  150. /**
  151. * @param dest - The PDF destination object.
  152. * @returns {string} The hyperlink to the PDF object.
  153. */
  154. getDestinationHash(dest: any): string;
  155. /**
  156. * @param hash - The PDF parameters/hash.
  157. * @returns {string} The hyperlink to the PDF object.
  158. */
  159. getAnchorUrl(hash: any): string;
  160. /**
  161. * @param {string} hash
  162. */
  163. setHash(hash: string): void;
  164. /**
  165. * @param {string} action
  166. */
  167. executeNamedAction(action: string): void;
  168. /**
  169. * @param {number} pageNum - page number.
  170. * @param {Object} pageRef - reference to the page.
  171. */
  172. cachePageRef(pageNum: number, pageRef: Object): void;
  173. /**
  174. * @param {number} pageNumber
  175. */
  176. isPageVisible(pageNumber: number): void;
  177. /**
  178. * @param {number} pageNumber
  179. */
  180. isPageCached(pageNumber: number): void;
  181. }
  182. /**
  183. * @interface
  184. */
  185. export class IPDFStructTreeLayerFactory {
  186. /**
  187. * @param {PDFPageProxy} pdfPage
  188. * @returns {StructTreeLayerBuilder}
  189. */
  190. createStructTreeLayerBuilder(pdfPage: PDFPageProxy): any;
  191. }
  192. /**
  193. * @interface
  194. */
  195. export class IPDFTextLayerFactory {
  196. /**
  197. * @param {HTMLDivElement} textLayerDiv
  198. * @param {number} pageIndex
  199. * @param {PageViewport} viewport
  200. * @param {boolean} enhanceTextSelection
  201. * @param {EventBus} eventBus
  202. * @param {TextHighlighter} highlighter
  203. * @returns {TextLayerBuilder}
  204. */
  205. createTextLayerBuilder(textLayerDiv: HTMLDivElement, pageIndex: number, viewport: PageViewport, enhanceTextSelection: boolean | undefined, eventBus: EventBus, highlighter: TextHighlighter): TextLayerBuilder;
  206. }
  207. /**
  208. * @interface
  209. */
  210. export class IPDFXfaLayerFactory {
  211. /**
  212. * @param {HTMLDivElement} pageDiv
  213. * @param {PDFPageProxy} pdfPage
  214. * @param {AnnotationStorage} [annotationStorage]
  215. * @param {Object} [xfaHtml]
  216. * @returns {XfaLayerBuilder}
  217. */
  218. createXfaLayerBuilder(pageDiv: HTMLDivElement, pdfPage: PDFPageProxy, annotationStorage?: any, xfaHtml?: Object | undefined): XfaLayerBuilder;
  219. }
  220. /**
  221. * @interface
  222. */
  223. export class IRenderableView {
  224. /** @type {function | null} */
  225. resume: Function | null;
  226. /**
  227. * @type {string} - Unique ID for rendering queue.
  228. */
  229. get renderingId(): string;
  230. /**
  231. * @type {RenderingStates}
  232. */
  233. get renderingState(): any;
  234. /**
  235. * @returns {Promise} Resolved on draw completion.
  236. */
  237. draw(): Promise<any>;
  238. }