Move the Default{...}LayerFactory
into a new web/default_factory.js
file
This patch, first of all, removes circular dependencies in the TypeScript definitions. Secondly, it also moves `RenderingStates` into `web/ui_utils.js` to break another type-dependency and directly use the `XfaLayerBuilder` during XFA-printing. Finally, note that this patch *slightly* reduces the size of the default viewer (e.g. in the `MOZCENTRAL` build) by not having to bundle code which is completely unused.
This commit is contained in:
parent
e0dba504d2
commit
e19020c028
@ -18,13 +18,10 @@
|
||||
/** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
|
||||
/** @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 */
|
||||
|
||||
import { AnnotationLayer } from "pdfjs-lib";
|
||||
import { NullL10n } from "./l10n_utils.js";
|
||||
import { SimpleLinkService } from "./pdf_link_service.js";
|
||||
|
||||
/**
|
||||
* @typedef {Object} AnnotationLayerBuilderOptions
|
||||
@ -146,55 +143,4 @@ class AnnotationLayerBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { AnnotationLayerBuilder, DefaultAnnotationLayerFactory };
|
||||
export { AnnotationLayerBuilder };
|
||||
|
@ -29,6 +29,7 @@ import {
|
||||
parseQueryString,
|
||||
ProgressBar,
|
||||
RendererType,
|
||||
RenderingStates,
|
||||
ScrollMode,
|
||||
SidebarView,
|
||||
SpreadMode,
|
||||
@ -56,7 +57,6 @@ import {
|
||||
version,
|
||||
} from "pdfjs-lib";
|
||||
import { CursorTool, PDFCursorTools } from "./pdf_cursor_tools.js";
|
||||
import { PDFRenderingQueue, RenderingStates } from "./pdf_rendering_queue.js";
|
||||
import { OverlayManager } from "./overlay_manager.js";
|
||||
import { PasswordPrompt } from "./password_prompt.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 { PDFOutlineViewer } from "./pdf_outline_viewer.js";
|
||||
import { PDFPresentationMode } from "./pdf_presentation_mode.js";
|
||||
import { PDFRenderingQueue } from "./pdf_rendering_queue.js";
|
||||
import { PDFScriptingManager } from "./pdf_scripting_manager.js";
|
||||
import { PDFSidebar } from "./pdf_sidebar.js";
|
||||
import { PDFSidebarResizer } from "./pdf_sidebar_resizer.js";
|
||||
|
@ -17,6 +17,7 @@
|
||||
/** @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
|
||||
@ -27,7 +28,6 @@
|
||||
// eslint-disable-next-line max-len
|
||||
/** @typedef {import("./interfaces").IPDFTextLayerFactory} IPDFTextLayerFactory */
|
||||
/** @typedef {import("./interfaces").IPDFXfaLayerFactory} IPDFXfaLayerFactory */
|
||||
/** @typedef {import("./ui_utils").EventBus} EventBus */
|
||||
|
||||
import {
|
||||
AnnotationMode,
|
||||
@ -50,6 +50,7 @@ import {
|
||||
MIN_SCALE,
|
||||
PresentationModeState,
|
||||
RendererType,
|
||||
RenderingStates,
|
||||
SCROLLBAR_PADDING,
|
||||
scrollIntoView,
|
||||
ScrollMode,
|
||||
@ -59,10 +60,10 @@ import {
|
||||
VERTICAL_PADDING,
|
||||
watchScroll,
|
||||
} from "./ui_utils.js";
|
||||
import { PDFRenderingQueue, RenderingStates } from "./pdf_rendering_queue.js";
|
||||
import { AnnotationLayerBuilder } from "./annotation_layer_builder.js";
|
||||
import { NullL10n } from "./l10n_utils.js";
|
||||
import { PDFPageView } from "./pdf_page_view.js";
|
||||
import { PDFRenderingQueue } from "./pdf_rendering_queue.js";
|
||||
import { SimpleLinkService } from "./pdf_link_service.js";
|
||||
import { StructTreeLayerBuilder } from "./struct_tree_layer_builder.js";
|
||||
import { TextHighlighter } from "./text_highlighter.js";
|
||||
|
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,
|
||||
};
|
@ -19,14 +19,13 @@
|
||||
/** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
|
||||
// eslint-disable-next-line max-len
|
||||
/** @typedef {import("./annotation_layer_builder").AnnotationLayerBuilder} AnnotationLayerBuilder */
|
||||
// eslint-disable-next-line max-len
|
||||
/** @typedef {import("./pdf_rendering_queue").RenderingStates} RenderingStates */
|
||||
/** @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").EventBus} EventBus */
|
||||
/** @typedef {import("./ui_utils").RenderingStates} RenderingStates */
|
||||
/** @typedef {import("./xfa_layer_builder").XfaLayerBuilder} XfaLayerBuilder */
|
||||
|
||||
/**
|
||||
|
@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
/** @typedef {import("../src/display/api").PDFDocumentProxy} PDFDocumentProxy */
|
||||
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
|
||||
/** @typedef {import("./ui_utils").EventBus} EventBus */
|
||||
|
||||
import { createPromiseCapability } from "pdfjs-lib";
|
||||
import { getCharacterType } from "./pdf_find_utils.js";
|
||||
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
|
||||
/** @typedef {import("./ui_utils").EventBus} EventBus */
|
||||
|
||||
import {
|
||||
isValidRotation,
|
||||
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
|
||||
/** @typedef {import("./ui_utils").EventBus} EventBus */
|
||||
|
||||
import { addLinkAttributes, LinkTarget } from "pdfjs-lib";
|
||||
import { parseQueryString } from "./ui_utils.js";
|
||||
|
@ -17,6 +17,7 @@
|
||||
/** @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 */
|
||||
@ -28,7 +29,6 @@
|
||||
/** @typedef {import("./interfaces").IRenderableView} IRenderableView */
|
||||
// eslint-disable-next-line max-len
|
||||
/** @typedef {import("./pdf_rendering_queue").PDFRenderingQueue} PDFRenderingQueue */
|
||||
/** @typedef {import("./ui_utils").EventBus} EventBus */
|
||||
|
||||
import {
|
||||
AnnotationMode,
|
||||
@ -42,12 +42,12 @@ import {
|
||||
DEFAULT_SCALE,
|
||||
getOutputScale,
|
||||
RendererType,
|
||||
RenderingStates,
|
||||
roundToDivide,
|
||||
TextLayerMode,
|
||||
} from "./ui_utils.js";
|
||||
import { compatibilityParams } from "./app_options.js";
|
||||
import { NullL10n } from "./l10n_utils.js";
|
||||
import { RenderingStates } from "./pdf_rendering_queue.js";
|
||||
|
||||
/**
|
||||
* @typedef {Object} PDFPageViewOptions
|
||||
|
@ -19,16 +19,10 @@
|
||||
/** @typedef {import("./pdf_thumbnail_viewer").PDFThumbnailViewer} PDFThumbnailViewer */
|
||||
|
||||
import { RenderingCancelledException } from "pdfjs-lib";
|
||||
import { RenderingStates } from "./ui_utils.js";
|
||||
|
||||
const CLEANUP_TIMEOUT = 30000;
|
||||
|
||||
const RenderingStates = {
|
||||
INITIAL: 0,
|
||||
RUNNING: 1,
|
||||
PAUSED: 2,
|
||||
FINISHED: 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* Controls rendering of the views for pages and thumbnails.
|
||||
*/
|
||||
@ -216,4 +210,4 @@ class PDFRenderingQueue {
|
||||
}
|
||||
}
|
||||
|
||||
export { PDFRenderingQueue, RenderingStates };
|
||||
export { PDFRenderingQueue };
|
||||
|
@ -13,11 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** @typedef {import("./ui_utils").EventBus} EventBus */
|
||||
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||
|
||||
import { apiPageLayoutToViewerModes, RenderingStates } from "./ui_utils.js";
|
||||
import { createPromiseCapability, shadow } from "pdfjs-lib";
|
||||
import { apiPageLayoutToViewerModes } from "./ui_utils.js";
|
||||
import { RenderingStates } from "./pdf_rendering_queue.js";
|
||||
|
||||
/**
|
||||
* @typedef {Object} PDFScriptingManagerOptions
|
||||
|
@ -13,8 +13,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { PresentationModeState, SidebarView } from "./ui_utils.js";
|
||||
import { RenderingStates } from "./pdf_rendering_queue.js";
|
||||
import {
|
||||
PresentationModeState,
|
||||
RenderingStates,
|
||||
SidebarView,
|
||||
} from "./ui_utils.js";
|
||||
|
||||
const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
|
||||
|
||||
|
@ -19,9 +19,8 @@
|
||||
// eslint-disable-next-line max-len
|
||||
/** @typedef {import("./pdf_rendering_queue").PDFRenderingQueue} PDFRenderingQueue */
|
||||
|
||||
import { getOutputScale } from "./ui_utils.js";
|
||||
import { getOutputScale, RenderingStates } from "./ui_utils.js";
|
||||
import { RenderingCancelledException } from "pdfjs-lib";
|
||||
import { RenderingStates } from "./pdf_rendering_queue.js";
|
||||
|
||||
const DRAW_UPSCALE_FACTOR = 2; // See comment in `PDFThumbnailView.draw` below.
|
||||
const MAX_NUM_SCALING_STEPS = 3;
|
||||
|
@ -14,20 +14,20 @@
|
||||
*/
|
||||
|
||||
/** @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 */
|
||||
/** @typedef {import("./ui_utils").EventBus} EventBus */
|
||||
|
||||
import {
|
||||
getVisibleElements,
|
||||
isValidRotation,
|
||||
RenderingStates,
|
||||
scrollIntoView,
|
||||
watchScroll,
|
||||
} from "./ui_utils.js";
|
||||
import { PDFThumbnailView, TempImageFactory } from "./pdf_thumbnail_view.js";
|
||||
import { RenderingStates } from "./pdf_rendering_queue.js";
|
||||
|
||||
const THUMBNAIL_SCROLL_MARGIN = -19;
|
||||
const THUMBNAIL_SELECTED_CLASS = "selected";
|
||||
|
@ -14,23 +14,14 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
AnnotationLayerBuilder,
|
||||
DefaultAnnotationLayerFactory,
|
||||
} from "./annotation_layer_builder.js";
|
||||
import {
|
||||
DefaultStructTreeLayerFactory,
|
||||
StructTreeLayerBuilder,
|
||||
} from "./struct_tree_layer_builder.js";
|
||||
import {
|
||||
DefaultTextLayerFactory,
|
||||
TextLayerBuilder,
|
||||
} from "./text_layer_builder.js";
|
||||
import {
|
||||
DefaultXfaLayerFactory,
|
||||
XfaLayerBuilder,
|
||||
} from "./xfa_layer_builder.js";
|
||||
} from "./default_factory.js";
|
||||
import { PDFLinkService, SimpleLinkService } from "./pdf_link_service.js";
|
||||
import { PDFSinglePageViewer, PDFViewer } from "./pdf_viewer.js";
|
||||
import { AnnotationLayerBuilder } from "./annotation_layer_builder.js";
|
||||
import { DownloadManager } from "./download_manager.js";
|
||||
import { EventBus } from "./event_utils.js";
|
||||
import { GenericL10n } from "./genericl10n.js";
|
||||
@ -40,6 +31,9 @@ import { PDFHistory } from "./pdf_history.js";
|
||||
import { PDFPageView } from "./pdf_page_view.js";
|
||||
import { PDFScriptingManager } from "./pdf_scripting_manager.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
|
||||
const pdfjsVersion = PDFJSDev.eval("BUNDLE_VERSION");
|
||||
|
@ -14,11 +14,12 @@
|
||||
*/
|
||||
|
||||
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) {
|
||||
const xfaHtml = pdfDocument.allXfaHtml;
|
||||
const factory = new DefaultXfaLayerFactory();
|
||||
const linkService = new SimpleLinkService();
|
||||
const scale = Math.round(PixelsPerInch.PDF_TO_CSS_UNITS * 100) / 100;
|
||||
|
||||
for (const xfaPage of xfaHtml.children) {
|
||||
@ -26,12 +27,13 @@ function getXfaHtmlForPrinting(printContainer, pdfDocument) {
|
||||
page.className = "xfaPrintedPage";
|
||||
printContainer.appendChild(page);
|
||||
|
||||
const builder = factory.createXfaLayerBuilder(
|
||||
/* pageDiv = */ page,
|
||||
/* pdfPage = */ null,
|
||||
/* annotationStorage = */ pdfDocument.annotationStorage,
|
||||
/* xfaHtml = */ xfaPage
|
||||
);
|
||||
const builder = new XfaLayerBuilder({
|
||||
pageDiv: page,
|
||||
pdfPage: null,
|
||||
annotationStorage: pdfDocument.annotationStorage,
|
||||
linkService,
|
||||
xfaHtml: xfaPage,
|
||||
});
|
||||
const viewport = getXfaPageViewport(xfaPage, { scale });
|
||||
|
||||
builder.render(viewport, "print");
|
||||
|
@ -14,8 +14,6 @@
|
||||
*/
|
||||
|
||||
/** @typedef {import("../src/display/api").PDFPageProxy} PDFPageProxy */
|
||||
// eslint-disable-next-line max-len
|
||||
/** @typedef {import("./interfaces").IPDFStructTreeLayerFactory} IPDFStructTreeLayerFactory */
|
||||
|
||||
const PDF_ROLE_TO_HTML_ROLE = {
|
||||
// Document level structure types
|
||||
@ -138,19 +136,4 @@ class StructTreeLayerBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @implements IPDFStructTreeLayerFactory
|
||||
*/
|
||||
class DefaultStructTreeLayerFactory {
|
||||
/**
|
||||
* @param {PDFPageProxy} pdfPage
|
||||
* @returns {StructTreeLayerBuilder}
|
||||
*/
|
||||
createStructTreeLayerBuilder(pdfPage) {
|
||||
return new StructTreeLayerBuilder({
|
||||
pdfPage,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { DefaultStructTreeLayerFactory, StructTreeLayerBuilder };
|
||||
export { StructTreeLayerBuilder };
|
||||
|
@ -13,9 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||
// eslint-disable-next-line max-len
|
||||
/** @typedef {import("./pdf_find_controller").PDFFindController} PDFFindController */
|
||||
/** @typedef {import("./ui_utils").EventBus} EventBus */
|
||||
|
||||
/**
|
||||
* @typedef {Object} TextHighlighterOptions
|
||||
|
@ -15,10 +15,8 @@
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
/** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
|
||||
// eslint-disable-next-line max-len
|
||||
/** @typedef {import("./interfaces").IPDFTextLayerFactory} IPDFTextLayerFactory */
|
||||
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||
/** @typedef {import("./text_highlighter").TextHighlighter} TextHighlighter */
|
||||
/** @typedef {import("./ui_utils").EventBus} EventBus */
|
||||
|
||||
import { renderTextLayer } from "pdfjs-lib";
|
||||
|
||||
@ -221,36 +219,4 @@ class 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 };
|
||||
export { TextLayerBuilder };
|
||||
|
@ -25,6 +25,13 @@ const VERTICAL_PADDING = 5;
|
||||
|
||||
const LOADINGBAR_END_OFFSET_VAR = "--loadingBar-end-offset";
|
||||
|
||||
const RenderingStates = {
|
||||
INITIAL: 0,
|
||||
RUNNING: 1,
|
||||
PAUSED: 2,
|
||||
FINISHED: 3,
|
||||
};
|
||||
|
||||
const PresentationModeState = {
|
||||
UNKNOWN: 0,
|
||||
NORMAL: 1,
|
||||
@ -832,6 +839,7 @@ export {
|
||||
PresentationModeState,
|
||||
ProgressBar,
|
||||
RendererType,
|
||||
RenderingStates,
|
||||
roundToDivide,
|
||||
SCROLLBAR_PADDING,
|
||||
scrollIntoView,
|
||||
|
@ -17,9 +17,7 @@
|
||||
// eslint-disable-next-line max-len
|
||||
/** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
|
||||
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
|
||||
/** @typedef {import("./interfaces").IPDFXfaLayerFactory} IPDFXfaLayerFactory */
|
||||
|
||||
import { SimpleLinkService } from "./pdf_link_service.js";
|
||||
import { XfaLayer } from "pdfjs-lib";
|
||||
|
||||
/**
|
||||
@ -122,30 +120,4 @@ class XfaLayerBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 { DefaultXfaLayerFactory, XfaLayerBuilder };
|
||||
export { XfaLayerBuilder };
|
||||
|
Loading…
Reference in New Issue
Block a user