unpdf 0.5.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +64 -31
  2. package/dist/index.node.cjs +8 -9
  3. package/dist/index.node.d.cts +4 -4
  4. package/dist/index.node.d.mts +4 -4
  5. package/dist/index.node.d.ts +4 -4
  6. package/dist/index.node.mjs +2 -3
  7. package/dist/index.web.cjs +8 -9
  8. package/dist/index.web.d.cts +4 -4
  9. package/dist/index.web.d.mts +4 -4
  10. package/dist/index.web.d.ts +4 -4
  11. package/dist/index.web.mjs +2 -3
  12. package/dist/index.worker.cjs +14 -11
  13. package/dist/index.worker.d.cts +4 -4
  14. package/dist/index.worker.d.mts +4 -4
  15. package/dist/index.worker.d.ts +4 -4
  16. package/dist/index.worker.mjs +12 -8
  17. package/dist/pdfjs.d.mts +1 -0
  18. package/dist/pdfjs.d.ts +1 -0
  19. package/dist/pdfjs.mjs +1 -0
  20. package/dist/shared/{unpdf.6363738c.d.ts → unpdf.3991886a.d.cts} +9 -7
  21. package/dist/shared/{unpdf.6363738c.d.cts → unpdf.3991886a.d.mts} +9 -7
  22. package/dist/shared/{unpdf.6363738c.d.mts → unpdf.3991886a.d.ts} +9 -7
  23. package/dist/shared/unpdf.6c0ca5b5.cjs +107 -0
  24. package/dist/shared/unpdf.ce219a40.mjs +99 -0
  25. package/dist/types/external/webL10n/l10n.d.ts +0 -0
  26. package/dist/types/src/display/annotation_layer.d.ts +203 -0
  27. package/dist/types/src/display/annotation_storage.d.ts +89 -0
  28. package/dist/types/src/display/api.d.ts +1466 -0
  29. package/dist/types/src/display/base_factory.d.ts +54 -0
  30. package/dist/types/src/display/canvas.d.ts +208 -0
  31. package/dist/types/src/display/display_utils.d.ts +277 -0
  32. package/dist/types/src/display/editor/annotation_editor_layer.d.ts +196 -0
  33. package/dist/types/src/display/editor/editor.d.ts +325 -0
  34. package/dist/types/src/display/editor/freetext.d.ts +72 -0
  35. package/dist/types/src/display/editor/ink.d.ts +95 -0
  36. package/dist/types/src/display/editor/stamp.d.ts +28 -0
  37. package/dist/types/src/display/editor/tools.d.ts +349 -0
  38. package/dist/types/src/display/font_loader.d.ts +43 -0
  39. package/dist/types/src/display/metadata.d.ts +11 -0
  40. package/dist/types/src/display/optional_content_config.d.ts +13 -0
  41. package/dist/types/src/display/pattern_helper.d.ts +73 -0
  42. package/dist/types/src/display/text_layer.d.ts +151 -0
  43. package/dist/types/src/display/transport_stream.d.ts +68 -0
  44. package/dist/types/src/display/worker_options.d.ts +27 -0
  45. package/dist/types/src/display/xfa_layer.d.ts +46 -0
  46. package/dist/types/src/display/xfa_text.d.ts +19 -0
  47. package/dist/types/src/pdf.d.ts +50 -0
  48. package/dist/types/src/shared/image_utils.d.ts +17 -0
  49. package/dist/types/src/shared/message_handler.d.ts +43 -0
  50. package/dist/types/src/shared/murmurhash3.d.ts +7 -0
  51. package/dist/types/src/shared/scripting_utils.d.ts +16 -0
  52. package/dist/types/src/shared/util.d.ts +398 -0
  53. package/dist/types/web/annotation_editor_layer_builder.d.ts +50 -0
  54. package/dist/types/web/annotation_layer_builder.d.ts +83 -0
  55. package/dist/types/web/app_options.d.ts +14 -0
  56. package/dist/types/web/download_manager.d.ts +14 -0
  57. package/dist/types/web/event_utils.d.ts +75 -0
  58. package/dist/types/web/generic_scripting.d.ts +8 -0
  59. package/dist/types/web/genericl10n.d.ts +13 -0
  60. package/dist/types/web/interfaces.d.ts +163 -0
  61. package/dist/types/web/l10n_utils.d.ts +7 -0
  62. package/dist/types/web/pdf_find_controller.d.ts +108 -0
  63. package/dist/types/web/pdf_find_utils.d.ts +16 -0
  64. package/dist/types/web/pdf_history.d.ts +168 -0
  65. package/dist/types/web/pdf_link_service.d.ts +243 -0
  66. package/dist/types/web/pdf_page_view.d.ts +209 -0
  67. package/dist/types/web/pdf_rendering_queue.d.ts +53 -0
  68. package/dist/types/web/pdf_scripting_manager.component.d.ts +5 -0
  69. package/dist/types/web/pdf_scripting_manager.d.ts +61 -0
  70. package/dist/types/web/pdf_single_page_viewer.d.ts +7 -0
  71. package/dist/types/web/pdf_thumbnail_view.d.ts +131 -0
  72. package/dist/types/web/pdf_thumbnail_viewer.d.ts +104 -0
  73. package/dist/types/web/pdf_viewer.component.d.ts +24 -0
  74. package/dist/types/web/pdf_viewer.d.ts +455 -0
  75. package/dist/types/web/struct_tree_layer_builder.d.ts +7 -0
  76. package/dist/types/web/text_accessibility.d.ts +42 -0
  77. package/dist/types/web/text_highlighter.d.ts +63 -0
  78. package/dist/types/web/text_layer_builder.d.ts +64 -0
  79. package/dist/types/web/ui_utils.d.ts +288 -0
  80. package/dist/types/web/xfa_layer_builder.d.ts +41 -0
  81. package/package.json +67 -41
  82. package/dist/shared/unpdf.3dcacb97.mjs +0 -49
  83. package/dist/shared/unpdf.42987ff1.cjs +0 -52
  84. package/dist/shared/unpdf.ab6a2535.mjs +0 -46
  85. package/dist/shared/unpdf.eba9a3dc.cjs +0 -53
