display_utils.d.ts 8.1 KB

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