display_utils.d.ts 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. export type ExternalLinkParameters = any;
  2. export type PageViewportParameters = {
  3. /**
  4. * - The xMin, yMin, xMax and
  5. * yMax coordinates.
  6. */
  7. viewBox: Array<number>;
  8. /**
  9. * - The scale of the viewport.
  10. */
  11. scale: number;
  12. /**
  13. * - The rotation, in degrees, of the viewport.
  14. */
  15. rotation: number;
  16. /**
  17. * - The horizontal, i.e. x-axis, offset. The
  18. * default value is `0`.
  19. */
  20. offsetX?: number | undefined;
  21. /**
  22. * - The vertical, i.e. y-axis, offset. The
  23. * default value is `0`.
  24. */
  25. offsetY?: number | undefined;
  26. /**
  27. * - If true, the y-axis will not be flipped.
  28. * The default value is `false`.
  29. */
  30. dontFlip?: boolean | undefined;
  31. };
  32. export type PageViewportCloneParameters = {
  33. /**
  34. * - The scale, overriding the one in the cloned
  35. * viewport. The default value is `this.scale`.
  36. */
  37. scale?: number | undefined;
  38. /**
  39. * - The rotation, in degrees, overriding the one
  40. * in the cloned viewport. The default value is `this.rotation`.
  41. */
  42. rotation?: number | undefined;
  43. /**
  44. * - The horizontal, i.e. x-axis, offset.
  45. * The default value is `this.offsetX`.
  46. */
  47. offsetX?: number | undefined;
  48. /**
  49. * - The vertical, i.e. y-axis, offset.
  50. * The default value is `this.offsetY`.
  51. */
  52. offsetY?: number | undefined;
  53. /**
  54. * - If true, the x-axis will not be flipped.
  55. * The default value is `false`.
  56. */
  57. dontFlip?: boolean | undefined;
  58. };
  59. /**
  60. * @typedef ExternalLinkParameters
  61. * @typedef {Object} ExternalLinkParameters
  62. * @property {string} url - An absolute URL.
  63. * @property {LinkTarget} [target] - The link target. The default value is
  64. * `LinkTarget.NONE`.
  65. * @property {string} [rel] - The link relationship. The default value is
  66. * `DEFAULT_LINK_REL`.
  67. * @property {boolean} [enabled] - Whether the link should be enabled. The
  68. * default value is true.
  69. */
  70. /**
  71. * Adds various attributes (href, title, target, rel) to hyperlinks.
  72. * @param {HTMLLinkElement} link - The link element.
  73. * @param {ExternalLinkParameters} params
  74. */
  75. export function addLinkAttributes(link: HTMLLinkElement, { url, target, rel, enabled }?: any): void;
  76. export class BaseCanvasFactory {
  77. create(width: any, height: any): void;
  78. reset(canvasAndContext: any, width: any, height: any): void;
  79. destroy(canvasAndContext: any): void;
  80. }
  81. export class BaseCMapReaderFactory {
  82. constructor({ baseUrl, isCompressed }: {
  83. baseUrl?: any;
  84. isCompressed?: boolean | undefined;
  85. });
  86. baseUrl: any;
  87. isCompressed: boolean;
  88. fetch({ name }: {
  89. name: any;
  90. }): Promise<any>;
  91. /**
  92. * @private
  93. */
  94. private _fetchData;
  95. }
  96. export const DEFAULT_LINK_REL: "noopener noreferrer nofollow";
  97. export function deprecated(details: any): void;
  98. export class DOMCanvasFactory extends BaseCanvasFactory {
  99. constructor({ ownerDocument }?: {
  100. ownerDocument?: Document | undefined;
  101. });
  102. _document: Document;
  103. }
  104. export class DOMCMapReaderFactory extends BaseCMapReaderFactory {
  105. }
  106. export class DOMSVGFactory {
  107. create(width: any, height: any): SVGElement;
  108. createElement(type: any): any;
  109. }
  110. /**
  111. * Gets the filename from a given URL.
  112. * @param {string} url
  113. * @returns {string}
  114. */
  115. export function getFilenameFromUrl(url: string): string;
  116. /**
  117. * Returns the filename or guessed filename from the url (see issue 3455).
  118. * @param {string} url - The original PDF location.
  119. * @param {string} defaultFilename - The value returned if the filename is
  120. * unknown, or the protocol is unsupported.
  121. * @returns {string} Guessed PDF filename.
  122. */
  123. export function getPdfFilenameFromUrl(url: string, defaultFilename?: string): string;
  124. export function isDataScheme(url: any): boolean;
  125. export function isFetchSupported(): boolean;
  126. export function isPdfFile(filename: any): boolean;
  127. export function isValidFetchUrl(url: any, baseUrl: any): boolean;
  128. export namespace LinkTarget {
  129. const NONE: number;
  130. const SELF: number;
  131. const BLANK: number;
  132. const PARENT: number;
  133. const TOP: number;
  134. }
  135. /**
  136. * @param {string} src
  137. * @param {boolean} [removeScriptElement]
  138. * @returns {Promise<void>}
  139. */
  140. export function loadScript(src: string, removeScriptElement?: boolean | undefined): Promise<void>;
  141. /**
  142. * @typedef {Object} PageViewportParameters
  143. * @property {Array<number>} viewBox - The xMin, yMin, xMax and
  144. * yMax coordinates.
  145. * @property {number} scale - The scale of the viewport.
  146. * @property {number} rotation - The rotation, in degrees, of the viewport.
  147. * @property {number} [offsetX] - The horizontal, i.e. x-axis, offset. The
  148. * default value is `0`.
  149. * @property {number} [offsetY] - The vertical, i.e. y-axis, offset. The
  150. * default value is `0`.
  151. * @property {boolean} [dontFlip] - If true, the y-axis will not be flipped.
  152. * The default value is `false`.
  153. */
  154. /**
  155. * @typedef {Object} PageViewportCloneParameters
  156. * @property {number} [scale] - The scale, overriding the one in the cloned
  157. * viewport. The default value is `this.scale`.
  158. * @property {number} [rotation] - The rotation, in degrees, overriding the one
  159. * in the cloned viewport. The default value is `this.rotation`.
  160. * @property {number} [offsetX] - The horizontal, i.e. x-axis, offset.
  161. * The default value is `this.offsetX`.
  162. * @property {number} [offsetY] - The vertical, i.e. y-axis, offset.
  163. * The default value is `this.offsetY`.
  164. * @property {boolean} [dontFlip] - If true, the x-axis will not be flipped.
  165. * The default value is `false`.
  166. */
  167. /**
  168. * PDF page viewport created based on scale, rotation and offset.
  169. */
  170. export class PageViewport {
  171. /**
  172. * @param {PageViewportParameters}
  173. */
  174. constructor({ viewBox, scale, rotation, offsetX, offsetY, dontFlip, }: PageViewportParameters);
  175. viewBox: number[];
  176. scale: number;
  177. rotation: number;
  178. offsetX: number;
  179. offsetY: number;
  180. transform: number[];
  181. width: number;
  182. height: number;
  183. /**
  184. * Clones viewport, with optional additional properties.
  185. * @param {PageViewportCloneParameters} [params]
  186. * @returns {PageViewport} Cloned viewport.
  187. */
  188. clone({ scale, rotation, offsetX, offsetY, dontFlip, }?: PageViewportCloneParameters | undefined): PageViewport;
  189. /**
  190. * Converts PDF point to the viewport coordinates. For examples, useful for
  191. * converting PDF location into canvas pixel coordinates.
  192. * @param {number} x - The x-coordinate.
  193. * @param {number} y - The y-coordinate.
  194. * @returns {Object} Object containing `x` and `y` properties of the
  195. * point in the viewport coordinate space.
  196. * @see {@link convertToPdfPoint}
  197. * @see {@link convertToViewportRectangle}
  198. */
  199. convertToViewportPoint(x: number, y: number): Object;
  200. /**
  201. * Converts PDF rectangle to the viewport coordinates.
  202. * @param {Array} rect - The xMin, yMin, xMax and yMax coordinates.
  203. * @returns {Array} Array containing corresponding coordinates of the
  204. * rectangle in the viewport coordinate space.
  205. * @see {@link convertToViewportPoint}
  206. */
  207. convertToViewportRectangle(rect: any[]): any[];
  208. /**
  209. * Converts viewport coordinates to the PDF location. For examples, useful
  210. * for converting canvas pixel location into PDF one.
  211. * @param {number} x - The x-coordinate.
  212. * @param {number} y - The y-coordinate.
  213. * @returns {Object} Object containing `x` and `y` properties of the
  214. * point in the PDF coordinate space.
  215. * @see {@link convertToViewportPoint}
  216. */
  217. convertToPdfPoint(x: number, y: number): Object;
  218. }
  219. export class PDFDateString {
  220. /**
  221. * Convert a PDF date string to a JavaScript `Date` object.
  222. *
  223. * The PDF date string format is described in section 7.9.4 of the official
  224. * PDF 32000-1:2008 specification. However, in the PDF 1.7 reference (sixth
  225. * edition) Adobe describes the same format including a trailing apostrophe.
  226. * This syntax in incorrect, but Adobe Acrobat creates PDF files that contain
  227. * them. We ignore all apostrophes as they are not necessary for date parsing.
  228. *
  229. * Moreover, Adobe Acrobat doesn't handle changing the date to universal time
  230. * and doesn't use the user's time zone (effectively ignoring the HH' and mm'
  231. * parts of the date string).
  232. *
  233. * @param {string} input
  234. * @returns {Date|null}
  235. */
  236. static toDateObject(input: string): Date | null;
  237. }
  238. declare const RenderingCancelledException_base: any;
  239. export class RenderingCancelledException extends RenderingCancelledException_base {
  240. [x: string]: any;
  241. constructor(msg: any, type: any);
  242. type: any;
  243. }
  244. export class StatTimer {
  245. started: any;
  246. times: any[];
  247. time(name: any): void;
  248. timeEnd(name: any): void;
  249. toString(): string;
  250. }
  251. export {};