@@ -1,5 +1,5 @@
1
- import { BinaryData, PDFDocumentProxy, DocumentInitParameters } from 'pdfjs-dist/types/src/display/api';
2
- import PDFJS from 'pdfjs-dist';
1
+ import { BinaryData, PDFDocumentProxy, DocumentInitParameters } from '../types/src/display/api';
2
+ import _PDFJS from '../types/src/pdf';
3
3
 
4
4
  declare function getPDFMeta(data: BinaryData | PDFDocumentProxy): Promise<{
5
5
  info: Record<string, any>;
@@ -15,6 +15,7 @@ declare function extractPDFText(data: BinaryData | PDFDocumentProxy, options?: {
15
15
 
16
16
  declare function getImagesFromPage(data: BinaryData | PDFDocumentProxy, pageNumber: number): Promise<ArrayBuffer[]>;
17
17
 
18
+ type PDFJS = typeof _PDFJS;
18
19
  interface UnPDFConfiguration {
19
20
  /**
20
21
  * By default, UnPDF will use the latest version of PDF.js. If you want to
@@ -22,22 +23,23 @@ interface UnPDFConfiguration {
22
23
  * the PDF.js module.
23
24
  *
24
25
  * @example
26
+ * // Use the legacy build
25
27
  * () => import('pdfjs-dist/legacy/build/pdf.js')
26
28
  */
27
- pdfjs?: () => Promise<typeof PDFJS>;
29
+ pdfjs?: () => Promise<PDFJS>;
28
30
  }
29
31
 
30
32
  /**
31
33
  * Returns a PDFDocumentProxy instance from a given binary data.
32
34
  *
33
35
  * Applies the following defaults:
34
- * - `useWorkerFetch: false`
35
36
  * - `isEvalSupported: false`
36
- * - `useSystemFonts: true`
37
37
  */
38
38
  declare function getDocumentProxy(data: BinaryData, options?: DocumentInitParameters): Promise<PDFDocumentProxy>;
39
39
  declare function defineUnPDFConfig(options: UnPDFConfiguration): Promise<void>;
40
- declare function getResolvedPDFJS(): Promise<typeof PDFJS>;
41
- declare function resolvePDFJSImports(pdfjs?: () => Promise<typeof PDFJS>): Promise<void>;
40
+ declare function getResolvedPDFJS(): Promise<PDFJS>;
41
+ declare function resolvePDFJSImports(pdfjsResolver?: () => Promise<PDFJS>, { force }?: {
42
+ force?: boolean | undefined;
43
+ }): Promise<void>;
42
44
 
43
45
  export { getImagesFromPage as a, getDocumentProxy as b, getResolvedPDFJS as c, defineUnPDFConfig as d, extractPDFText as e, getPDFMeta as g, resolvePDFJSImports as r };
@@ -1,5 +1,5 @@
1
- import { BinaryData, PDFDocumentProxy, DocumentInitParameters } from 'pdfjs-dist/types/src/display/api';
2
- import PDFJS from 'pdfjs-dist';
1
+ import { BinaryData, PDFDocumentProxy, DocumentInitParameters } from '../types/src/display/api';
2
+ import _PDFJS from '../types/src/pdf';
3
3
 
4
4
  declare function getPDFMeta(data: BinaryData | PDFDocumentProxy): Promise<{
5
5
  info: Record<string, any>;
@@ -15,6 +15,7 @@ declare function extractPDFText(data: BinaryData | PDFDocumentProxy, options?: {
15
15
 
16
16
  declare function getImagesFromPage(data: BinaryData | PDFDocumentProxy, pageNumber: number): Promise<ArrayBuffer[]>;
17
17
 
18
+ type PDFJS = typeof _PDFJS;
18
19
  interface UnPDFConfiguration {
19
20
  /**
20
21
  * By default, UnPDF will use the latest version of PDF.js. If you want to
@@ -22,22 +23,23 @@ interface UnPDFConfiguration {
22
23
  * the PDF.js module.
23
24
  *
24
25
  * @example
26
+ * // Use the legacy build
25
27
  * () => import('pdfjs-dist/legacy/build/pdf.js')
26
28
  */
27
- pdfjs?: () => Promise<typeof PDFJS>;
29
+ pdfjs?: () => Promise<PDFJS>;
28
30
  }
29
31
 
30
32
  /**
31
33
  * Returns a PDFDocumentProxy instance from a given binary data.
32
34
  *
33
35
  * Applies the following defaults:
34
- * - `useWorkerFetch: false`
35
36
  * - `isEvalSupported: false`
36
- * - `useSystemFonts: true`
37
37
  */
38
38
  declare function getDocumentProxy(data: BinaryData, options?: DocumentInitParameters): Promise<PDFDocumentProxy>;
39
39
  declare function defineUnPDFConfig(options: UnPDFConfiguration): Promise<void>;
40
- declare function getResolvedPDFJS(): Promise<typeof PDFJS>;
41
- declare function resolvePDFJSImports(pdfjs?: () => Promise<typeof PDFJS>): Promise<void>;
40
+ declare function getResolvedPDFJS(): Promise<PDFJS>;
41
+ declare function resolvePDFJSImports(pdfjsResolver?: () => Promise<PDFJS>, { force }?: {
42
+ force?: boolean | undefined;
43
+ }): Promise<void>;
42
44
 
43
45
  export { getImagesFromPage as a, getDocumentProxy as b, getResolvedPDFJS as c, defineUnPDFConfig as d, extractPDFText as e, getPDFMeta as g, resolvePDFJSImports as r };
@@ -1,5 +1,5 @@
1
- import { BinaryData, PDFDocumentProxy, DocumentInitParameters } from 'pdfjs-dist/types/src/display/api';
2
- import PDFJS from 'pdfjs-dist';
1
+ import { BinaryData, PDFDocumentProxy, DocumentInitParameters } from '../types/src/display/api';
2
+ import _PDFJS from '../types/src/pdf';
3
3
 
4
4
  declare function getPDFMeta(data: BinaryData | PDFDocumentProxy): Promise<{
5
5
  info: Record<string, any>;
@@ -15,6 +15,7 @@ declare function extractPDFText(data: BinaryData | PDFDocumentProxy, options?: {
15
15
 
16
16
  declare function getImagesFromPage(data: BinaryData | PDFDocumentProxy, pageNumber: number): Promise<ArrayBuffer[]>;
17
17
 
18
+ type PDFJS = typeof _PDFJS;
18
19
  interface UnPDFConfiguration {
19
20
  /**
20
21
  * By default, UnPDF will use the latest version of PDF.js. If you want to
@@ -22,22 +23,23 @@ interface UnPDFConfiguration {
22
23
  * the PDF.js module.
23
24
  *
24
25
  * @example
26
+ * // Use the legacy build
25
27
  * () => import('pdfjs-dist/legacy/build/pdf.js')
26
28
  */
27
- pdfjs?: () => Promise<typeof PDFJS>;
29
+ pdfjs?: () => Promise<PDFJS>;
28
30
  }
29
31
 
30
32
  /**
31
33
  * Returns a PDFDocumentProxy instance from a given binary data.
32
34
  *
33
35
  * Applies the following defaults:
34
- * - `useWorkerFetch: false`
35
36
  * - `isEvalSupported: false`
36
- * - `useSystemFonts: true`
37
37
  */
38
38
  declare function getDocumentProxy(data: BinaryData, options?: DocumentInitParameters): Promise<PDFDocumentProxy>;
39
39
  declare function defineUnPDFConfig(options: UnPDFConfiguration): Promise<void>;
40
- declare function getResolvedPDFJS(): Promise<typeof PDFJS>;
41
- declare function resolvePDFJSImports(pdfjs?: () => Promise<typeof PDFJS>): Promise<void>;
40
+ declare function getResolvedPDFJS(): Promise<PDFJS>;
41
+ declare function resolvePDFJSImports(pdfjsResolver?: () => Promise<PDFJS>, { force }?: {
42
+ force?: boolean | undefined;
43
+ }): Promise<void>;
42
44
 
43
45
  export { getImagesFromPage as a, getDocumentProxy as b, getResolvedPDFJS as c, defineUnPDFConfig as d, extractPDFText as e, getPDFMeta as g, resolvePDFJSImports as r };
@@ -0,0 +1,107 @@
1
+ 'use strict';
2
+
3
+ let resolvedModule;
4
+ async function getDocumentProxy(data, options = {}) {
5
+ const { getDocument } = await getResolvedPDFJS();
6
+ const pdf = await getDocument({
7
+ data,
8
+ isEvalSupported: false,
9
+ ...options
10
+ }).promise;
11
+ return pdf;
12
+ }
13
+ async function defineUnPDFConfig(options) {
14
+ const { pdfjs } = { ...options };
15
+ if (pdfjs) {
16
+ await resolvePDFJSImports(pdfjs, { force: true });
17
+ }
18
+ }
19
+ async function getResolvedPDFJS() {
20
+ if (!resolvedModule) {
21
+ await resolvePDFJSImports();
22
+ }
23
+ return resolvedModule;
24
+ }
25
+ async function resolvePDFJSImports(pdfjsResolver, { force = false } = {}) {
26
+ if (resolvedModule && !force) {
27
+ return;
28
+ }
29
+ if (pdfjsResolver) {
30
+ try {
31
+ const _import = await pdfjsResolver();
32
+ resolvedModule = _import.default || _import;
33
+ return;
34
+ } catch {
35
+ throw new Error(
36
+ "Resolving failed. Please check the provided configuration."
37
+ );
38
+ }
39
+ }
40
+ try {
41
+ resolvedModule = await import('unpdf/pdfjs');
42
+ } catch {
43
+ throw new Error(
44
+ "PDF.js is not available. Please add the package as a dependency."
45
+ );
46
+ }
47
+ }
48
+ function isPDFDocumentProxy(data) {
49
+ return typeof data === "object" && data !== null && "_pdfInfo" in data;
50
+ }
51
+
52
+ async function getPDFMeta(data) {
53
+ const pdf = isPDFDocumentProxy(data) ? data : await getDocumentProxy(data);
54
+ const meta = await pdf.getMetadata();
55
+ return {
56
+ info: meta?.info ?? {},
57
+ metadata: meta?.metadata?.getAll() ?? {}
58
+ };
59
+ }
60
+
61
+ async function extractPDFText(data, options = {}) {
62
+ const { mergePages = false } = { ...options };
63
+ const pdf = isPDFDocumentProxy(data) ? data : await getDocumentProxy(data);
64
+ const texts = await Promise.all(
65
+ Array.from({ length: pdf.numPages }, (_, i) => getPageText(pdf, i + 1))
66
+ );
67
+ const filteredTexts = texts.filter(Boolean);
68
+ return {
69
+ totalPages: pdf.numPages,
70
+ text: mergePages ? filteredTexts.join("\n\n") : filteredTexts
71
+ };
72
+ }
73
+ async function getPageText(pdf, pageNumber) {
74
+ const page = await pdf.getPage(pageNumber);
75
+ const content = await page.getTextContent();
76
+ const items = content.items;
77
+ if (items.length === 0) {
78
+ return;
79
+ }
80
+ return items.map(({ str }) => str).join("\n");
81
+ }
82
+
83
+ async function getImagesFromPage(data, pageNumber) {
84
+ const pdf = isPDFDocumentProxy(data) ? data : await getDocumentProxy(data);
85
+ const page = await pdf.getPage(pageNumber);
86
+ const operatorList = await page.getOperatorList();
87
+ const { OPS } = await getResolvedPDFJS();
88
+ const images = [];
89
+ for (const op of operatorList.fnArray) {
90
+ if (op !== OPS.paintImageXObject) {
91
+ continue;
92
+ }
93
+ const image = await page.objs.get(operatorList.argsArray[op][0]);
94
+ if (image.data) {
95
+ images.push(image.data.buffer);
96
+ }
97
+ }
98
+ return images;
99
+ }
100
+
101
+ exports.defineUnPDFConfig = defineUnPDFConfig;
102
+ exports.extractPDFText = extractPDFText;
103
+ exports.getDocumentProxy = getDocumentProxy;
104
+ exports.getImagesFromPage = getImagesFromPage;
105
+ exports.getPDFMeta = getPDFMeta;
106
+ exports.getResolvedPDFJS = getResolvedPDFJS;
107
+ exports.resolvePDFJSImports = resolvePDFJSImports;
@@ -0,0 +1,99 @@
1
+ let resolvedModule;
2
+ async function getDocumentProxy(data, options = {}) {
3
+ const { getDocument } = await getResolvedPDFJS();
4
+ const pdf = await getDocument({
5
+ data,
6
+ isEvalSupported: false,
7
+ ...options
8
+ }).promise;
9
+ return pdf;
10
+ }
11
+ async function defineUnPDFConfig(options) {
12
+ const { pdfjs } = { ...options };
13
+ if (pdfjs) {
14
+ await resolvePDFJSImports(pdfjs, { force: true });
15
+ }
16
+ }
17
+ async function getResolvedPDFJS() {
18
+ if (!resolvedModule) {
19
+ await resolvePDFJSImports();
20
+ }
21
+ return resolvedModule;
22
+ }
23
+ async function resolvePDFJSImports(pdfjsResolver, { force = false } = {}) {
24
+ if (resolvedModule && !force) {
25
+ return;
26
+ }
27
+ if (pdfjsResolver) {
28
+ try {
29
+ const _import = await pdfjsResolver();
30
+ resolvedModule = _import.default || _import;
31
+ return;
32
+ } catch {
33
+ throw new Error(
34
+ "Resolving failed. Please check the provided configuration."
35
+ );
36
+ }
37
+ }
38
+ try {
39
+ resolvedModule = await import('unpdf/pdfjs');
40
+ } catch {
41
+ throw new Error(
42
+ "PDF.js is not available. Please add the package as a dependency."
43
+ );
44
+ }
45
+ }
46
+ function isPDFDocumentProxy(data) {
47
+ return typeof data === "object" && data !== null && "_pdfInfo" in data;
48
+ }
49
+
50
+ async function getPDFMeta(data) {
51
+ const pdf = isPDFDocumentProxy(data) ? data : await getDocumentProxy(data);
52
+ const meta = await pdf.getMetadata();
53
+ return {
54
+ info: meta?.info ?? {},
55
+ metadata: meta?.metadata?.getAll() ?? {}
56
+ };
57
+ }
58
+
59
+ async function extractPDFText(data, options = {}) {
60
+ const { mergePages = false } = { ...options };
61
+ const pdf = isPDFDocumentProxy(data) ? data : await getDocumentProxy(data);
62
+ const texts = await Promise.all(
63
+ Array.from({ length: pdf.numPages }, (_, i) => getPageText(pdf, i + 1))
64
+ );
65
+ const filteredTexts = texts.filter(Boolean);
66
+ return {
67
+ totalPages: pdf.numPages,
68
+ text: mergePages ? filteredTexts.join("\n\n") : filteredTexts
69
+ };
70
+ }
71
+ async function getPageText(pdf, pageNumber) {
72
+ const page = await pdf.getPage(pageNumber);
73
+ const content = await page.getTextContent();
74
+ const items = content.items;
75
+ if (items.length === 0) {
76
+ return;
77
+ }
78
+ return items.map(({ str }) => str).join("\n");
79
+ }
80
+
81
+ async function getImagesFromPage(data, pageNumber) {
82
+ const pdf = isPDFDocumentProxy(data) ? data : await getDocumentProxy(data);
83
+ const page = await pdf.getPage(pageNumber);
84
+ const operatorList = await page.getOperatorList();
85
+ const { OPS } = await getResolvedPDFJS();
86
+ const images = [];
87
+ for (const op of operatorList.fnArray) {
88
+ if (op !== OPS.paintImageXObject) {
89
+ continue;
90
+ }
91
+ const image = await page.objs.get(operatorList.argsArray[op][0]);
92
+ if (image.data) {
93
+ images.push(image.data.buffer);
94
+ }
95
+ }
96
+ return images;
97
+ }
98
+
99
+ export { getImagesFromPage as a, getDocumentProxy as b, getResolvedPDFJS as c, defineUnPDFConfig as d, extractPDFText as e, getPDFMeta as g, resolvePDFJSImports as r };
File without changes
@@ -0,0 +1,203 @@
1
+ export type PDFPageProxy = import("./api").PDFPageProxy;
2
+ export type PageViewport = import("./display_utils").PageViewport;
3
+ export type IDownloadManager = any;
4
+ export type IPDFLinkService = import("../../web/interfaces").IPDFLinkService;
5
+ export type AnnotationElementParameters = {
6
+ data: Object;
7
+ layer: HTMLDivElement;
8
+ linkService: IPDFLinkService;
9
+ downloadManager: any;
10
+ annotationStorage?: AnnotationStorage | undefined;
11
+ /**
12
+ * - Path for image resources, mainly
13
+ * for annotation icons. Include trailing slash.
14
+ */
15
+ imageResourcesPath?: string | undefined;
16
+ renderForms: boolean;
17
+ svgFactory: Object;
18
+ enableScripting?: boolean | undefined;
19
+ hasJSActions?: boolean | undefined;
20
+ fieldObjects?: Object | undefined;
21
+ };
22
+ export type AnnotationLayerParameters = {
23
+ viewport: PageViewport;
24
+ div: HTMLDivElement;
25
+ annotations: any[];
26
+ page: PDFPageProxy;
27
+ linkService: IPDFLinkService;
28
+ downloadManager: any;
29
+ annotationStorage?: AnnotationStorage | undefined;
30
+ /**
31
+ * - Path for image resources, mainly
32
+ * for annotation icons. Include trailing slash.
33
+ */
34
+ imageResourcesPath?: string | undefined;
35
+ renderForms: boolean;
36
+ /**
37
+ * - Enable embedded script execution.
38
+ */
39
+ enableScripting?: boolean | undefined;
40
+ /**
41
+ * - Some fields have JS actions.
42
+ * The default value is `false`.
43
+ */
44
+ hasJSActions?: boolean | undefined;
45
+ fieldObjects?: {
46
+ [x: string]: Object[];
47
+ } | null | undefined;
48
+ annotationCanvasMap?: Map<string, HTMLCanvasElement> | undefined;
49
+ accessibilityManager?: any;
50
+ };
51
+ /**
52
+ * @typedef {Object} AnnotationLayerParameters
53
+ * @property {PageViewport} viewport
54
+ * @property {HTMLDivElement} div
55
+ * @property {Array} annotations
56
+ * @property {PDFPageProxy} page
57
+ * @property {IPDFLinkService} linkService
58
+ * @property {IDownloadManager} downloadManager
59
+ * @property {AnnotationStorage} [annotationStorage]
60
+ * @property {string} [imageResourcesPath] - Path for image resources, mainly
61
+ * for annotation icons. Include trailing slash.
62
+ * @property {boolean} renderForms
63
+ * @property {boolean} [enableScripting] - Enable embedded script execution.
64
+ * @property {boolean} [hasJSActions] - Some fields have JS actions.
65
+ * The default value is `false`.
66
+ * @property {Object<string, Array<Object>> | null} [fieldObjects]
67
+ * @property {Map<string, HTMLCanvasElement>} [annotationCanvasMap]
68
+ * @property {TextAccessibilityManager} [accessibilityManager]
69
+ */
70
+ /**
71
+ * Manage the layer containing all the annotations.
72
+ */
73
+ export class AnnotationLayer {
74
+ constructor({ div, accessibilityManager, annotationCanvasMap, l10n, page, viewport, }: {
75
+ div: any;
76
+ accessibilityManager: any;
77
+ annotationCanvasMap: any;
78
+ l10n: any;
79
+ page: any;
80
+ viewport: any;
81
+ });
82
+ div: any;
83
+ l10n: any;
84
+ page: any;
85
+ viewport: any;
86
+ zIndex: number;
87
+ popupShow: any[] | undefined;
88
+ /**
89
+ * Render a new annotation layer with all annotation elements.
90
+ *
91
+ * @param {AnnotationLayerParameters} params
92
+ * @memberof AnnotationLayer
93
+ */
94
+ render(params: AnnotationLayerParameters): Promise<void>;
95
+ /**
96
+ * Update the annotation elements on existing annotation layer.
97
+ *
98
+ * @param {AnnotationLayerParameters} viewport
99
+ * @memberof AnnotationLayer
100
+ */
101
+ update({ viewport }: AnnotationLayerParameters): void;
102
+ getEditableAnnotations(): any[];
103
+ getEditableAnnotation(id: any): any;
104
+ #private;
105
+ }
106
+ export class FreeTextAnnotationElement extends AnnotationElement {
107
+ constructor(parameters: any);
108
+ textContent: any;
109
+ textPosition: any;
110
+ annotationEditorType: number;
111
+ render(): HTMLElement | undefined;
112
+ }
113
+ export class InkAnnotationElement extends AnnotationElement {
114
+ constructor(parameters: any);
115
+ containerClassName: string;
116
+ svgElementName: string;
117
+ annotationEditorType: number;
118
+ render(): HTMLElement | undefined;
119
+ getElementsToTriggerPopup(): any[];
120
+ #private;
121
+ }
122
+ export class StampAnnotationElement extends AnnotationElement {
123
+ constructor(parameters: any);
124
+ render(): HTMLElement | undefined;
125
+ }
126
+ import { AnnotationStorage } from "./annotation_storage.js";
127
+ declare class AnnotationElement {
128
+ constructor(parameters: any, { isRenderable, ignoreBorder, createQuadrilaterals, }?: {
129
+ isRenderable?: boolean | undefined;
130
+ ignoreBorder?: boolean | undefined;
131
+ createQuadrilaterals?: boolean | undefined;
132
+ });
133
+ isRenderable: boolean;
134
+ data: any;
135
+ layer: any;
136
+ linkService: any;
137
+ downloadManager: any;
138
+ imageResourcesPath: any;
139
+ renderForms: any;
140
+ svgFactory: any;
141
+ annotationStorage: any;
142
+ enableScripting: any;
143
+ hasJSActions: any;
144
+ _fieldObjects: any;
145
+ parent: any;
146
+ container: HTMLElement | undefined;
147
+ /**
148
+ * Create an empty container for the annotation's HTML element.
149
+ *
150
+ * @private
151
+ * @param {boolean} ignoreBorder
152
+ * @memberof AnnotationElement
153
+ * @returns {HTMLElement} A section element.
154
+ */
155
+ private _createContainer;
156
+ setRotation(angle: any, container?: HTMLElement | undefined): void;
157
+ get _commonActions(): any;
158
+ _dispatchEventFromSandbox(actions: any, jsEvent: any): void;
159
+ _setDefaultPropertiesFromJS(element: any): void;
160
+ /**
161
+ * Create quadrilaterals from the annotation's quadpoints.
162
+ *
163
+ * @private
164
+ * @memberof AnnotationElement
165
+ */
166
+ private _createQuadrilaterals;
167
+ /**
168
+ * Create a popup for the annotation's HTML element. This is used for
169
+ * annotations that do not have a Popup entry in the dictionary, but
170
+ * are of a type that works with popups (such as Highlight annotations).
171
+ *
172
+ * @private
173
+ * @memberof AnnotationElement
174
+ */
175
+ private _createPopup;
176
+ /**
177
+ * Render the annotation's HTML element(s).
178
+ *
179
+ * @public
180
+ * @memberof AnnotationElement
181
+ */
182
+ public render(): void;
183
+ /**
184
+ * @private
185
+ * @returns {Array}
186
+ */
187
+ private _getElementsByName;
188
+ show(): void;
189
+ hide(): void;
190
+ /**
191
+ * Get the HTML element(s) which can trigger a popup when clicked or hovered.
192
+ *
193
+ * @public
194
+ * @memberof AnnotationElement
195
+ * @returns {Array<HTMLElement>|HTMLElement} An array of elements or an
196
+ * element.
197
+ */
198
+ public getElementsToTriggerPopup(): Array<HTMLElement> | HTMLElement;
199
+ addHighlightArea(): void;
200
+ _editOnDoubleClick(): void;
201
+ #private;
202
+ }
203
+ export {};
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Key/value storage for annotation data in forms.
3
+ */
4
+ export class AnnotationStorage {
5
+ onSetModified: any;
6
+ onResetModified: any;
7
+ onAnnotationEditor: any;
8
+ /**
9
+ * Get the value for a given key if it exists, or return the default value.
10
+ * @param {string} key
11
+ * @param {Object} defaultValue
12
+ * @returns {Object}
13
+ */
14
+ getValue(key: string, defaultValue: Object): Object;
15
+ /**
16
+ * Get the value for a given key.
17
+ * @param {string} key
18
+ * @returns {Object}
19
+ */
20
+ getRawValue(key: string): Object;
21
+ /**
22
+ * Remove a value from the storage.
23
+ * @param {string} key
24
+ */
25
+ remove(key: string): void;
26
+ /**
27
+ * Set the value for a given key
28
+ * @param {string} key
29
+ * @param {Object} value
30
+ */
31
+ setValue(key: string, value: Object): void;
32
+ /**
33
+ * Check if the storage contains the given key.
34
+ * @param {string} key
35
+ * @returns {boolean}
36
+ */
37
+ has(key: string): boolean;
38
+ /**
39
+ * @returns {Object | null}
40
+ */
41
+ getAll(): Object | null;
42
+ /**
43
+ * @param {Object} obj
44
+ */
45
+ setAll(obj: Object): void;
46
+ get size(): number;
47
+ resetModified(): void;
48
+ /**
49
+ * @returns {PrintAnnotationStorage}
50
+ */
51
+ get print(): PrintAnnotationStorage;
52
+ /**
53
+ * PLEASE NOTE: Only intended for usage within the API itself.
54
+ * @ignore
55
+ */
56
+ get serializable(): Readonly<{
57
+ map: null;
58
+ hash: "";
59
+ transfers: undefined;
60
+ }> | {
61
+ map: Map<any, any>;
62
+ hash: string;
63
+ transfers: any[];
64
+ };
65
+ #private;
66
+ }
67
+ /**
68
+ * A special `AnnotationStorage` for use during printing, where the serializable
69
+ * data is *frozen* upon initialization, to prevent scripting from modifying its
70
+ * contents. (Necessary since printing is triggered synchronously in browsers.)
71
+ */
72
+ export class PrintAnnotationStorage extends AnnotationStorage {
73
+ constructor(parent: any);
74
+ /**
75
+ * PLEASE NOTE: Only intended for usage within the API itself.
76
+ * @ignore
77
+ */
78
+ get serializable(): {
79
+ map: any;
80
+ hash: any;
81
+ transfers: any;
82
+ };
83
+ #private;
84
+ }
85
+ export const SerializableEmpty: Readonly<{
86
+ map: null;
87
+ hash: "";
88
+ transfers: undefined;
89
+ }>;