interfaces.d.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. export type PDFPageProxy = import("../src/display/api").PDFPageProxy;
  2. export type PageViewport = import("../src/display/display_utils").PageViewport;
  3. export type RenderingStates = any;
  4. /**
  5. * @interface
  6. */
  7. export class IDownloadManager {
  8. /**
  9. * @param {string} url
  10. * @param {string} filename
  11. */
  12. downloadUrl(url: string, filename: string): void;
  13. /**
  14. * @param {Uint8Array} data
  15. * @param {string} filename
  16. * @param {string} [contentType]
  17. */
  18. downloadData(data: Uint8Array, filename: string, contentType?: string | undefined): void;
  19. /**
  20. * @param {HTMLElement} element
  21. * @param {Uint8Array} data
  22. * @param {string} filename
  23. * @returns {boolean} Indicating if the data was opened.
  24. */
  25. openOrDownloadData(element: HTMLElement, data: Uint8Array, filename: string): boolean;
  26. /**
  27. * @param {Blob} blob
  28. * @param {string} url
  29. * @param {string} filename
  30. */
  31. download(blob: Blob, url: string, filename: string): void;
  32. }
  33. /**
  34. * @interface
  35. */
  36. export class IL10n {
  37. /**
  38. * @returns {Promise<string>} - Resolves to the current locale.
  39. */
  40. getLanguage(): Promise<string>;
  41. /**
  42. * @returns {Promise<string>} - Resolves to 'rtl' or 'ltr'.
  43. */
  44. getDirection(): Promise<string>;
  45. /**
  46. * Translates text identified by the key and adds/formats data using the args
  47. * property bag. If the key was not found, translation falls back to the
  48. * fallback text.
  49. * @param {string} key
  50. * @param {Object | null} [args]
  51. * @param {string} [fallback]
  52. * @returns {Promise<string>}
  53. */
  54. get(key: string, args?: Object | null | undefined, fallback?: string | undefined): Promise<string>;
  55. /**
  56. * Translates HTML element.
  57. * @param {HTMLElement} element
  58. * @returns {Promise<void>}
  59. */
  60. translate(element: HTMLElement): Promise<void>;
  61. }
  62. /** @typedef {import("../src/display/api").PDFPageProxy} PDFPageProxy */
  63. /** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
  64. /** @typedef {import("./ui_utils").RenderingStates} RenderingStates */
  65. /**
  66. * @interface
  67. */
  68. export class IPDFLinkService {
  69. /**
  70. * @type {number}
  71. */
  72. get pagesCount(): number;
  73. /**
  74. * @param {number} value
  75. */
  76. set page(arg: number);
  77. /**
  78. * @type {number}
  79. */
  80. get page(): number;
  81. /**
  82. * @param {number} value
  83. */
  84. set rotation(arg: number);
  85. /**
  86. * @type {number}
  87. */
  88. get rotation(): number;
  89. /**
  90. * @type {boolean}
  91. */
  92. get isInPresentationMode(): boolean;
  93. /**
  94. * @param {boolean} value
  95. */
  96. set externalLinkEnabled(arg: boolean);
  97. /**
  98. * @type {boolean}
  99. */
  100. get externalLinkEnabled(): boolean;
  101. /**
  102. * @param {string|Array} dest - The named, or explicit, PDF destination.
  103. */
  104. goToDestination(dest: string | any[]): Promise<void>;
  105. /**
  106. * @param {number|string} val - The page number, or page label.
  107. */
  108. goToPage(val: number | string): void;
  109. /**
  110. * @param {HTMLAnchorElement} link
  111. * @param {string} url
  112. * @param {boolean} [newWindow]
  113. */
  114. addLinkAttributes(link: HTMLAnchorElement, url: string, newWindow?: boolean | undefined): void;
  115. /**
  116. * @param dest - The PDF destination object.
  117. * @returns {string} The hyperlink to the PDF object.
  118. */
  119. getDestinationHash(dest: any): string;
  120. /**
  121. * @param hash - The PDF parameters/hash.
  122. * @returns {string} The hyperlink to the PDF object.
  123. */
  124. getAnchorUrl(hash: any): string;
  125. /**
  126. * @param {string} hash
  127. */
  128. setHash(hash: string): void;
  129. /**
  130. * @param {string} action
  131. */
  132. executeNamedAction(action: string): void;
  133. /**
  134. * @param {Object} action
  135. */
  136. executeSetOCGState(action: Object): void;
  137. /**
  138. * @param {number} pageNum - page number.
  139. * @param {Object} pageRef - reference to the page.
  140. */
  141. cachePageRef(pageNum: number, pageRef: Object): void;
  142. /**
  143. * @param {number} pageNumber
  144. */
  145. isPageVisible(pageNumber: number): void;
  146. /**
  147. * @param {number} pageNumber
  148. */
  149. isPageCached(pageNumber: number): void;
  150. }
  151. /**
  152. * @interface
  153. */
  154. export class IRenderableView {
  155. /** @type {function | null} */
  156. resume: Function | null;
  157. /**
  158. * @type {string} - Unique ID for rendering queue.
  159. */
  160. get renderingId(): string;
  161. /**
  162. * @type {RenderingStates}
  163. */
  164. get renderingState(): any;
  165. /**
  166. * @returns {Promise} Resolved on draw completion.
  167. */
  168. draw(): Promise<any>;
  169. }