Merge pull request #14373 from Snuffleupagus/update-TypeScript
[api-minor] Fix broken/missing JSDocs and `typedef`s, to allow updating TypeScript to the latest version (issue 14342)
This commit is contained in:
commit
869b396011
36
package-lock.json
generated
36
package-lock.json
generated
@ -59,7 +59,7 @@
|
|||||||
"terser": "^5.10.0",
|
"terser": "^5.10.0",
|
||||||
"through2": "^4.0.2",
|
"through2": "^4.0.2",
|
||||||
"ttest": "^3.0.0",
|
"ttest": "^3.0.0",
|
||||||
"typescript": "~4.4.4",
|
"typescript": "^4.5.4",
|
||||||
"typogr": "^0.6.8",
|
"typogr": "^0.6.8",
|
||||||
"vinyl": "^2.2.1",
|
"vinyl": "^2.2.1",
|
||||||
"vinyl-fs": "^3.0.3",
|
"vinyl-fs": "^3.0.3",
|
||||||
@ -12389,7 +12389,6 @@
|
|||||||
},
|
},
|
||||||
"node_modules/npm/node_modules/lodash._baseindexof": {
|
"node_modules/npm/node_modules/lodash._baseindexof": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"extraneous": true,
|
|
||||||
"inBundle": true,
|
"inBundle": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
@ -12405,19 +12404,16 @@
|
|||||||
},
|
},
|
||||||
"node_modules/npm/node_modules/lodash._bindcallback": {
|
"node_modules/npm/node_modules/lodash._bindcallback": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"extraneous": true,
|
|
||||||
"inBundle": true,
|
"inBundle": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/npm/node_modules/lodash._cacheindexof": {
|
"node_modules/npm/node_modules/lodash._cacheindexof": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"extraneous": true,
|
|
||||||
"inBundle": true,
|
"inBundle": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/npm/node_modules/lodash._createcache": {
|
"node_modules/npm/node_modules/lodash._createcache": {
|
||||||
"version": "3.1.2",
|
"version": "3.1.2",
|
||||||
"extraneous": true,
|
|
||||||
"inBundle": true,
|
"inBundle": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -12432,7 +12428,6 @@
|
|||||||
},
|
},
|
||||||
"node_modules/npm/node_modules/lodash._getnative": {
|
"node_modules/npm/node_modules/lodash._getnative": {
|
||||||
"version": "3.9.1",
|
"version": "3.9.1",
|
||||||
"extraneous": true,
|
|
||||||
"inBundle": true,
|
"inBundle": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
@ -12450,7 +12445,6 @@
|
|||||||
},
|
},
|
||||||
"node_modules/npm/node_modules/lodash.restparam": {
|
"node_modules/npm/node_modules/lodash.restparam": {
|
||||||
"version": "3.6.1",
|
"version": "3.6.1",
|
||||||
"extraneous": true,
|
|
||||||
"inBundle": true,
|
"inBundle": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
@ -17845,9 +17839,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/typescript": {
|
"node_modules/typescript": {
|
||||||
"version": "4.4.4",
|
"version": "4.5.4",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz",
|
||||||
"integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==",
|
"integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
@ -28465,8 +28459,7 @@
|
|||||||
},
|
},
|
||||||
"lodash._baseindexof": {
|
"lodash._baseindexof": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"extraneous": true
|
|
||||||
},
|
},
|
||||||
"lodash._baseuniq": {
|
"lodash._baseuniq": {
|
||||||
"version": "4.6.0",
|
"version": "4.6.0",
|
||||||
@ -28479,18 +28472,15 @@
|
|||||||
},
|
},
|
||||||
"lodash._bindcallback": {
|
"lodash._bindcallback": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"extraneous": true
|
|
||||||
},
|
},
|
||||||
"lodash._cacheindexof": {
|
"lodash._cacheindexof": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"extraneous": true
|
|
||||||
},
|
},
|
||||||
"lodash._createcache": {
|
"lodash._createcache": {
|
||||||
"version": "3.1.2",
|
"version": "3.1.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"extraneous": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"lodash._getnative": "^3.0.0"
|
"lodash._getnative": "^3.0.0"
|
||||||
}
|
}
|
||||||
@ -28502,8 +28492,7 @@
|
|||||||
},
|
},
|
||||||
"lodash._getnative": {
|
"lodash._getnative": {
|
||||||
"version": "3.9.1",
|
"version": "3.9.1",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"extraneous": true
|
|
||||||
},
|
},
|
||||||
"lodash._root": {
|
"lodash._root": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
@ -28517,8 +28506,7 @@
|
|||||||
},
|
},
|
||||||
"lodash.restparam": {
|
"lodash.restparam": {
|
||||||
"version": "3.6.1",
|
"version": "3.6.1",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"extraneous": true
|
|
||||||
},
|
},
|
||||||
"lodash.union": {
|
"lodash.union": {
|
||||||
"version": "4.6.0",
|
"version": "4.6.0",
|
||||||
@ -32730,9 +32718,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"typescript": {
|
"typescript": {
|
||||||
"version": "4.4.4",
|
"version": "4.5.4",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz",
|
||||||
"integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==",
|
"integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"typogr": {
|
"typogr": {
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
"terser": "^5.10.0",
|
"terser": "^5.10.0",
|
||||||
"through2": "^4.0.2",
|
"through2": "^4.0.2",
|
||||||
"ttest": "^3.0.0",
|
"ttest": "^3.0.0",
|
||||||
"typescript": "~4.4.4",
|
"typescript": "^4.5.4",
|
||||||
"typogr": "^0.6.8",
|
"typogr": "^0.6.8",
|
||||||
"vinyl": "^2.2.1",
|
"vinyl": "^2.2.1",
|
||||||
"vinyl-fs": "^3.0.3",
|
"vinyl-fs": "^3.0.3",
|
||||||
|
@ -13,6 +13,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./api").PDFPageProxy} PDFPageProxy */
|
||||||
|
/** @typedef {import("./display_utils").PageViewport} PageViewport */
|
||||||
|
/** @typedef {import("./interfaces").IDownloadManager} IDownloadManager */
|
||||||
|
/** @typedef {import("../../web/interfaces").IPDFLinkService} IPDFLinkService */
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AnnotationBorderStyleType,
|
AnnotationBorderStyleType,
|
||||||
AnnotationType,
|
AnnotationType,
|
||||||
@ -39,10 +44,10 @@ const GetElementsByNameSet = new WeakSet();
|
|||||||
* @typedef {Object} AnnotationElementParameters
|
* @typedef {Object} AnnotationElementParameters
|
||||||
* @property {Object} data
|
* @property {Object} data
|
||||||
* @property {HTMLDivElement} layer
|
* @property {HTMLDivElement} layer
|
||||||
* @property {PDFPage} page
|
* @property {PDFPageProxy} page
|
||||||
* @property {PageViewport} viewport
|
* @property {PageViewport} viewport
|
||||||
* @property {IPDFLinkService} linkService
|
* @property {IPDFLinkService} linkService
|
||||||
* @property {DownloadManager} downloadManager
|
* @property {IDownloadManager} downloadManager
|
||||||
* @property {AnnotationStorage} [annotationStorage]
|
* @property {AnnotationStorage} [annotationStorage]
|
||||||
* @property {string} [imageResourcesPath] - Path for image resources, mainly
|
* @property {string} [imageResourcesPath] - Path for image resources, mainly
|
||||||
* for annotation icons. Include trailing slash.
|
* for annotation icons. Include trailing slash.
|
||||||
@ -1700,7 +1705,7 @@ class PopupElement {
|
|||||||
(!this.contentsObj?.str || this.contentsObj.str === this.richText.str)
|
(!this.contentsObj?.str || this.contentsObj.str === this.richText.str)
|
||||||
) {
|
) {
|
||||||
XfaLayer.render({
|
XfaLayer.render({
|
||||||
xfa: this.richText.html,
|
xfaHtml: this.richText.html,
|
||||||
intent: "richText",
|
intent: "richText",
|
||||||
div: popup,
|
div: popup,
|
||||||
});
|
});
|
||||||
@ -2302,15 +2307,16 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
|
|||||||
* @property {PageViewport} viewport
|
* @property {PageViewport} viewport
|
||||||
* @property {HTMLDivElement} div
|
* @property {HTMLDivElement} div
|
||||||
* @property {Array} annotations
|
* @property {Array} annotations
|
||||||
* @property {PDFPage} page
|
* @property {PDFPageProxy} page
|
||||||
* @property {IPDFLinkService} linkService
|
* @property {IPDFLinkService} linkService
|
||||||
* @property {DownloadManager} downloadManager
|
* @property {IDownloadManager} downloadManager
|
||||||
* @property {string} [imageResourcesPath] - Path for image resources, mainly
|
* @property {string} [imageResourcesPath] - Path for image resources, mainly
|
||||||
* for annotation icons. Include trailing slash.
|
* for annotation icons. Include trailing slash.
|
||||||
* @property {boolean} renderForms
|
* @property {boolean} renderForms
|
||||||
* @property {boolean} [enableScripting] - Enable embedded script execution.
|
* @property {boolean} [enableScripting] - Enable embedded script execution.
|
||||||
* @property {boolean} [hasJSActions] - Some fields have JS actions.
|
* @property {boolean} [hasJSActions] - Some fields have JS actions.
|
||||||
* The default value is `false`.
|
* The default value is `false`.
|
||||||
|
* @property {Map<string, HTMLCanvasElement>} [annotationCanvasMap]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class AnnotationLayer {
|
class AnnotationLayer {
|
||||||
|
@ -1168,8 +1168,8 @@ class PDFDocumentProxy {
|
|||||||
* created from `PDFDocumentProxy.getOptionalContentConfig`. If `null`,
|
* created from `PDFDocumentProxy.getOptionalContentConfig`. If `null`,
|
||||||
* the configuration will be fetched automatically with the default visibility
|
* the configuration will be fetched automatically with the default visibility
|
||||||
* states set.
|
* states set.
|
||||||
* @property {Map<string, Canvas>} [annotationCanvasMap] - Map some annotation
|
* @property {Map<string, HTMLCanvasElement>} [annotationCanvasMap] - Map some
|
||||||
* ids with canvases used to render them.
|
* annotation ids with canvases used to render them.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,9 +13,22 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./display_utils").PageViewport} PageViewport */
|
||||||
|
/** @typedef {import("../../web/interfaces").IPDFLinkService} IPDFLinkService */
|
||||||
|
|
||||||
import { warn } from "../shared/util.js";
|
import { warn } from "../shared/util.js";
|
||||||
import { XfaText } from "./xfa_text.js";
|
import { XfaText } from "./xfa_text.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} XfaLayerParameters
|
||||||
|
* @property {PageViewport} viewport
|
||||||
|
* @property {HTMLDivElement} div
|
||||||
|
* @property {Object} xfaHtml
|
||||||
|
* @property {AnnotationStorage} [annotationStorage]
|
||||||
|
* @property {IPDFLinkService} linkService
|
||||||
|
* @property {string} [intent] - (default value is 'display').
|
||||||
|
*/
|
||||||
|
|
||||||
class XfaLayer {
|
class XfaLayer {
|
||||||
static setupStorage(html, id, element, storage, intent) {
|
static setupStorage(html, id, element, storage, intent) {
|
||||||
const storedData = storage.getValue(id, { value: null });
|
const storedData = storage.getValue(id, { value: null });
|
||||||
@ -143,10 +156,15 @@ class XfaLayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the XFA layer.
|
||||||
|
*
|
||||||
|
* @param {XfaLayerParameters} parameters
|
||||||
|
*/
|
||||||
static render(parameters) {
|
static render(parameters) {
|
||||||
const storage = parameters.annotationStorage;
|
const storage = parameters.annotationStorage;
|
||||||
const linkService = parameters.linkService;
|
const linkService = parameters.linkService;
|
||||||
const root = parameters.xfa;
|
const root = parameters.xfaHtml;
|
||||||
const intent = parameters.intent || "display";
|
const intent = parameters.intent || "display";
|
||||||
const rootHtml = document.createElement(root.name);
|
const rootHtml = document.createElement(root.name);
|
||||||
if (root.attributes) {
|
if (root.attributes) {
|
||||||
@ -252,11 +270,9 @@ class XfaLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the xfa layer.
|
* Update the XFA layer.
|
||||||
*
|
*
|
||||||
* @public
|
|
||||||
* @param {XfaLayerParameters} parameters
|
* @param {XfaLayerParameters} parameters
|
||||||
* @memberof XfaLayer
|
|
||||||
*/
|
*/
|
||||||
static update(parameters) {
|
static update(parameters) {
|
||||||
const transform = `matrix(${parameters.viewport.transform.join(",")})`;
|
const transform = `matrix(${parameters.viewport.transform.join(",")})`;
|
||||||
|
@ -272,7 +272,7 @@ class Rasterize {
|
|||||||
static async xfaLayer(
|
static async xfaLayer(
|
||||||
ctx,
|
ctx,
|
||||||
viewport,
|
viewport,
|
||||||
xfa,
|
xfaHtml,
|
||||||
fontRules,
|
fontRules,
|
||||||
annotationStorage,
|
annotationStorage,
|
||||||
isPrint
|
isPrint
|
||||||
@ -285,9 +285,9 @@ class Rasterize {
|
|||||||
|
|
||||||
// Rendering XFA layer as HTML.
|
// Rendering XFA layer as HTML.
|
||||||
XfaLayer.render({
|
XfaLayer.render({
|
||||||
xfa,
|
|
||||||
div,
|
|
||||||
viewport: viewport.clone({ dontFlip: true }),
|
viewport: viewport.clone({ dontFlip: true }),
|
||||||
|
div,
|
||||||
|
xfaHtml,
|
||||||
annotationStorage,
|
annotationStorage,
|
||||||
linkService: new SimpleLinkService(),
|
linkService: new SimpleLinkService(),
|
||||||
intent: isPrint ? "print" : "display",
|
intent: isPrint ? "print" : "display",
|
||||||
@ -688,11 +688,11 @@ class Driver {
|
|||||||
initPromise = page.getAnnotations({ intent: "display" });
|
initPromise = page.getAnnotations({ intent: "display" });
|
||||||
annotationCanvasMap = new Map();
|
annotationCanvasMap = new Map();
|
||||||
} else {
|
} else {
|
||||||
initPromise = page.getXfa().then(function (xfa) {
|
initPromise = page.getXfa().then(function (xfaHtml) {
|
||||||
return Rasterize.xfaLayer(
|
return Rasterize.xfaLayer(
|
||||||
annotationLayerContext,
|
annotationLayerContext,
|
||||||
viewport,
|
viewport,
|
||||||
xfa,
|
xfaHtml,
|
||||||
task.fontRules,
|
task.fontRules,
|
||||||
task.pdfDoc.annotationStorage,
|
task.pdfDoc.annotationStorage,
|
||||||
task.renderPrint
|
task.renderPrint
|
||||||
|
@ -13,30 +13,33 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("../src/display/api").PDFPageProxy} PDFPageProxy */
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
/** @typedef {import("./interfaces").IPDFAnnotationLayerFactory} IPDFAnnotationLayerFactory */
|
/** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
|
||||||
|
/** @typedef {import("./interfaces").IDownloadManager} IDownloadManager */
|
||||||
|
/** @typedef {import("./interfaces").IL10n} IL10n */
|
||||||
|
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
|
||||||
|
|
||||||
import { AnnotationLayer } from "pdfjs-lib";
|
import { AnnotationLayer } from "pdfjs-lib";
|
||||||
import { NullL10n } from "./l10n_utils.js";
|
import { NullL10n } from "./l10n_utils.js";
|
||||||
import { SimpleLinkService } from "./pdf_link_service.js";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} AnnotationLayerBuilderOptions
|
* @typedef {Object} AnnotationLayerBuilderOptions
|
||||||
* @property {HTMLDivElement} pageDiv
|
* @property {HTMLDivElement} pageDiv
|
||||||
* @property {PDFPage} pdfPage
|
* @property {PDFPageProxy} pdfPage
|
||||||
* @property {AnnotationStorage} [annotationStorage]
|
* @property {AnnotationStorage} [annotationStorage]
|
||||||
* @property {string} [imageResourcesPath] - Path for image resources, mainly
|
* @property {string} [imageResourcesPath] - Path for image resources, mainly
|
||||||
* for annotation icons. Include trailing slash.
|
* for annotation icons. Include trailing slash.
|
||||||
* @property {boolean} renderForms
|
* @property {boolean} renderForms
|
||||||
* @property {IPDFLinkService} linkService
|
* @property {IPDFLinkService} linkService
|
||||||
* @property {DownloadManager} downloadManager
|
* @property {IDownloadManager} downloadManager
|
||||||
* @property {IL10n} l10n - Localization service.
|
* @property {IL10n} l10n - Localization service.
|
||||||
* @property {boolean} [enableScripting]
|
* @property {boolean} [enableScripting]
|
||||||
* @property {Promise<boolean>} [hasJSActionsPromise]
|
* @property {Promise<boolean>} [hasJSActionsPromise]
|
||||||
* @property {Promise<Object<string, Array<Object>> | null>}
|
* @property {Promise<Object<string, Array<Object>> | null>}
|
||||||
* [fieldObjectsPromise]
|
* [fieldObjectsPromise]
|
||||||
* @property {Object} [mouseState]
|
* @property {Object} [mouseState]
|
||||||
* @property {Map<string, Canvas>} [annotationCanvasMap]
|
* @property {Map<string, HTMLCanvasElement>} [annotationCanvasMap]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class AnnotationLayerBuilder {
|
class AnnotationLayerBuilder {
|
||||||
@ -140,55 +143,4 @@ class AnnotationLayerBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export { AnnotationLayerBuilder };
|
||||||
* @implements IPDFAnnotationLayerFactory
|
|
||||||
*/
|
|
||||||
class DefaultAnnotationLayerFactory {
|
|
||||||
/**
|
|
||||||
* @param {HTMLDivElement} pageDiv
|
|
||||||
* @param {PDFPage} pdfPage
|
|
||||||
* @param {AnnotationStorage} [annotationStorage]
|
|
||||||
* @param {string} [imageResourcesPath] - Path for image resources, mainly
|
|
||||||
* for annotation icons. Include trailing slash.
|
|
||||||
* @param {boolean} renderForms
|
|
||||||
* @param {IL10n} l10n
|
|
||||||
* @param {boolean} [enableScripting]
|
|
||||||
* @param {Promise<boolean>} [hasJSActionsPromise]
|
|
||||||
* @param {Object} [mouseState]
|
|
||||||
* @param {Promise<Object<string, Array<Object>> | null>}
|
|
||||||
* [fieldObjectsPromise]
|
|
||||||
* @param {Map<string, Canvas> | null} [annotationCanvasMap] - Map some
|
|
||||||
* annotation ids with canvases used to render them.
|
|
||||||
* @returns {AnnotationLayerBuilder}
|
|
||||||
*/
|
|
||||||
createAnnotationLayerBuilder(
|
|
||||||
pageDiv,
|
|
||||||
pdfPage,
|
|
||||||
annotationStorage = null,
|
|
||||||
imageResourcesPath = "",
|
|
||||||
renderForms = true,
|
|
||||||
l10n = NullL10n,
|
|
||||||
enableScripting = false,
|
|
||||||
hasJSActionsPromise = null,
|
|
||||||
mouseState = null,
|
|
||||||
fieldObjectsPromise = null,
|
|
||||||
annotationCanvasMap = null
|
|
||||||
) {
|
|
||||||
return new AnnotationLayerBuilder({
|
|
||||||
pageDiv,
|
|
||||||
pdfPage,
|
|
||||||
imageResourcesPath,
|
|
||||||
renderForms,
|
|
||||||
linkService: new SimpleLinkService(),
|
|
||||||
l10n,
|
|
||||||
annotationStorage,
|
|
||||||
enableScripting,
|
|
||||||
hasJSActionsPromise,
|
|
||||||
fieldObjectsPromise,
|
|
||||||
mouseState,
|
|
||||||
annotationCanvasMap,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { AnnotationLayerBuilder, DefaultAnnotationLayerFactory };
|
|
||||||
|
@ -29,6 +29,7 @@ import {
|
|||||||
parseQueryString,
|
parseQueryString,
|
||||||
ProgressBar,
|
ProgressBar,
|
||||||
RendererType,
|
RendererType,
|
||||||
|
RenderingStates,
|
||||||
ScrollMode,
|
ScrollMode,
|
||||||
SidebarView,
|
SidebarView,
|
||||||
SpreadMode,
|
SpreadMode,
|
||||||
@ -56,7 +57,6 @@ import {
|
|||||||
version,
|
version,
|
||||||
} from "pdfjs-lib";
|
} from "pdfjs-lib";
|
||||||
import { CursorTool, PDFCursorTools } from "./pdf_cursor_tools.js";
|
import { CursorTool, PDFCursorTools } from "./pdf_cursor_tools.js";
|
||||||
import { PDFRenderingQueue, RenderingStates } from "./pdf_rendering_queue.js";
|
|
||||||
import { OverlayManager } from "./overlay_manager.js";
|
import { OverlayManager } from "./overlay_manager.js";
|
||||||
import { PasswordPrompt } from "./password_prompt.js";
|
import { PasswordPrompt } from "./password_prompt.js";
|
||||||
import { PDFAttachmentViewer } from "./pdf_attachment_viewer.js";
|
import { PDFAttachmentViewer } from "./pdf_attachment_viewer.js";
|
||||||
@ -68,6 +68,7 @@ import { PDFLayerViewer } from "./pdf_layer_viewer.js";
|
|||||||
import { PDFLinkService } from "./pdf_link_service.js";
|
import { PDFLinkService } from "./pdf_link_service.js";
|
||||||
import { PDFOutlineViewer } from "./pdf_outline_viewer.js";
|
import { PDFOutlineViewer } from "./pdf_outline_viewer.js";
|
||||||
import { PDFPresentationMode } from "./pdf_presentation_mode.js";
|
import { PDFPresentationMode } from "./pdf_presentation_mode.js";
|
||||||
|
import { PDFRenderingQueue } from "./pdf_rendering_queue.js";
|
||||||
import { PDFScriptingManager } from "./pdf_scripting_manager.js";
|
import { PDFScriptingManager } from "./pdf_scripting_manager.js";
|
||||||
import { PDFSidebar } from "./pdf_sidebar.js";
|
import { PDFSidebar } from "./pdf_sidebar.js";
|
||||||
import { PDFSidebarResizer } from "./pdf_sidebar_resizer.js";
|
import { PDFSidebarResizer } from "./pdf_sidebar_resizer.js";
|
||||||
|
@ -13,6 +13,22 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("../src/display/api").PDFDocumentProxy} PDFDocumentProxy */
|
||||||
|
/** @typedef {import("../src/display/api").PDFPageProxy} PDFPageProxy */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
|
||||||
|
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||||
|
/** @typedef {import("./interfaces").IDownloadManager} IDownloadManager */
|
||||||
|
/** @typedef {import("./interfaces").IL10n} IL10n */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./interfaces").IPDFAnnotationLayerFactory} IPDFAnnotationLayerFactory */
|
||||||
|
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./interfaces").IPDFStructTreeLayerFactory} IPDFStructTreeLayerFactory */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./interfaces").IPDFTextLayerFactory} IPDFTextLayerFactory */
|
||||||
|
/** @typedef {import("./interfaces").IPDFXfaLayerFactory} IPDFXfaLayerFactory */
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AnnotationMode,
|
AnnotationMode,
|
||||||
createPromiseCapability,
|
createPromiseCapability,
|
||||||
@ -34,6 +50,7 @@ import {
|
|||||||
MIN_SCALE,
|
MIN_SCALE,
|
||||||
PresentationModeState,
|
PresentationModeState,
|
||||||
RendererType,
|
RendererType,
|
||||||
|
RenderingStates,
|
||||||
SCROLLBAR_PADDING,
|
SCROLLBAR_PADDING,
|
||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
ScrollMode,
|
ScrollMode,
|
||||||
@ -43,10 +60,10 @@ import {
|
|||||||
VERTICAL_PADDING,
|
VERTICAL_PADDING,
|
||||||
watchScroll,
|
watchScroll,
|
||||||
} from "./ui_utils.js";
|
} from "./ui_utils.js";
|
||||||
import { PDFRenderingQueue, RenderingStates } from "./pdf_rendering_queue.js";
|
|
||||||
import { AnnotationLayerBuilder } from "./annotation_layer_builder.js";
|
import { AnnotationLayerBuilder } from "./annotation_layer_builder.js";
|
||||||
import { NullL10n } from "./l10n_utils.js";
|
import { NullL10n } from "./l10n_utils.js";
|
||||||
import { PDFPageView } from "./pdf_page_view.js";
|
import { PDFPageView } from "./pdf_page_view.js";
|
||||||
|
import { PDFRenderingQueue } from "./pdf_rendering_queue.js";
|
||||||
import { SimpleLinkService } from "./pdf_link_service.js";
|
import { SimpleLinkService } from "./pdf_link_service.js";
|
||||||
import { StructTreeLayerBuilder } from "./struct_tree_layer_builder.js";
|
import { StructTreeLayerBuilder } from "./struct_tree_layer_builder.js";
|
||||||
import { TextHighlighter } from "./text_highlighter.js";
|
import { TextHighlighter } from "./text_highlighter.js";
|
||||||
@ -68,7 +85,7 @@ const PagesCountLimit = {
|
|||||||
* @property {HTMLDivElement} [viewer] - The viewer element.
|
* @property {HTMLDivElement} [viewer] - The viewer element.
|
||||||
* @property {EventBus} eventBus - The application event bus.
|
* @property {EventBus} eventBus - The application event bus.
|
||||||
* @property {IPDFLinkService} linkService - The navigation/linking service.
|
* @property {IPDFLinkService} linkService - The navigation/linking service.
|
||||||
* @property {DownloadManager} [downloadManager] - The download manager
|
* @property {IDownloadManager} [downloadManager] - The download manager
|
||||||
* component.
|
* component.
|
||||||
* @property {PDFFindController} [findController] - The find controller
|
* @property {PDFFindController} [findController] - The find controller
|
||||||
* component.
|
* component.
|
||||||
@ -171,6 +188,11 @@ class PDFPageViewBuffer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple viewer control to display PDF content/pages.
|
* Simple viewer control to display PDF content/pages.
|
||||||
|
*
|
||||||
|
* @implements {IPDFAnnotationLayerFactory}
|
||||||
|
* @implements {IPDFStructTreeLayerFactory}
|
||||||
|
* @implements {IPDFTextLayerFactory}
|
||||||
|
* @implements {IPDFXfaLayerFactory}
|
||||||
*/
|
*/
|
||||||
class BaseViewer {
|
class BaseViewer {
|
||||||
#buffer = null;
|
#buffer = null;
|
||||||
@ -525,7 +547,7 @@ class BaseViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param pdfDocument {PDFDocument}
|
* @param {PDFDocumentProxy} pdfDocument
|
||||||
*/
|
*/
|
||||||
setDocument(pdfDocument) {
|
setDocument(pdfDocument) {
|
||||||
if (this.pdfDocument) {
|
if (this.pdfDocument) {
|
||||||
@ -1587,7 +1609,7 @@ class BaseViewer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {HTMLDivElement} pageDiv
|
* @param {HTMLDivElement} pageDiv
|
||||||
* @param {PDFPage} pdfPage
|
* @param {PDFPageProxy} pdfPage
|
||||||
* @param {AnnotationStorage} [annotationStorage] - Storage for annotation
|
* @param {AnnotationStorage} [annotationStorage] - Storage for annotation
|
||||||
* data in forms.
|
* data in forms.
|
||||||
* @param {string} [imageResourcesPath] - Path for image resources, mainly
|
* @param {string} [imageResourcesPath] - Path for image resources, mainly
|
||||||
@ -1599,7 +1621,7 @@ class BaseViewer {
|
|||||||
* @param {Object} [mouseState]
|
* @param {Object} [mouseState]
|
||||||
* @param {Promise<Object<string, Array<Object>> | null>}
|
* @param {Promise<Object<string, Array<Object>> | null>}
|
||||||
* [fieldObjectsPromise]
|
* [fieldObjectsPromise]
|
||||||
* @param {Map<string, Canvas>} [annotationCanvasMap]
|
* @param {Map<string, HTMLCanvasElement>} [annotationCanvasMap]
|
||||||
* @returns {AnnotationLayerBuilder}
|
* @returns {AnnotationLayerBuilder}
|
||||||
*/
|
*/
|
||||||
createAnnotationLayerBuilder(
|
createAnnotationLayerBuilder(
|
||||||
@ -1637,7 +1659,7 @@ class BaseViewer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {HTMLDivElement} pageDiv
|
* @param {HTMLDivElement} pageDiv
|
||||||
* @param {PDFPage} pdfPage
|
* @param {PDFPageProxy} pdfPage
|
||||||
* @param {AnnotationStorage} [annotationStorage] - Storage for annotation
|
* @param {AnnotationStorage} [annotationStorage] - Storage for annotation
|
||||||
* data in forms.
|
* data in forms.
|
||||||
* @returns {XfaLayerBuilder}
|
* @returns {XfaLayerBuilder}
|
||||||
@ -1653,7 +1675,7 @@ class BaseViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {PDFPage} pdfPage
|
* @param {PDFPageProxy} pdfPage
|
||||||
* @returns {StructTreeLayerBuilder}
|
* @returns {StructTreeLayerBuilder}
|
||||||
*/
|
*/
|
||||||
createStructTreeLayerBuilder(pdfPage) {
|
createStructTreeLayerBuilder(pdfPage) {
|
||||||
|
168
web/default_factory.js
Normal file
168
web/default_factory.js
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
/* Copyright 2014 Mozilla Foundation
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("../src/display/api").PDFPageProxy} PDFPageProxy */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
|
||||||
|
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||||
|
/** @typedef {import("./interfaces").IDownloadManager} IDownloadManager */
|
||||||
|
/** @typedef {import("./interfaces").IL10n} IL10n */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./interfaces").IPDFAnnotationLayerFactory} IPDFAnnotationLayerFactory */
|
||||||
|
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./interfaces").IPDFStructTreeLayerFactory} IPDFStructTreeLayerFactory */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./interfaces").IPDFTextLayerFactory} IPDFTextLayerFactory */
|
||||||
|
/** @typedef {import("./interfaces").IPDFXfaLayerFactory} IPDFXfaLayerFactory */
|
||||||
|
/** @typedef {import("./text_highlighter").TextHighlighter} TextHighlighter */
|
||||||
|
|
||||||
|
import { AnnotationLayerBuilder } from "./annotation_layer_builder.js";
|
||||||
|
import { NullL10n } from "./l10n_utils.js";
|
||||||
|
import { SimpleLinkService } from "./pdf_link_service.js";
|
||||||
|
import { StructTreeLayerBuilder } from "./struct_tree_layer_builder.js";
|
||||||
|
import { TextLayerBuilder } from "./text_layer_builder.js";
|
||||||
|
import { XfaLayerBuilder } from "./xfa_layer_builder.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implements IPDFAnnotationLayerFactory
|
||||||
|
*/
|
||||||
|
class DefaultAnnotationLayerFactory {
|
||||||
|
/**
|
||||||
|
* @param {HTMLDivElement} pageDiv
|
||||||
|
* @param {PDFPageProxy} pdfPage
|
||||||
|
* @param {AnnotationStorage} [annotationStorage]
|
||||||
|
* @param {string} [imageResourcesPath] - Path for image resources, mainly
|
||||||
|
* for annotation icons. Include trailing slash.
|
||||||
|
* @param {boolean} renderForms
|
||||||
|
* @param {IL10n} l10n
|
||||||
|
* @param {boolean} [enableScripting]
|
||||||
|
* @param {Promise<boolean>} [hasJSActionsPromise]
|
||||||
|
* @param {Object} [mouseState]
|
||||||
|
* @param {Promise<Object<string, Array<Object>> | null>}
|
||||||
|
* [fieldObjectsPromise]
|
||||||
|
* @param {Map<string, HTMLCanvasElement>} [annotationCanvasMap] - Map some
|
||||||
|
* annotation ids with canvases used to render them.
|
||||||
|
* @returns {AnnotationLayerBuilder}
|
||||||
|
*/
|
||||||
|
createAnnotationLayerBuilder(
|
||||||
|
pageDiv,
|
||||||
|
pdfPage,
|
||||||
|
annotationStorage = null,
|
||||||
|
imageResourcesPath = "",
|
||||||
|
renderForms = true,
|
||||||
|
l10n = NullL10n,
|
||||||
|
enableScripting = false,
|
||||||
|
hasJSActionsPromise = null,
|
||||||
|
mouseState = null,
|
||||||
|
fieldObjectsPromise = null,
|
||||||
|
annotationCanvasMap = null
|
||||||
|
) {
|
||||||
|
return new AnnotationLayerBuilder({
|
||||||
|
pageDiv,
|
||||||
|
pdfPage,
|
||||||
|
imageResourcesPath,
|
||||||
|
renderForms,
|
||||||
|
linkService: new SimpleLinkService(),
|
||||||
|
l10n,
|
||||||
|
annotationStorage,
|
||||||
|
enableScripting,
|
||||||
|
hasJSActionsPromise,
|
||||||
|
fieldObjectsPromise,
|
||||||
|
mouseState,
|
||||||
|
annotationCanvasMap,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implements IPDFStructTreeLayerFactory
|
||||||
|
*/
|
||||||
|
class DefaultStructTreeLayerFactory {
|
||||||
|
/**
|
||||||
|
* @param {PDFPageProxy} pdfPage
|
||||||
|
* @returns {StructTreeLayerBuilder}
|
||||||
|
*/
|
||||||
|
createStructTreeLayerBuilder(pdfPage) {
|
||||||
|
return new StructTreeLayerBuilder({
|
||||||
|
pdfPage,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implements IPDFTextLayerFactory
|
||||||
|
*/
|
||||||
|
class DefaultTextLayerFactory {
|
||||||
|
/**
|
||||||
|
* @param {HTMLDivElement} textLayerDiv
|
||||||
|
* @param {number} pageIndex
|
||||||
|
* @param {PageViewport} viewport
|
||||||
|
* @param {boolean} enhanceTextSelection
|
||||||
|
* @param {EventBus} eventBus
|
||||||
|
* @param {TextHighlighter} highlighter
|
||||||
|
* @returns {TextLayerBuilder}
|
||||||
|
*/
|
||||||
|
createTextLayerBuilder(
|
||||||
|
textLayerDiv,
|
||||||
|
pageIndex,
|
||||||
|
viewport,
|
||||||
|
enhanceTextSelection = false,
|
||||||
|
eventBus,
|
||||||
|
highlighter
|
||||||
|
) {
|
||||||
|
return new TextLayerBuilder({
|
||||||
|
textLayerDiv,
|
||||||
|
pageIndex,
|
||||||
|
viewport,
|
||||||
|
enhanceTextSelection,
|
||||||
|
eventBus,
|
||||||
|
highlighter,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implements IPDFXfaLayerFactory
|
||||||
|
*/
|
||||||
|
class DefaultXfaLayerFactory {
|
||||||
|
/**
|
||||||
|
* @param {HTMLDivElement} pageDiv
|
||||||
|
* @param {PDFPageProxy} pdfPage
|
||||||
|
* @param {AnnotationStorage} [annotationStorage]
|
||||||
|
* @param {Object} [xfaHtml]
|
||||||
|
*/
|
||||||
|
createXfaLayerBuilder(
|
||||||
|
pageDiv,
|
||||||
|
pdfPage,
|
||||||
|
annotationStorage = null,
|
||||||
|
xfaHtml = null
|
||||||
|
) {
|
||||||
|
return new XfaLayerBuilder({
|
||||||
|
pageDiv,
|
||||||
|
pdfPage,
|
||||||
|
annotationStorage,
|
||||||
|
linkService: new SimpleLinkService(),
|
||||||
|
xfaHtml,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
DefaultAnnotationLayerFactory,
|
||||||
|
DefaultStructTreeLayerFactory,
|
||||||
|
DefaultTextLayerFactory,
|
||||||
|
DefaultXfaLayerFactory,
|
||||||
|
};
|
@ -13,6 +13,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./interfaces").IDownloadManager} IDownloadManager */
|
||||||
|
|
||||||
import { createObjectURL, createValidAbsoluteUrl, isPdfFile } from "pdfjs-lib";
|
import { createObjectURL, createValidAbsoluteUrl, isPdfFile } from "pdfjs-lib";
|
||||||
import { compatibilityParams } from "./app_options.js";
|
import { compatibilityParams } from "./app_options.js";
|
||||||
|
|
||||||
@ -42,6 +44,9 @@ function download(blobUrl, filename) {
|
|||||||
a.remove();
|
a.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implements {IDownloadManager}
|
||||||
|
*/
|
||||||
class DownloadManager {
|
class DownloadManager {
|
||||||
constructor() {
|
constructor() {
|
||||||
this._openBlobUrls = new WeakMap();
|
this._openBlobUrls = new WeakMap();
|
||||||
|
@ -13,11 +13,16 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./interfaces").IL10n} IL10n */
|
||||||
|
|
||||||
import "../external/webL10n/l10n.js";
|
import "../external/webL10n/l10n.js";
|
||||||
import { fixupLangCode, getL10nFallback } from "./l10n_utils.js";
|
import { fixupLangCode, getL10nFallback } from "./l10n_utils.js";
|
||||||
|
|
||||||
const webL10n = document.webL10n;
|
const webL10n = document.webL10n;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implements {IL10n}
|
||||||
|
*/
|
||||||
class GenericL10n {
|
class GenericL10n {
|
||||||
constructor(lang) {
|
constructor(lang) {
|
||||||
this._lang = lang;
|
this._lang = lang;
|
||||||
|
@ -14,6 +14,20 @@
|
|||||||
*/
|
*/
|
||||||
/* eslint-disable getter-return */
|
/* eslint-disable getter-return */
|
||||||
|
|
||||||
|
/** @typedef {import("../src/display/api").PDFPageProxy} PDFPageProxy */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./annotation_layer_builder").AnnotationLayerBuilder} AnnotationLayerBuilder */
|
||||||
|
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./struct_tree_builder").StructTreeLayerBuilder} StructTreeLayerBuilder */
|
||||||
|
/** @typedef {import("./text_highlighter").TextHighlighter} TextHighlighter */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./text_layer_builder").TextLayerBuilder} TextLayerBuilder */
|
||||||
|
/** @typedef {import("./ui_utils").RenderingStates} RenderingStates */
|
||||||
|
/** @typedef {import("./xfa_layer_builder").XfaLayerBuilder} XfaLayerBuilder */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
* @interface
|
||||||
*/
|
*/
|
||||||
@ -163,7 +177,7 @@ class IPDFTextLayerFactory {
|
|||||||
class IPDFAnnotationLayerFactory {
|
class IPDFAnnotationLayerFactory {
|
||||||
/**
|
/**
|
||||||
* @param {HTMLDivElement} pageDiv
|
* @param {HTMLDivElement} pageDiv
|
||||||
* @param {PDFPage} pdfPage
|
* @param {PDFPageProxy} pdfPage
|
||||||
* @param {AnnotationStorage} [annotationStorage] - Storage for annotation
|
* @param {AnnotationStorage} [annotationStorage] - Storage for annotation
|
||||||
* data in forms.
|
* data in forms.
|
||||||
* @param {string} [imageResourcesPath] - Path for image resources, mainly
|
* @param {string} [imageResourcesPath] - Path for image resources, mainly
|
||||||
@ -175,8 +189,8 @@ class IPDFAnnotationLayerFactory {
|
|||||||
* @param {Object} [mouseState]
|
* @param {Object} [mouseState]
|
||||||
* @param {Promise<Object<string, Array<Object>> | null>}
|
* @param {Promise<Object<string, Array<Object>> | null>}
|
||||||
* [fieldObjectsPromise]
|
* [fieldObjectsPromise]
|
||||||
* @property {Map<string, Canvas> | null} [annotationCanvasMap] - Map some
|
* @param {Map<string, HTMLCanvasElement>} [annotationCanvasMap] - Map some
|
||||||
* annotation ids with canvases used to render them.
|
* annotation ids with canvases used to render them.
|
||||||
* @returns {AnnotationLayerBuilder}
|
* @returns {AnnotationLayerBuilder}
|
||||||
*/
|
*/
|
||||||
createAnnotationLayerBuilder(
|
createAnnotationLayerBuilder(
|
||||||
@ -200,7 +214,7 @@ class IPDFAnnotationLayerFactory {
|
|||||||
class IPDFXfaLayerFactory {
|
class IPDFXfaLayerFactory {
|
||||||
/**
|
/**
|
||||||
* @param {HTMLDivElement} pageDiv
|
* @param {HTMLDivElement} pageDiv
|
||||||
* @param {PDFPage} pdfPage
|
* @param {PDFPageProxy} pdfPage
|
||||||
* @param {AnnotationStorage} [annotationStorage]
|
* @param {AnnotationStorage} [annotationStorage]
|
||||||
* @param {Object} [xfaHtml]
|
* @param {Object} [xfaHtml]
|
||||||
* @returns {XfaLayerBuilder}
|
* @returns {XfaLayerBuilder}
|
||||||
@ -218,12 +232,46 @@ class IPDFXfaLayerFactory {
|
|||||||
*/
|
*/
|
||||||
class IPDFStructTreeLayerFactory {
|
class IPDFStructTreeLayerFactory {
|
||||||
/**
|
/**
|
||||||
* @param {PDFPage} pdfPage
|
* @param {PDFPageProxy} pdfPage
|
||||||
* @returns {StructTreeLayerBuilder}
|
* @returns {StructTreeLayerBuilder}
|
||||||
*/
|
*/
|
||||||
createStructTreeLayerBuilder(pdfPage) {}
|
createStructTreeLayerBuilder(pdfPage) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @interface
|
||||||
|
*/
|
||||||
|
class IDownloadManager {
|
||||||
|
/**
|
||||||
|
* @param {string} url
|
||||||
|
* @param {string} filename
|
||||||
|
*/
|
||||||
|
downloadUrl(url, filename) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Uint8Array} data
|
||||||
|
* @param {string} filename
|
||||||
|
* @param {string} [contentType]
|
||||||
|
*/
|
||||||
|
downloadData(data, filename, contentType) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {HTMLElement} element
|
||||||
|
* @param {Uint8Array} data
|
||||||
|
* @param {string} filename
|
||||||
|
* @returns {boolean} Indicating if the data was opened.
|
||||||
|
*/
|
||||||
|
openOrDownloadData(element, data, filename) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Blob} blob
|
||||||
|
* @param {string} url
|
||||||
|
* @param {string} filename
|
||||||
|
* @param {string} [sourceEventType]
|
||||||
|
*/
|
||||||
|
download(blob, url, filename, sourceEventType = "download") {}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
* @interface
|
||||||
*/
|
*/
|
||||||
@ -243,11 +291,11 @@ class IL10n {
|
|||||||
* property bag. If the key was not found, translation falls back to the
|
* property bag. If the key was not found, translation falls back to the
|
||||||
* fallback text.
|
* fallback text.
|
||||||
* @param {string} key
|
* @param {string} key
|
||||||
* @param {object} args
|
* @param {Object | null} [args]
|
||||||
* @param {string} fallback
|
* @param {string} [fallback]
|
||||||
* @returns {Promise<string>}
|
* @returns {Promise<string>}
|
||||||
*/
|
*/
|
||||||
async get(key, args, fallback) {}
|
async get(key, args = null, fallback) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translates HTML element.
|
* Translates HTML element.
|
||||||
@ -258,6 +306,7 @@ class IL10n {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
IDownloadManager,
|
||||||
IL10n,
|
IL10n,
|
||||||
IPDFAnnotationLayerFactory,
|
IPDFAnnotationLayerFactory,
|
||||||
IPDFLinkService,
|
IPDFLinkService,
|
||||||
|
@ -13,6 +13,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("../src/display/api").PDFDocumentProxy} PDFDocumentProxy */
|
||||||
|
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||||
|
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
|
||||||
|
|
||||||
import { createPromiseCapability } from "pdfjs-lib";
|
import { createPromiseCapability } from "pdfjs-lib";
|
||||||
import { getCharacterType } from "./pdf_find_utils.js";
|
import { getCharacterType } from "./pdf_find_utils.js";
|
||||||
import { scrollIntoView } from "./ui_utils.js";
|
import { scrollIntoView } from "./ui_utils.js";
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||||
|
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
|
||||||
|
|
||||||
import {
|
import {
|
||||||
isValidRotation,
|
isValidRotation,
|
||||||
parseQueryString,
|
parseQueryString,
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||||
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
|
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
|
||||||
|
|
||||||
import { addLinkAttributes, LinkTarget } from "pdfjs-lib";
|
import { addLinkAttributes, LinkTarget } from "pdfjs-lib";
|
||||||
|
@ -13,7 +13,22 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("../src/display/optional_content_config").OptionalContentConfig} OptionalContentConfig */
|
||||||
|
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||||
|
/** @typedef {import("./interfaces").IL10n} IL10n */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./interfaces").IPDFAnnotationLayerFactory} IPDFAnnotationLayerFactory */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./interfaces").IPDFStructTreeLayerFactory} IPDFStructTreeLayerFactory */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./interfaces").IPDFTextLayerFactory} IPDFTextLayerFactory */
|
||||||
|
/** @typedef {import("./interfaces").IL10n} IPDFXfaLayerFactory */
|
||||||
/** @typedef {import("./interfaces").IRenderableView} IRenderableView */
|
/** @typedef {import("./interfaces").IRenderableView} IRenderableView */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./pdf_rendering_queue").PDFRenderingQueue} PDFRenderingQueue */
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AnnotationMode,
|
AnnotationMode,
|
||||||
@ -27,12 +42,12 @@ import {
|
|||||||
DEFAULT_SCALE,
|
DEFAULT_SCALE,
|
||||||
getOutputScale,
|
getOutputScale,
|
||||||
RendererType,
|
RendererType,
|
||||||
|
RenderingStates,
|
||||||
roundToDivide,
|
roundToDivide,
|
||||||
TextLayerMode,
|
TextLayerMode,
|
||||||
} from "./ui_utils.js";
|
} from "./ui_utils.js";
|
||||||
import { compatibilityParams } from "./app_options.js";
|
import { compatibilityParams } from "./app_options.js";
|
||||||
import { NullL10n } from "./l10n_utils.js";
|
import { NullL10n } from "./l10n_utils.js";
|
||||||
import { RenderingStates } from "./pdf_rendering_queue.js";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} PDFPageViewOptions
|
* @typedef {Object} PDFPageViewOptions
|
||||||
|
@ -13,17 +13,16 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./interfaces").IRenderableView} IRenderableView */
|
||||||
|
/** @typedef {import("./pdf_viewer").PDFViewer} PDFViewer */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./pdf_thumbnail_viewer").PDFThumbnailViewer} PDFThumbnailViewer */
|
||||||
|
|
||||||
import { RenderingCancelledException } from "pdfjs-lib";
|
import { RenderingCancelledException } from "pdfjs-lib";
|
||||||
|
import { RenderingStates } from "./ui_utils.js";
|
||||||
|
|
||||||
const CLEANUP_TIMEOUT = 30000;
|
const CLEANUP_TIMEOUT = 30000;
|
||||||
|
|
||||||
const RenderingStates = {
|
|
||||||
INITIAL: 0,
|
|
||||||
RUNNING: 1,
|
|
||||||
PAUSED: 2,
|
|
||||||
FINISHED: 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls rendering of the views for pages and thumbnails.
|
* Controls rendering of the views for pages and thumbnails.
|
||||||
*/
|
*/
|
||||||
@ -211,4 +210,4 @@ class PDFRenderingQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { PDFRenderingQueue, RenderingStates };
|
export { PDFRenderingQueue };
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||||
|
|
||||||
|
import { apiPageLayoutToViewerModes, RenderingStates } from "./ui_utils.js";
|
||||||
import { createPromiseCapability, shadow } from "pdfjs-lib";
|
import { createPromiseCapability, shadow } from "pdfjs-lib";
|
||||||
import { apiPageLayoutToViewerModes } from "./ui_utils.js";
|
|
||||||
import { RenderingStates } from "./pdf_rendering_queue.js";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} PDFScriptingManagerOptions
|
* @typedef {Object} PDFScriptingManagerOptions
|
||||||
|
@ -13,8 +13,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { PresentationModeState, SidebarView } from "./ui_utils.js";
|
import {
|
||||||
import { RenderingStates } from "./pdf_rendering_queue.js";
|
PresentationModeState,
|
||||||
|
RenderingStates,
|
||||||
|
SidebarView,
|
||||||
|
} from "./ui_utils.js";
|
||||||
|
|
||||||
const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
|
const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
|
||||||
|
|
||||||
|
@ -13,9 +13,14 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { getOutputScale } from "./ui_utils.js";
|
/** @typedef {import("./interfaces").IL10n} IL10n */
|
||||||
|
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
|
||||||
|
/** @typedef {import("./interfaces").IRenderableView} IRenderableView */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./pdf_rendering_queue").PDFRenderingQueue} PDFRenderingQueue */
|
||||||
|
|
||||||
|
import { getOutputScale, RenderingStates } from "./ui_utils.js";
|
||||||
import { RenderingCancelledException } from "pdfjs-lib";
|
import { RenderingCancelledException } from "pdfjs-lib";
|
||||||
import { RenderingStates } from "./pdf_rendering_queue.js";
|
|
||||||
|
|
||||||
const DRAW_UPSCALE_FACTOR = 2; // See comment in `PDFThumbnailView.draw` below.
|
const DRAW_UPSCALE_FACTOR = 2; // See comment in `PDFThumbnailView.draw` below.
|
||||||
const MAX_NUM_SCALING_STEPS = 3;
|
const MAX_NUM_SCALING_STEPS = 3;
|
||||||
|
@ -13,14 +13,21 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("../src/display/api").PDFDocumentProxy} PDFDocumentProxy */
|
||||||
|
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||||
|
/** @typedef {import("./interfaces").IL10n} IL10n */
|
||||||
|
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./pdf_rendering_queue").PDFRenderingQueue} PDFRenderingQueue */
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getVisibleElements,
|
getVisibleElements,
|
||||||
isValidRotation,
|
isValidRotation,
|
||||||
|
RenderingStates,
|
||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
watchScroll,
|
watchScroll,
|
||||||
} from "./ui_utils.js";
|
} from "./ui_utils.js";
|
||||||
import { PDFThumbnailView, TempImageFactory } from "./pdf_thumbnail_view.js";
|
import { PDFThumbnailView, TempImageFactory } from "./pdf_thumbnail_view.js";
|
||||||
import { RenderingStates } from "./pdf_rendering_queue.js";
|
|
||||||
|
|
||||||
const THUMBNAIL_SCROLL_MARGIN = -19;
|
const THUMBNAIL_SCROLL_MARGIN = -19;
|
||||||
const THUMBNAIL_SELECTED_CLASS = "selected";
|
const THUMBNAIL_SELECTED_CLASS = "selected";
|
||||||
@ -37,8 +44,6 @@ const THUMBNAIL_SELECTED_CLASS = "selected";
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Viewer control to display thumbnails for pages in a PDF document.
|
* Viewer control to display thumbnails for pages in a PDF document.
|
||||||
*
|
|
||||||
* @implements {IRenderableView}
|
|
||||||
*/
|
*/
|
||||||
class PDFThumbnailViewer {
|
class PDFThumbnailViewer {
|
||||||
/**
|
/**
|
||||||
@ -172,6 +177,9 @@ class PDFThumbnailViewer {
|
|||||||
this.container.textContent = "";
|
this.container.textContent = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {PDFDocumentProxy} pdfDocument
|
||||||
|
*/
|
||||||
setDocument(pdfDocument) {
|
setDocument(pdfDocument) {
|
||||||
if (this.pdfDocument) {
|
if (this.pdfDocument) {
|
||||||
this._cancelRendering();
|
this._cancelRendering();
|
||||||
|
@ -14,23 +14,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AnnotationLayerBuilder,
|
|
||||||
DefaultAnnotationLayerFactory,
|
DefaultAnnotationLayerFactory,
|
||||||
} from "./annotation_layer_builder.js";
|
|
||||||
import {
|
|
||||||
DefaultStructTreeLayerFactory,
|
DefaultStructTreeLayerFactory,
|
||||||
StructTreeLayerBuilder,
|
|
||||||
} from "./struct_tree_layer_builder.js";
|
|
||||||
import {
|
|
||||||
DefaultTextLayerFactory,
|
DefaultTextLayerFactory,
|
||||||
TextLayerBuilder,
|
|
||||||
} from "./text_layer_builder.js";
|
|
||||||
import {
|
|
||||||
DefaultXfaLayerFactory,
|
DefaultXfaLayerFactory,
|
||||||
XfaLayerBuilder,
|
} from "./default_factory.js";
|
||||||
} from "./xfa_layer_builder.js";
|
|
||||||
import { PDFLinkService, SimpleLinkService } from "./pdf_link_service.js";
|
import { PDFLinkService, SimpleLinkService } from "./pdf_link_service.js";
|
||||||
import { PDFSinglePageViewer, PDFViewer } from "./pdf_viewer.js";
|
import { PDFSinglePageViewer, PDFViewer } from "./pdf_viewer.js";
|
||||||
|
import { AnnotationLayerBuilder } from "./annotation_layer_builder.js";
|
||||||
import { DownloadManager } from "./download_manager.js";
|
import { DownloadManager } from "./download_manager.js";
|
||||||
import { EventBus } from "./event_utils.js";
|
import { EventBus } from "./event_utils.js";
|
||||||
import { GenericL10n } from "./genericl10n.js";
|
import { GenericL10n } from "./genericl10n.js";
|
||||||
@ -40,6 +31,9 @@ import { PDFHistory } from "./pdf_history.js";
|
|||||||
import { PDFPageView } from "./pdf_page_view.js";
|
import { PDFPageView } from "./pdf_page_view.js";
|
||||||
import { PDFScriptingManager } from "./pdf_scripting_manager.js";
|
import { PDFScriptingManager } from "./pdf_scripting_manager.js";
|
||||||
import { ProgressBar } from "./ui_utils.js";
|
import { ProgressBar } from "./ui_utils.js";
|
||||||
|
import { StructTreeLayerBuilder } from "./struct_tree_layer_builder.js";
|
||||||
|
import { TextLayerBuilder } from "./text_layer_builder.js";
|
||||||
|
import { XfaLayerBuilder } from "./xfa_layer_builder.js";
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const pdfjsVersion = PDFJSDev.eval("BUNDLE_VERSION");
|
const pdfjsVersion = PDFJSDev.eval("BUNDLE_VERSION");
|
||||||
|
@ -14,11 +14,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { getXfaPageViewport, PixelsPerInch } from "pdfjs-lib";
|
import { getXfaPageViewport, PixelsPerInch } from "pdfjs-lib";
|
||||||
import { DefaultXfaLayerFactory } from "./xfa_layer_builder.js";
|
import { SimpleLinkService } from "./pdf_link_service.js";
|
||||||
|
import { XfaLayerBuilder } from "./xfa_layer_builder.js";
|
||||||
|
|
||||||
function getXfaHtmlForPrinting(printContainer, pdfDocument) {
|
function getXfaHtmlForPrinting(printContainer, pdfDocument) {
|
||||||
const xfaHtml = pdfDocument.allXfaHtml;
|
const xfaHtml = pdfDocument.allXfaHtml;
|
||||||
const factory = new DefaultXfaLayerFactory();
|
const linkService = new SimpleLinkService();
|
||||||
const scale = Math.round(PixelsPerInch.PDF_TO_CSS_UNITS * 100) / 100;
|
const scale = Math.round(PixelsPerInch.PDF_TO_CSS_UNITS * 100) / 100;
|
||||||
|
|
||||||
for (const xfaPage of xfaHtml.children) {
|
for (const xfaPage of xfaHtml.children) {
|
||||||
@ -26,12 +27,13 @@ function getXfaHtmlForPrinting(printContainer, pdfDocument) {
|
|||||||
page.className = "xfaPrintedPage";
|
page.className = "xfaPrintedPage";
|
||||||
printContainer.appendChild(page);
|
printContainer.appendChild(page);
|
||||||
|
|
||||||
const builder = factory.createXfaLayerBuilder(
|
const builder = new XfaLayerBuilder({
|
||||||
/* pageDiv = */ page,
|
pageDiv: page,
|
||||||
/* pdfPage = */ null,
|
pdfPage: null,
|
||||||
/* annotationStorage = */ pdfDocument.annotationStorage,
|
annotationStorage: pdfDocument.annotationStorage,
|
||||||
/* xfaHtml = */ xfaPage
|
linkService,
|
||||||
);
|
xfaHtml: xfaPage,
|
||||||
|
});
|
||||||
const viewport = getXfaPageViewport(xfaPage, { scale });
|
const viewport = getXfaPageViewport(xfaPage, { scale });
|
||||||
|
|
||||||
builder.render(viewport, "print");
|
builder.render(viewport, "print");
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line max-len
|
/** @typedef {import("../src/display/api").PDFPageProxy} PDFPageProxy */
|
||||||
/** @typedef {import("./interfaces").IPDFStructTreeLayerFactory} IPDFStructTreeLayerFactory */
|
|
||||||
|
|
||||||
const PDF_ROLE_TO_HTML_ROLE = {
|
const PDF_ROLE_TO_HTML_ROLE = {
|
||||||
// Document level structure types
|
// Document level structure types
|
||||||
@ -76,7 +75,7 @@ const HEADING_PATTERN = /^H(\d+)$/;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} StructTreeLayerBuilderOptions
|
* @typedef {Object} StructTreeLayerBuilderOptions
|
||||||
* @property {PDFPage} pdfPage
|
* @property {PDFPageProxy} pdfPage
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class StructTreeLayerBuilder {
|
class StructTreeLayerBuilder {
|
||||||
@ -137,19 +136,4 @@ class StructTreeLayerBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export { StructTreeLayerBuilder };
|
||||||
* @implements IPDFStructTreeLayerFactory
|
|
||||||
*/
|
|
||||||
class DefaultStructTreeLayerFactory {
|
|
||||||
/**
|
|
||||||
* @param {PDFPage} pdfPage
|
|
||||||
* @returns {StructTreeLayerBuilder}
|
|
||||||
*/
|
|
||||||
createStructTreeLayerBuilder(pdfPage) {
|
|
||||||
return new StructTreeLayerBuilder({
|
|
||||||
pdfPage,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { DefaultStructTreeLayerFactory, StructTreeLayerBuilder };
|
|
||||||
|
@ -13,6 +13,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./pdf_find_controller").PDFFindController} PDFFindController */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} TextHighlighterOptions
|
* @typedef {Object} TextHighlighterOptions
|
||||||
* @property {PDFFindController} findController
|
* @property {PDFFindController} findController
|
||||||
|
@ -14,7 +14,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
/** @typedef {import("./interfaces").IPDFTextLayerFactory} IPDFTextLayerFactory */
|
/** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
|
||||||
|
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||||
|
/** @typedef {import("./text_highlighter").TextHighlighter} TextHighlighter */
|
||||||
|
|
||||||
import { renderTextLayer } from "pdfjs-lib";
|
import { renderTextLayer } from "pdfjs-lib";
|
||||||
|
|
||||||
@ -217,36 +219,4 @@ class TextLayerBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export { TextLayerBuilder };
|
||||||
* @implements IPDFTextLayerFactory
|
|
||||||
*/
|
|
||||||
class DefaultTextLayerFactory {
|
|
||||||
/**
|
|
||||||
* @param {HTMLDivElement} textLayerDiv
|
|
||||||
* @param {number} pageIndex
|
|
||||||
* @param {PageViewport} viewport
|
|
||||||
* @param {boolean} enhanceTextSelection
|
|
||||||
* @param {EventBus} eventBus
|
|
||||||
* @param {TextHighlighter} highlighter
|
|
||||||
* @returns {TextLayerBuilder}
|
|
||||||
*/
|
|
||||||
createTextLayerBuilder(
|
|
||||||
textLayerDiv,
|
|
||||||
pageIndex,
|
|
||||||
viewport,
|
|
||||||
enhanceTextSelection = false,
|
|
||||||
eventBus,
|
|
||||||
highlighter
|
|
||||||
) {
|
|
||||||
return new TextLayerBuilder({
|
|
||||||
textLayerDiv,
|
|
||||||
pageIndex,
|
|
||||||
viewport,
|
|
||||||
enhanceTextSelection,
|
|
||||||
eventBus,
|
|
||||||
highlighter,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { DefaultTextLayerFactory, TextLayerBuilder };
|
|
||||||
|
@ -25,6 +25,13 @@ const VERTICAL_PADDING = 5;
|
|||||||
|
|
||||||
const LOADINGBAR_END_OFFSET_VAR = "--loadingBar-end-offset";
|
const LOADINGBAR_END_OFFSET_VAR = "--loadingBar-end-offset";
|
||||||
|
|
||||||
|
const RenderingStates = {
|
||||||
|
INITIAL: 0,
|
||||||
|
RUNNING: 1,
|
||||||
|
PAUSED: 2,
|
||||||
|
FINISHED: 3,
|
||||||
|
};
|
||||||
|
|
||||||
const PresentationModeState = {
|
const PresentationModeState = {
|
||||||
UNKNOWN: 0,
|
UNKNOWN: 0,
|
||||||
NORMAL: 1,
|
NORMAL: 1,
|
||||||
@ -832,6 +839,7 @@ export {
|
|||||||
PresentationModeState,
|
PresentationModeState,
|
||||||
ProgressBar,
|
ProgressBar,
|
||||||
RendererType,
|
RendererType,
|
||||||
|
RenderingStates,
|
||||||
roundToDivide,
|
roundToDivide,
|
||||||
SCROLLBAR_PADDING,
|
SCROLLBAR_PADDING,
|
||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
|
@ -13,15 +13,17 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @typedef {import("./interfaces").IPDFXfaLayerFactory} IPDFXfaLayerFactory */
|
/** @typedef {import("../src/display/api").PDFPageProxy} PDFPageProxy */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
|
||||||
|
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
|
||||||
|
|
||||||
import { SimpleLinkService } from "./pdf_link_service.js";
|
|
||||||
import { XfaLayer } from "pdfjs-lib";
|
import { XfaLayer } from "pdfjs-lib";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} XfaLayerBuilderOptions
|
* @typedef {Object} XfaLayerBuilderOptions
|
||||||
* @property {HTMLDivElement} pageDiv
|
* @property {HTMLDivElement} pageDiv
|
||||||
* @property {PDFPage} pdfPage
|
* @property {PDFPageProxy} pdfPage
|
||||||
* @property {AnnotationStorage} [annotationStorage]
|
* @property {AnnotationStorage} [annotationStorage]
|
||||||
* @property {IPDFLinkService} linkService
|
* @property {IPDFLinkService} linkService
|
||||||
* @property {Object} [xfaHtml]
|
* @property {Object} [xfaHtml]
|
||||||
@ -31,7 +33,13 @@ class XfaLayerBuilder {
|
|||||||
/**
|
/**
|
||||||
* @param {XfaLayerBuilderOptions} options
|
* @param {XfaLayerBuilderOptions} options
|
||||||
*/
|
*/
|
||||||
constructor({ pageDiv, pdfPage, annotationStorage, linkService, xfaHtml }) {
|
constructor({
|
||||||
|
pageDiv,
|
||||||
|
pdfPage,
|
||||||
|
annotationStorage = null,
|
||||||
|
linkService,
|
||||||
|
xfaHtml = null,
|
||||||
|
}) {
|
||||||
this.pageDiv = pageDiv;
|
this.pageDiv = pageDiv;
|
||||||
this.pdfPage = pdfPage;
|
this.pdfPage = pdfPage;
|
||||||
this.annotationStorage = annotationStorage;
|
this.annotationStorage = annotationStorage;
|
||||||
@ -54,8 +62,7 @@ class XfaLayerBuilder {
|
|||||||
const parameters = {
|
const parameters = {
|
||||||
viewport: viewport.clone({ dontFlip: true }),
|
viewport: viewport.clone({ dontFlip: true }),
|
||||||
div: this.div,
|
div: this.div,
|
||||||
xfa: this.xfaHtml,
|
xfaHtml: this.xfaHtml,
|
||||||
page: null,
|
|
||||||
annotationStorage: this.annotationStorage,
|
annotationStorage: this.annotationStorage,
|
||||||
linkService: this.linkService,
|
linkService: this.linkService,
|
||||||
intent,
|
intent,
|
||||||
@ -73,16 +80,15 @@ class XfaLayerBuilder {
|
|||||||
// intent === "display"
|
// intent === "display"
|
||||||
return this.pdfPage
|
return this.pdfPage
|
||||||
.getXfa()
|
.getXfa()
|
||||||
.then(xfa => {
|
.then(xfaHtml => {
|
||||||
if (this._cancelled || !xfa) {
|
if (this._cancelled || !xfaHtml) {
|
||||||
return { textDivs: [] };
|
return { textDivs: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
const parameters = {
|
const parameters = {
|
||||||
viewport: viewport.clone({ dontFlip: true }),
|
viewport: viewport.clone({ dontFlip: true }),
|
||||||
div: this.div,
|
div: this.div,
|
||||||
xfa,
|
xfaHtml,
|
||||||
page: this.pdfPage,
|
|
||||||
annotationStorage: this.annotationStorage,
|
annotationStorage: this.annotationStorage,
|
||||||
linkService: this.linkService,
|
linkService: this.linkService,
|
||||||
intent,
|
intent,
|
||||||
@ -114,30 +120,4 @@ class XfaLayerBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export { XfaLayerBuilder };
|
||||||
* @implements IPDFXfaLayerFactory
|
|
||||||
*/
|
|
||||||
class DefaultXfaLayerFactory {
|
|
||||||
/**
|
|
||||||
* @param {HTMLDivElement} pageDiv
|
|
||||||
* @param {PDFPage} pdfPage
|
|
||||||
* @param {AnnotationStorage} [annotationStorage]
|
|
||||||
* @param {Object} [xfaHtml]
|
|
||||||
*/
|
|
||||||
createXfaLayerBuilder(
|
|
||||||
pageDiv,
|
|
||||||
pdfPage,
|
|
||||||
annotationStorage = null,
|
|
||||||
xfaHtml = null
|
|
||||||
) {
|
|
||||||
return new XfaLayerBuilder({
|
|
||||||
pageDiv,
|
|
||||||
pdfPage,
|
|
||||||
annotationStorage,
|
|
||||||
linkService: new SimpleLinkService(),
|
|
||||||
xfaHtml,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { DefaultXfaLayerFactory, XfaLayerBuilder };
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user