mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 14:48:08 +02:00
This is very old code, and predates e.g. the introduction of JavaScript classes, which creates unnecessarily unwieldy code in the viewer. By introducing a new `TextLayer` class in the API, similar to how e.g. the `AnnotationLayer` looks, we're able to keep most parameters on the class-instance itself. This removes the need to manually track them in the viewer, and simplifies the call-sites. This also removes the `numTextDivs` parameter from the "textlayerrendered" event, since that's only added to support default-viewer functionality that no longer exists. Finally we try, as far as possible, to polyfill the old `renderTextLayer` and `updateTextLayer` functions since they are exposed in the library API. For *simple* invocations of `renderTextLayer` the behaviour should thus be the same, with only a warning printed in the console.
112 lines
2.3 KiB
JavaScript
112 lines
2.3 KiB
JavaScript
/* Copyright 2016 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.
|
|
*/
|
|
|
|
const {
|
|
AbortException,
|
|
AnnotationEditorLayer,
|
|
AnnotationEditorParamsType,
|
|
AnnotationEditorType,
|
|
AnnotationEditorUIManager,
|
|
AnnotationLayer,
|
|
AnnotationMode,
|
|
build,
|
|
CMapCompressionType,
|
|
ColorPicker,
|
|
createValidAbsoluteUrl,
|
|
DOMSVGFactory,
|
|
DrawLayer,
|
|
FeatureTest,
|
|
fetchData,
|
|
getDocument,
|
|
getFilenameFromUrl,
|
|
getPdfFilenameFromUrl,
|
|
getXfaPageViewport,
|
|
GlobalWorkerOptions,
|
|
ImageKind,
|
|
InvalidPDFException,
|
|
isDataScheme,
|
|
isPdfFile,
|
|
MissingPDFException,
|
|
noContextMenu,
|
|
normalizeUnicode,
|
|
OPS,
|
|
Outliner,
|
|
PasswordResponses,
|
|
PDFDataRangeTransport,
|
|
PDFDateString,
|
|
PDFWorker,
|
|
PermissionFlag,
|
|
PixelsPerInch,
|
|
RenderingCancelledException,
|
|
renderTextLayer,
|
|
setLayerDimensions,
|
|
shadow,
|
|
TextLayer,
|
|
UnexpectedResponseException,
|
|
updateTextLayer,
|
|
Util,
|
|
VerbosityLevel,
|
|
version,
|
|
XfaLayer,
|
|
} = globalThis.pdfjsLib;
|
|
|
|
export {
|
|
AbortException,
|
|
AnnotationEditorLayer,
|
|
AnnotationEditorParamsType,
|
|
AnnotationEditorType,
|
|
AnnotationEditorUIManager,
|
|
AnnotationLayer,
|
|
AnnotationMode,
|
|
build,
|
|
CMapCompressionType,
|
|
ColorPicker,
|
|
createValidAbsoluteUrl,
|
|
DOMSVGFactory,
|
|
DrawLayer,
|
|
FeatureTest,
|
|
fetchData,
|
|
getDocument,
|
|
getFilenameFromUrl,
|
|
getPdfFilenameFromUrl,
|
|
getXfaPageViewport,
|
|
GlobalWorkerOptions,
|
|
ImageKind,
|
|
InvalidPDFException,
|
|
isDataScheme,
|
|
isPdfFile,
|
|
MissingPDFException,
|
|
noContextMenu,
|
|
normalizeUnicode,
|
|
OPS,
|
|
Outliner,
|
|
PasswordResponses,
|
|
PDFDataRangeTransport,
|
|
PDFDateString,
|
|
PDFWorker,
|
|
PermissionFlag,
|
|
PixelsPerInch,
|
|
RenderingCancelledException,
|
|
renderTextLayer,
|
|
setLayerDimensions,
|
|
shadow,
|
|
TextLayer,
|
|
UnexpectedResponseException,
|
|
updateTextLayer,
|
|
Util,
|
|
VerbosityLevel,
|
|
version,
|
|
XfaLayer,
|
|
};
|