@pdfslick/core 2.3.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/esm/PDFSlick.d.ts +8 -2
- package/dist/esm/PDFSlick.d.ts.map +1 -1
- package/dist/esm/index.js +132 -94
- package/dist/esm/lib/pdf_rendering_queue.d.ts +6 -3
- package/dist/esm/lib/pdf_rendering_queue.d.ts.map +1 -1
- package/dist/esm/lib/pdf_thumbnail_view.d.ts +12 -2
- package/dist/esm/lib/pdf_thumbnail_view.d.ts.map +1 -1
- package/dist/esm/lib/pdf_thumbnail_viewer.d.ts +14 -1
- package/dist/esm/lib/pdf_thumbnail_viewer.d.ts.map +1 -1
- package/dist/esm/lib/ui_utils.d.ts +19 -13
- package/dist/esm/lib/ui_utils.d.ts.map +1 -1
- package/dist/esm/types.d.ts +6 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/pdf_viewer.css +2725 -363
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/umd/index.js +25 -2
- package/package.json +13 -11
package/README.md
CHANGED
|
@@ -189,6 +189,10 @@ Provided with the PDF Document path and options object, the `usePDFSlick()` hook
|
|
|
189
189
|
|
|
190
190
|
[Learn more about PDFSlick](https://pdfslick.dev) | [Checkout the Examples](https://pdfslick.dev/examples)
|
|
191
191
|
|
|
192
|
+
## Author
|
|
193
|
+
|
|
194
|
+
PDFSlick was conceived and developed, and is currently maintained by [Vancho Stojkov](https://github.com/van100j), who embarked on this project with the vision of simplifying PDF integration for modern web frameworks, leveraging the power of PDF.js while providing a developer-friendly API.
|
|
195
|
+
|
|
192
196
|
## Thanks
|
|
193
197
|
|
|
194
198
|
- [Vane Kosturanov](https://kosturanov.com/portfolio/logo-branding-design) for designing the logo
|
package/dist/esm/PDFSlick.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type OnProgressParameters, PDFDocumentProxy, AbortException,
|
|
1
|
+
import { type OnProgressParameters, PDFDocumentProxy, AbortException, ResponseException, InvalidPDFException, RenderingCancelledException } from "pdfjs-dist";
|
|
2
2
|
import type { DocumentInitParameters } from "pdfjs-dist/types/src/display/api";
|
|
3
3
|
import { EventBus, PDFViewer, PDFLinkService, DownloadManager, PDFFindController, PDFPageView } from "pdfjs-dist/web/pdf_viewer.mjs";
|
|
4
4
|
import { IL10n } from "pdfjs-dist/types/web/pdf_viewer";
|
|
5
5
|
import type { PDFSlickInputArgs, PDFSlickState, TEventBusName, TEventBusOptions, TEventBusListener } from "./types";
|
|
6
6
|
import { PDFThumbnailViewer, PDFPresentationMode } from "./lib";
|
|
7
7
|
import { StoreApi } from "zustand/vanilla";
|
|
8
|
-
export type PDFException = AbortException |
|
|
8
|
+
export type PDFException = AbortException | ResponseException | InvalidPDFException | RenderingCancelledException;
|
|
9
9
|
export declare class PDFSlick {
|
|
10
10
|
#private;
|
|
11
11
|
url: string | ArrayBuffer | undefined;
|
|
@@ -31,8 +31,14 @@ export declare class PDFSlick {
|
|
|
31
31
|
annotationEditorHighlightColors: string | undefined;
|
|
32
32
|
textLayerMode: number;
|
|
33
33
|
maxCanvasPixels: number;
|
|
34
|
+
maxCanvasDim: number;
|
|
35
|
+
capCanvasAreaFactor: number;
|
|
34
36
|
printResolution: number;
|
|
35
37
|
thumbnailWidth: number;
|
|
38
|
+
enableHWA: boolean;
|
|
39
|
+
enableDetailCanvas: boolean;
|
|
40
|
+
enableOptimizedPartialRendering: boolean;
|
|
41
|
+
minDurationToUpdateCanvas: number;
|
|
36
42
|
getDocumentParams: DocumentInitParameters;
|
|
37
43
|
constructor({ container, viewer, thumbs, store, options, onError, printDialog, }: PDFSlickInputArgs);
|
|
38
44
|
loadDocument(url: string | URL | ArrayBuffer, options?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PDFSlick.d.ts","sourceRoot":"","sources":["../PDFSlick.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,oBAAo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Y;IA6DZ,QAAQ;IAcR,uBAAuB,CAAC,oBAAoB,EAAE,MAAM;IASpD,yBAAyB,CACrB,sBAAsB,EAChB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,GAAG,CAAA;KAAE,GAC5B;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,GAAG,CAAA;KAAE,EAAE;IAexC,wBAAwB,CAAC,KAAK,EAAE,MAAM;IAetC,aAAa,CAAC,MAAM,EAAE,MAAM;IAO5B,aAAa,CAAC,MAAM,EAAE,MAAM;IAO5B,WAAW,CAAC,QAAQ,EAAE,MAAM;IAM5B,gBAAgB;eAIO,MAAM;gBACL,MAAM;kBACJ,MAAM;;IAQhC;;OAEG;IACH,aAAa;IAIb;;OAEG;IACH,aAAa;IAIb;;OAEG;IACH,IAAI,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAEhC;IAED;;OAEG;IACH,IAAI,YAAY,CAAC,GAAG,EAAE,MAAM,EAE3B;IAED,WAAW,CAAC,EAAE,EAAE,MAAM,GACoB,WAAW;IAGrD;;;;;OAKG;IACH,EAAE,CACE,SAAS,EAAE,aAAa,EACxB,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,CAAC,EAAE,gBAAgB;IAK9B;;;;;OAKG;IACH,GAAG,CACC,SAAS,EAAE,aAAa,EACxB,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,CAAC,EAAE,gBAAgB;IAK9B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM;CAGlD"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RenderingCancelledException, PixelsPerInch, getXfaPageViewport, AnnotationMode, AnnotationEditorType, GlobalWorkerOptions, AnnotationEditorParamsType, getPdfFilenameFromUrl, getDocument, PDFDateString } from 'pdfjs-dist';
|
|
1
|
+
import { MathClamp, RenderingCancelledException, OutputScale, PixelsPerInch, getXfaPageViewport, AnnotationMode, AnnotationEditorType, GlobalWorkerOptions, AnnotationEditorParamsType, getPdfFilenameFromUrl, getDocument, PDFDateString } from 'pdfjs-dist';
|
|
2
2
|
import { SimpleLinkService, XfaLayerBuilder, GenericL10n, DownloadManager, EventBus, PDFLinkService, PDFFindController, PDFSinglePageViewer, PDFViewer } from 'pdfjs-dist/web/pdf_viewer.mjs';
|
|
3
3
|
import { createStore } from 'zustand/vanilla';
|
|
4
4
|
|
|
@@ -120,28 +120,6 @@ const CursorTool = {
|
|
|
120
120
|
};
|
|
121
121
|
// Used by `PDFViewerApplication`, and by the API unit-tests.
|
|
122
122
|
const AutoPrintRegExp = /\bprint\s*\(/;
|
|
123
|
-
/**
|
|
124
|
-
* Scale factors for the canvas, necessary with HiDPI displays.
|
|
125
|
-
*/
|
|
126
|
-
class OutputScale {
|
|
127
|
-
constructor() {
|
|
128
|
-
const pixelRatio = window.devicePixelRatio || 1;
|
|
129
|
-
/**
|
|
130
|
-
* @type {number} Horizontal scale.
|
|
131
|
-
*/
|
|
132
|
-
this.sx = pixelRatio;
|
|
133
|
-
/**
|
|
134
|
-
* @type {number} Vertical scale.
|
|
135
|
-
*/
|
|
136
|
-
this.sy = pixelRatio;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* @type {boolean} Returns `true` when scaling is required, `false` otherwise.
|
|
140
|
-
*/
|
|
141
|
-
get scaled() {
|
|
142
|
-
return this.sx !== 1 || this.sy !== 1;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
123
|
/**
|
|
146
124
|
* Scrolls specified element into view of its parent.
|
|
147
125
|
* @param {HTMLElement} element - The element to be visible.
|
|
@@ -181,7 +159,14 @@ function scrollIntoView(element, spot, scrollMatches = false) {
|
|
|
181
159
|
offsetY += spot.top;
|
|
182
160
|
}
|
|
183
161
|
if (spot.left !== undefined) {
|
|
184
|
-
|
|
162
|
+
if (scrollMatches) {
|
|
163
|
+
const elementWidth = element.getBoundingClientRect().width;
|
|
164
|
+
const padding = MathClamp((parent.clientWidth - elementWidth) / 2, 20, 400);
|
|
165
|
+
offsetX += spot.left - padding;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
offsetX += spot.left;
|
|
169
|
+
}
|
|
185
170
|
parent.scrollLeft = offsetX;
|
|
186
171
|
}
|
|
187
172
|
}
|
|
@@ -545,14 +530,28 @@ function getVisibleElements({ scrollEl, views, sortByVisibility = false, horizon
|
|
|
545
530
|
currentWidth >= right) {
|
|
546
531
|
continue;
|
|
547
532
|
}
|
|
548
|
-
const
|
|
549
|
-
const
|
|
533
|
+
const minY = Math.max(0, top - currentHeight);
|
|
534
|
+
const minX = Math.max(0, left - currentWidth);
|
|
535
|
+
const hiddenHeight = minY + Math.max(0, viewBottom - bottom);
|
|
536
|
+
const hiddenWidth = minX + Math.max(0, viewRight - right);
|
|
550
537
|
const fractionHeight = (viewHeight - hiddenHeight) / viewHeight, fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
|
|
551
538
|
const percent = (fractionHeight * fractionWidth * 100) | 0;
|
|
552
539
|
visible.push({
|
|
553
540
|
id: view.id,
|
|
554
541
|
x: currentWidth,
|
|
555
542
|
y: currentHeight,
|
|
543
|
+
visibleArea:
|
|
544
|
+
// We only specify which part of the page is visible when it's not
|
|
545
|
+
// the full page, as there is no point in handling a partial page
|
|
546
|
+
// rendering otherwise.
|
|
547
|
+
percent === 100
|
|
548
|
+
? null
|
|
549
|
+
: {
|
|
550
|
+
minX,
|
|
551
|
+
minY,
|
|
552
|
+
maxX: Math.min(viewRight, right) - currentWidth,
|
|
553
|
+
maxY: Math.min(viewBottom, bottom) - currentHeight,
|
|
554
|
+
},
|
|
556
555
|
view,
|
|
557
556
|
percent,
|
|
558
557
|
widthPercent: (fractionWidth * 100) | 0,
|
|
@@ -617,9 +616,6 @@ const animationStarted = new Promise(function (resolve) {
|
|
|
617
616
|
window.requestAnimationFrame(resolve);
|
|
618
617
|
});
|
|
619
618
|
const docStyle = document.documentElement.style;
|
|
620
|
-
function clamp(v, min, max) {
|
|
621
|
-
return Math.min(Math.max(v, min), max);
|
|
622
|
-
}
|
|
623
619
|
class ProgressBar {
|
|
624
620
|
constructor(bar) {
|
|
625
621
|
_ProgressBar_classList.set(this, void 0);
|
|
@@ -634,7 +630,7 @@ class ProgressBar {
|
|
|
634
630
|
return __classPrivateFieldGet(this, _ProgressBar_percent, "f");
|
|
635
631
|
}
|
|
636
632
|
set percent(val) {
|
|
637
|
-
__classPrivateFieldSet(this, _ProgressBar_percent,
|
|
633
|
+
__classPrivateFieldSet(this, _ProgressBar_percent, MathClamp(val, 0, 100), "f");
|
|
638
634
|
if (isNaN(val)) {
|
|
639
635
|
__classPrivateFieldGet(this, _ProgressBar_classList, "f").add("indeterminate");
|
|
640
636
|
return;
|
|
@@ -785,7 +781,6 @@ const calcRound = (function () {
|
|
|
785
781
|
*/
|
|
786
782
|
/** @typedef {import("./interfaces").IRenderableView} IRenderableView */
|
|
787
783
|
/** @typedef {import("./pdf_viewer").PDFViewer} PDFViewer */
|
|
788
|
-
// eslint-disable-next-line max-len
|
|
789
784
|
/** @typedef {import("./pdf_thumbnail_viewer").PDFThumbnailViewer} PDFThumbnailViewer */
|
|
790
785
|
const CLEANUP_TIMEOUT = 30000;
|
|
791
786
|
/**
|
|
@@ -858,14 +853,15 @@ class PDFRenderingQueue {
|
|
|
858
853
|
* @param {boolean} scrolledDown
|
|
859
854
|
* @param {boolean} [preRenderExtra]
|
|
860
855
|
*/
|
|
861
|
-
getHighestPriority(visible, views, scrolledDown, preRenderExtra = false) {
|
|
856
|
+
getHighestPriority(visible, views, scrolledDown, preRenderExtra = false, ignoreDetailViews = false) {
|
|
862
857
|
/**
|
|
863
858
|
* The state has changed. Figure out which page has the highest priority to
|
|
864
859
|
* render next (if any).
|
|
865
860
|
*
|
|
866
861
|
* Priority:
|
|
867
862
|
* 1. visible pages
|
|
868
|
-
* 2.
|
|
863
|
+
* 2. zoomed-in partial views of visible pages, unless `ignoreDetailViews`
|
|
864
|
+
* 3. if last scrolled down, the page after the visible pages, or
|
|
869
865
|
* if last scrolled up, the page before the visible pages
|
|
870
866
|
*/
|
|
871
867
|
const visibleViews = visible.views, numVisible = visibleViews.length;
|
|
@@ -878,6 +874,14 @@ class PDFRenderingQueue {
|
|
|
878
874
|
return view;
|
|
879
875
|
}
|
|
880
876
|
}
|
|
877
|
+
if (!ignoreDetailViews) {
|
|
878
|
+
for (let i = 0; i < numVisible; i++) {
|
|
879
|
+
const { detailView } = visibleViews[i].view;
|
|
880
|
+
if (detailView && !this.isViewFinished(detailView)) {
|
|
881
|
+
return detailView;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
}
|
|
881
885
|
const firstId = visible.first.id, lastId = visible.last.id;
|
|
882
886
|
// All the visible views have rendered; try to handle any "holes" in the
|
|
883
887
|
// page layout (can happen e.g. with spreadModes at higher zoom levels).
|
|
@@ -969,9 +973,15 @@ class PDFRenderingQueue {
|
|
|
969
973
|
* See the License for the specific language governing permissions and
|
|
970
974
|
* limitations under the License.
|
|
971
975
|
*/
|
|
972
|
-
var _a, _TempImageFactory_tempCanvas, _PDFThumbnailView_instances, _PDFThumbnailView_updateDims, _PDFThumbnailView_getPageDrawContext, _PDFThumbnailView_convertCanvasToImage,
|
|
976
|
+
var _a, _TempImageFactory_tempCanvas, _PDFThumbnailView_instances, _PDFThumbnailView_updateDims, _PDFThumbnailView_getPageDrawContext, _PDFThumbnailView_convertCanvasToImage, _PDFThumbnailView_getReducedImageDims, _PDFThumbnailView_reduceImage;
|
|
973
977
|
const DRAW_UPSCALE_FACTOR = 2; // See comment in `PDFThumbnailView.draw` below.
|
|
974
978
|
const MAX_NUM_SCALING_STEPS = 3;
|
|
979
|
+
function zeroCanvas(c) {
|
|
980
|
+
// Zeroing the width and height causes Firefox to release graphics
|
|
981
|
+
// resources immediately, which can greatly reduce memory consumption.
|
|
982
|
+
c.width = 0;
|
|
983
|
+
c.height = 0;
|
|
984
|
+
}
|
|
975
985
|
/**
|
|
976
986
|
* @typedef {Object} PDFThumbnailViewOptions
|
|
977
987
|
* @property {HTMLDivElement} container - The viewer element.
|
|
@@ -983,6 +993,12 @@ const MAX_NUM_SCALING_STEPS = 3;
|
|
|
983
993
|
* The default value is `null`.
|
|
984
994
|
* @property {IPDFLinkService} linkService - The navigation/linking service.
|
|
985
995
|
* @property {PDFRenderingQueue} renderingQueue - The rendering queue object.
|
|
996
|
+
* @property {number} [maxCanvasPixels] - The maximum supported canvas size in
|
|
997
|
+
* total pixels, i.e. width * height. Use `-1` for no limit, or `0` for
|
|
998
|
+
* CSS-only zooming. The default value is 4096 * 8192 (32 mega-pixels).
|
|
999
|
+
* @property {number} [maxCanvasDim] - The maximum supported canvas dimension,
|
|
1000
|
+
* in either width or height. Use `-1` for no limit.
|
|
1001
|
+
* The default value is 32767.
|
|
986
1002
|
* @property {Object} [pageColors] - Overwrites background and foreground colors
|
|
987
1003
|
* with user defined ones in order to improve readability in high contrast
|
|
988
1004
|
* mode.
|
|
@@ -1004,12 +1020,8 @@ class TempImageFactory {
|
|
|
1004
1020
|
return [tempCanvas, tempCanvas.getContext("2d")];
|
|
1005
1021
|
}
|
|
1006
1022
|
static destroyCanvas() {
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
// Zeroing the width and height causes Firefox to release graphics
|
|
1010
|
-
// resources immediately, which can greatly reduce memory consumption.
|
|
1011
|
-
tempCanvas.width = 0;
|
|
1012
|
-
tempCanvas.height = 0;
|
|
1023
|
+
if (__classPrivateFieldGet(this, _a, "f", _TempImageFactory_tempCanvas)) {
|
|
1024
|
+
zeroCanvas(__classPrivateFieldGet(this, _a, "f", _TempImageFactory_tempCanvas));
|
|
1013
1025
|
}
|
|
1014
1026
|
__classPrivateFieldSet(this, _a, null, "f", _TempImageFactory_tempCanvas);
|
|
1015
1027
|
}
|
|
@@ -1023,7 +1035,7 @@ class PDFThumbnailView {
|
|
|
1023
1035
|
/**
|
|
1024
1036
|
* @param {PDFThumbnailViewOptions} options
|
|
1025
1037
|
*/
|
|
1026
|
-
constructor({ container, eventBus, id, defaultViewport, optionalContentConfigPromise, linkService, renderingQueue, pageColors, enableHWA, store, thumbnailWidth, }) {
|
|
1038
|
+
constructor({ container, eventBus, id, defaultViewport, optionalContentConfigPromise, linkService, renderingQueue, maxCanvasPixels, maxCanvasDim, pageColors, enableHWA, store, thumbnailWidth, }) {
|
|
1027
1039
|
_PDFThumbnailView_instances.add(this);
|
|
1028
1040
|
this.id = id;
|
|
1029
1041
|
this.renderingId = "thumbnail" + id;
|
|
@@ -1033,6 +1045,8 @@ class PDFThumbnailView {
|
|
|
1033
1045
|
this.viewport = defaultViewport;
|
|
1034
1046
|
this.pdfPageRotate = defaultViewport.rotation;
|
|
1035
1047
|
this._optionalContentConfigPromise = optionalContentConfigPromise || null;
|
|
1048
|
+
this.maxCanvasPixels = maxCanvasPixels !== null && maxCanvasPixels !== void 0 ? maxCanvasPixels : 4096 * 8192;
|
|
1049
|
+
this.maxCanvasDim = maxCanvasDim || 32767;
|
|
1036
1050
|
this.pageColors = pageColors || null;
|
|
1037
1051
|
this.enableHWA = enableHWA || false;
|
|
1038
1052
|
this.eventBus = eventBus;
|
|
@@ -1125,7 +1139,7 @@ class PDFThumbnailView {
|
|
|
1125
1139
|
console.error("Must be in new state before drawing");
|
|
1126
1140
|
return undefined;
|
|
1127
1141
|
}
|
|
1128
|
-
const { pdfPage } = this;
|
|
1142
|
+
const { pageColors, pdfPage } = this;
|
|
1129
1143
|
if (!pdfPage) {
|
|
1130
1144
|
this.renderingState = RenderingStates.FINISHED;
|
|
1131
1145
|
throw new Error("pdfPage is not loaded");
|
|
@@ -1152,27 +1166,45 @@ class PDFThumbnailView {
|
|
|
1152
1166
|
cont();
|
|
1153
1167
|
};
|
|
1154
1168
|
const renderContext = {
|
|
1169
|
+
canvas: canvas,
|
|
1155
1170
|
canvasContext: ctx,
|
|
1156
1171
|
transform,
|
|
1157
1172
|
viewport: drawViewport,
|
|
1158
1173
|
optionalContentConfigPromise: this._optionalContentConfigPromise,
|
|
1159
|
-
pageColors
|
|
1174
|
+
pageColors,
|
|
1160
1175
|
};
|
|
1161
1176
|
const renderTask = (this.renderTask = pdfPage.render(renderContext));
|
|
1162
1177
|
renderTask.onContinue = renderContinueCallback;
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1178
|
+
let error = null;
|
|
1179
|
+
try {
|
|
1180
|
+
yield renderTask.promise;
|
|
1181
|
+
}
|
|
1182
|
+
catch (e) {
|
|
1183
|
+
if (e instanceof RenderingCancelledException) {
|
|
1184
|
+
zeroCanvas(canvas);
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
error = e;
|
|
1188
|
+
}
|
|
1189
|
+
finally {
|
|
1190
|
+
// The renderTask may have been replaced by a new one, so only remove
|
|
1191
|
+
// the reference to the renderTask if it matches the one that is
|
|
1192
|
+
// triggering this callback.
|
|
1193
|
+
if (renderTask === this.renderTask) {
|
|
1194
|
+
this.renderTask = null;
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
this.renderingState = RenderingStates.FINISHED;
|
|
1198
|
+
__classPrivateFieldGet(this, _PDFThumbnailView_instances, "m", _PDFThumbnailView_convertCanvasToImage).call(this, canvas);
|
|
1199
|
+
zeroCanvas(canvas);
|
|
1200
|
+
this.eventBus.dispatch("thumbnailrendered", {
|
|
1201
|
+
source: this,
|
|
1202
|
+
pageNumber: this.id,
|
|
1203
|
+
pdfPage,
|
|
1174
1204
|
});
|
|
1175
|
-
|
|
1205
|
+
if (error) {
|
|
1206
|
+
throw error;
|
|
1207
|
+
}
|
|
1176
1208
|
});
|
|
1177
1209
|
}
|
|
1178
1210
|
setImage(pageView) {
|
|
@@ -1225,8 +1257,10 @@ _PDFThumbnailView_instances = new WeakSet(), _PDFThumbnailView_updateDims = func
|
|
|
1225
1257
|
willReadFrequently: !enableHWA,
|
|
1226
1258
|
});
|
|
1227
1259
|
const outputScale = new OutputScale();
|
|
1228
|
-
|
|
1229
|
-
|
|
1260
|
+
const width = upscaleFactor * this.canvasWidth, height = upscaleFactor * this.canvasHeight;
|
|
1261
|
+
outputScale.limitCanvas(width, height, this.maxCanvasPixels, this.maxCanvasDim);
|
|
1262
|
+
canvas.width = (width * outputScale.sx) | 0;
|
|
1263
|
+
canvas.height = (height * outputScale.sy) | 0;
|
|
1230
1264
|
const transform = outputScale.scaled
|
|
1231
1265
|
? [outputScale.sx, 0, 0, outputScale.sy, 0, 0]
|
|
1232
1266
|
: null;
|
|
@@ -1255,23 +1289,14 @@ _PDFThumbnailView_instances = new WeakSet(), _PDFThumbnailView_updateDims = func
|
|
|
1255
1289
|
// resources immediately, which can greatly reduce memory consumption.
|
|
1256
1290
|
reducedCanvas.width = 0;
|
|
1257
1291
|
reducedCanvas.height = 0;
|
|
1258
|
-
},
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
if (error instanceof RenderingCancelledException) {
|
|
1267
|
-
return;
|
|
1268
|
-
}
|
|
1269
|
-
this.renderingState = RenderingStates.FINISHED;
|
|
1270
|
-
__classPrivateFieldGet(this, _PDFThumbnailView_instances, "m", _PDFThumbnailView_convertCanvasToImage).call(this, canvas);
|
|
1271
|
-
if (error) {
|
|
1272
|
-
throw error;
|
|
1273
|
-
}
|
|
1274
|
-
});
|
|
1292
|
+
}, _PDFThumbnailView_getReducedImageDims = function _PDFThumbnailView_getReducedImageDims(canvas) {
|
|
1293
|
+
const width = canvas.width << MAX_NUM_SCALING_STEPS, height = canvas.height << MAX_NUM_SCALING_STEPS;
|
|
1294
|
+
const outputScale = new OutputScale();
|
|
1295
|
+
// Here we're not actually "rendering" to the canvas and the `OutputScale`
|
|
1296
|
+
// is thus only used to limit the canvas size, hence the identity scale.
|
|
1297
|
+
outputScale.sx = outputScale.sy = 1;
|
|
1298
|
+
outputScale.limitCanvas(width, height, this.maxCanvasPixels, this.maxCanvasDim);
|
|
1299
|
+
return [(width * outputScale.sx) | 0, (height * outputScale.sy) | 0];
|
|
1275
1300
|
}, _PDFThumbnailView_reduceImage = function _PDFThumbnailView_reduceImage(img) {
|
|
1276
1301
|
const { ctx, canvas } = __classPrivateFieldGet(this, _PDFThumbnailView_instances, "m", _PDFThumbnailView_getPageDrawContext).call(this, 1, true);
|
|
1277
1302
|
if (img.width <= 2 * canvas.width) {
|
|
@@ -1279,8 +1304,7 @@ _PDFThumbnailView_instances = new WeakSet(), _PDFThumbnailView_updateDims = func
|
|
|
1279
1304
|
return canvas;
|
|
1280
1305
|
}
|
|
1281
1306
|
// drawImage does an awful job of rescaling the image, doing it gradually.
|
|
1282
|
-
let reducedWidth =
|
|
1283
|
-
let reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
|
|
1307
|
+
let [reducedWidth, reducedHeight] = __classPrivateFieldGet(this, _PDFThumbnailView_instances, "m", _PDFThumbnailView_getReducedImageDims).call(this, canvas);
|
|
1284
1308
|
const [reducedImage, reducedImageCtx] = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
|
|
1285
1309
|
while (reducedWidth > img.width || reducedHeight > img.height) {
|
|
1286
1310
|
reducedWidth >>= 1;
|
|
@@ -1320,12 +1344,14 @@ class PDFThumbnailViewer {
|
|
|
1320
1344
|
/**
|
|
1321
1345
|
* @param {PDFThumbnailViewerOptions} options
|
|
1322
1346
|
*/
|
|
1323
|
-
constructor({ container, eventBus, linkService, renderingQueue, pageColors, abortSignal, enableHWA, store, thumbnailWidth, }) {
|
|
1347
|
+
constructor({ container, eventBus, linkService, renderingQueue, maxCanvasPixels, maxCanvasDim, pageColors, abortSignal, enableHWA, store, thumbnailWidth, }) {
|
|
1324
1348
|
_PDFThumbnailViewer_instances.add(this);
|
|
1325
1349
|
this.container = container;
|
|
1326
1350
|
this.eventBus = eventBus;
|
|
1327
1351
|
this.linkService = linkService;
|
|
1328
1352
|
this.renderingQueue = renderingQueue;
|
|
1353
|
+
this.maxCanvasPixels = maxCanvasPixels || 4096 * 8192;
|
|
1354
|
+
this.maxCanvasDim = maxCanvasDim || 32767;
|
|
1329
1355
|
this.pageColors = pageColors || null;
|
|
1330
1356
|
this.enableHWA = enableHWA || false;
|
|
1331
1357
|
// <pdf-slick>
|
|
@@ -1433,6 +1459,8 @@ class PDFThumbnailViewer {
|
|
|
1433
1459
|
optionalContentConfigPromise,
|
|
1434
1460
|
linkService: this.linkService,
|
|
1435
1461
|
renderingQueue: this.renderingQueue,
|
|
1462
|
+
maxCanvasPixels: this.maxCanvasPixels,
|
|
1463
|
+
maxCanvasDim: this.maxCanvasDim,
|
|
1436
1464
|
pageColors: this.pageColors,
|
|
1437
1465
|
enableHWA: this.enableHWA,
|
|
1438
1466
|
store: this.store,
|
|
@@ -1481,7 +1509,9 @@ class PDFThumbnailViewer {
|
|
|
1481
1509
|
forceRendering() {
|
|
1482
1510
|
const visibleThumbs = __classPrivateFieldGet(this, _PDFThumbnailViewer_instances, "m", _PDFThumbnailViewer_getVisibleThumbs).call(this);
|
|
1483
1511
|
const scrollAhead = __classPrivateFieldGet(this, _PDFThumbnailViewer_instances, "m", _PDFThumbnailViewer_getScrollAhead).call(this, visibleThumbs);
|
|
1484
|
-
const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, scrollAhead
|
|
1512
|
+
const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, scrollAhead,
|
|
1513
|
+
/* preRenderExtra */ false,
|
|
1514
|
+
/* ignoreDetailViews */ true);
|
|
1485
1515
|
if (thumbView) {
|
|
1486
1516
|
__classPrivateFieldGet(this, _PDFThumbnailViewer_instances, "m", _PDFThumbnailViewer_ensurePdfPageLoaded).call(this, thumbView).then(() => {
|
|
1487
1517
|
this.renderingQueue.renderView(thumbView);
|
|
@@ -1569,7 +1599,7 @@ function getXfaHtmlForPrinting(printContainer, pdfDocument) {
|
|
|
1569
1599
|
xfaHtml: xfaPage,
|
|
1570
1600
|
});
|
|
1571
1601
|
const viewport = getXfaPageViewport(xfaPage, { scale });
|
|
1572
|
-
builder.render(viewport, "print");
|
|
1602
|
+
builder.render({ viewport, intent: "print" });
|
|
1573
1603
|
page.append(builder.div);
|
|
1574
1604
|
}
|
|
1575
1605
|
}
|
|
@@ -2433,7 +2463,7 @@ function getPageName(size, isPortrait, pageNames) {
|
|
|
2433
2463
|
}
|
|
2434
2464
|
class PDFSlick {
|
|
2435
2465
|
constructor({ container, viewer, thumbs, store = create(), options, onError, printDialog, }) {
|
|
2436
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
2466
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
2437
2467
|
_PDFSlick_instances.add(this);
|
|
2438
2468
|
_PDFSlick_renderingQueue.set(this, void 0);
|
|
2439
2469
|
_PDFSlick_container.set(this, void 0);
|
|
@@ -2464,10 +2494,16 @@ class PDFSlick {
|
|
|
2464
2494
|
this.enablePrintAutoRotate = (_h = options === null || options === void 0 ? void 0 : options.enablePrintAutoRotate) !== null && _h !== void 0 ? _h : false;
|
|
2465
2495
|
this.useOnlyCssZoom = (_j = options === null || options === void 0 ? void 0 : options.useOnlyCssZoom) !== null && _j !== void 0 ? _j : false;
|
|
2466
2496
|
this.pageColors = (_k = options === null || options === void 0 ? void 0 : options.pageColors) !== null && _k !== void 0 ? _k : null;
|
|
2467
|
-
this.maxCanvasPixels = (_l = options === null || options === void 0 ? void 0 : options.maxCanvasPixels) !== null && _l !== void 0 ? _l :
|
|
2468
|
-
this.
|
|
2469
|
-
this.
|
|
2470
|
-
this.
|
|
2497
|
+
this.maxCanvasPixels = (_l = options === null || options === void 0 ? void 0 : options.maxCanvasPixels) !== null && _l !== void 0 ? _l : Math.pow(2, 24);
|
|
2498
|
+
this.maxCanvasDim = (_m = options === null || options === void 0 ? void 0 : options.maxCanvasDim) !== null && _m !== void 0 ? _m : 32767;
|
|
2499
|
+
this.capCanvasAreaFactor = (_o = options === null || options === void 0 ? void 0 : options.capCanvasAreaFactor) !== null && _o !== void 0 ? _o : 200;
|
|
2500
|
+
this.printResolution = (_p = options === null || options === void 0 ? void 0 : options.printResolution) !== null && _p !== void 0 ? _p : 96;
|
|
2501
|
+
this.thumbnailWidth = (_q = options === null || options === void 0 ? void 0 : options.thumbnailWidth) !== null && _q !== void 0 ? _q : 125;
|
|
2502
|
+
this.enableHWA = (_r = options === null || options === void 0 ? void 0 : options.enableHWA) !== null && _r !== void 0 ? _r : false;
|
|
2503
|
+
this.enableDetailCanvas = (_s = options === null || options === void 0 ? void 0 : options.enableDetailCanvas) !== null && _s !== void 0 ? _s : true;
|
|
2504
|
+
this.enableOptimizedPartialRendering = (_t = options === null || options === void 0 ? void 0 : options.enableOptimizedPartialRendering) !== null && _t !== void 0 ? _t : false;
|
|
2505
|
+
this.minDurationToUpdateCanvas = (_u = options === null || options === void 0 ? void 0 : options.minDurationToUpdateCanvas) !== null && _u !== void 0 ? _u : 500;
|
|
2506
|
+
this.getDocumentParams = (_v = options === null || options === void 0 ? void 0 : options.getDocumentParams) !== null && _v !== void 0 ? _v : {};
|
|
2471
2507
|
if (this.pageColors &&
|
|
2472
2508
|
!(CSS.supports("color", this.pageColors.background) &&
|
|
2473
2509
|
CSS.supports("color", this.pageColors.foreground))) {
|
|
@@ -2491,7 +2527,7 @@ class PDFSlick {
|
|
|
2491
2527
|
const findController = new PDFFindController({ eventBus, linkService });
|
|
2492
2528
|
const viewerOptions = Object.assign(Object.assign({ container }, (viewer && { viewer })), { eventBus,
|
|
2493
2529
|
linkService,
|
|
2494
|
-
findController, renderingQueue: renderingQueue, textLayerMode: this.textLayerMode, annotationEditorHighlightColors: this.annotationEditorHighlightColors, l10n: this.l10n, annotationMode: __classPrivateFieldGet(this, _PDFSlick_annotationMode, "f"), annotationEditorMode: __classPrivateFieldGet(this, _PDFSlick_annotationEditorMode, "f"), removePageBorders: this.removePageBorders, imageResourcesPath: "/images/" });
|
|
2530
|
+
findController, renderingQueue: renderingQueue, textLayerMode: this.textLayerMode, annotationEditorHighlightColors: this.annotationEditorHighlightColors, l10n: this.l10n, annotationMode: __classPrivateFieldGet(this, _PDFSlick_annotationMode, "f"), annotationEditorMode: __classPrivateFieldGet(this, _PDFSlick_annotationEditorMode, "f"), removePageBorders: this.removePageBorders, imageResourcesPath: "/images/", enableHWA: this.enableHWA, enableDetailCanvas: this.enableDetailCanvas, enableOptimizedPartialRendering: this.enableOptimizedPartialRendering, minDurationToUpdateCanvas: this.minDurationToUpdateCanvas, maxCanvasPixels: this.useOnlyCssZoom === true ? 0 : this.maxCanvasPixels, maxCanvasDim: this.maxCanvasDim, capCanvasAreaFactor: this.capCanvasAreaFactor });
|
|
2495
2531
|
const pdfViewer = this.singlePageViewer
|
|
2496
2532
|
? new PDFSinglePageViewer(viewerOptions)
|
|
2497
2533
|
: new PDFViewer(viewerOptions);
|
|
@@ -2502,10 +2538,13 @@ class PDFSlick {
|
|
|
2502
2538
|
eventBus,
|
|
2503
2539
|
linkService,
|
|
2504
2540
|
renderingQueue,
|
|
2541
|
+
maxCanvasPixels: this.useOnlyCssZoom === true ? 0 : this.maxCanvasPixels,
|
|
2542
|
+
maxCanvasDim: this.maxCanvasDim,
|
|
2505
2543
|
pageColors: this.pageColors,
|
|
2506
|
-
enableHWA:
|
|
2544
|
+
enableHWA: this.enableHWA,
|
|
2507
2545
|
store: store,
|
|
2508
2546
|
thumbnailWidth: this.thumbnailWidth,
|
|
2547
|
+
abortSignal: (_w = __classPrivateFieldGet(this, _PDFSlick_eventAbortController, "f")) === null || _w === void 0 ? void 0 : _w.signal,
|
|
2509
2548
|
});
|
|
2510
2549
|
renderingQueue.setThumbnailViewer(this.thumbnailViewer);
|
|
2511
2550
|
}
|
|
@@ -2526,7 +2565,7 @@ class PDFSlick {
|
|
|
2526
2565
|
slick: this,
|
|
2527
2566
|
printDialog: printDialog !== null && printDialog !== void 0 ? printDialog : PDFSlickPrintDialog.create(),
|
|
2528
2567
|
}), "f");
|
|
2529
|
-
const scaleValue = (
|
|
2568
|
+
const scaleValue = (_x = options === null || options === void 0 ? void 0 : options.scaleValue) !== null && _x !== void 0 ? _x : "auto";
|
|
2530
2569
|
this.store.setState({ scaleValue });
|
|
2531
2570
|
}
|
|
2532
2571
|
loadDocument(url, options) {
|
|
@@ -2606,7 +2645,7 @@ class PDFSlick {
|
|
|
2606
2645
|
const { filename } = this;
|
|
2607
2646
|
try {
|
|
2608
2647
|
// this._ensureDownloadComplete();
|
|
2609
|
-
const data = yield this.document.getData();
|
|
2648
|
+
const data = (yield this.document.getData()).slice(0);
|
|
2610
2649
|
const blob = new Blob([data], { type: "application/pdf" });
|
|
2611
2650
|
yield ((_a = this.downloadManager) === null || _a === void 0 ? void 0 : _a.download(blob, url, filename));
|
|
2612
2651
|
}
|
|
@@ -2627,7 +2666,7 @@ class PDFSlick {
|
|
|
2627
2666
|
const { filename } = this;
|
|
2628
2667
|
try {
|
|
2629
2668
|
// this._ensureDownloadComplete();
|
|
2630
|
-
const data = yield this.document.saveDocument();
|
|
2669
|
+
const data = (yield this.document.saveDocument()).slice(0);
|
|
2631
2670
|
const blob = new Blob([data], { type: "application/pdf" });
|
|
2632
2671
|
yield ((_a = this.downloadManager) === null || _a === void 0 ? void 0 : _a.download(blob, url, filename));
|
|
2633
2672
|
}
|
|
@@ -2713,7 +2752,7 @@ class PDFSlick {
|
|
|
2713
2752
|
this.setAnnotationEditorMode(AnnotationEditorType.HIGHLIGHT);
|
|
2714
2753
|
this.setAnnotationEditorParams([
|
|
2715
2754
|
{
|
|
2716
|
-
type: AnnotationEditorParamsType.
|
|
2755
|
+
type: AnnotationEditorParamsType.HIGHLIGHT_COLOR,
|
|
2717
2756
|
value: color,
|
|
2718
2757
|
},
|
|
2719
2758
|
]);
|
|
@@ -2933,9 +2972,8 @@ _PDFSlick_renderingQueue = new WeakMap(), _PDFSlick_container = new WeakMap(), _
|
|
|
2933
2972
|
var _b;
|
|
2934
2973
|
const documentOutline = (yield ((_b = this.document) === null || _b === void 0 ? void 0 : _b.getOutline()));
|
|
2935
2974
|
const scaleValue = this.store.getState().scaleValue;
|
|
2936
|
-
// source.
|
|
2937
|
-
source.
|
|
2938
|
-
source.currentScaleValue = "auto";
|
|
2975
|
+
// source.currentScale = 1;
|
|
2976
|
+
source.currentScaleValue = scaleValue !== null && scaleValue !== void 0 ? scaleValue : "auto";
|
|
2939
2977
|
this.store.setState({
|
|
2940
2978
|
documentOutline,
|
|
2941
2979
|
pageNumber: 1,
|
|
@@ -2974,4 +3012,4 @@ _PDFSlick_renderingQueue = new WeakMap(), _PDFSlick_container = new WeakMap(), _
|
|
|
2974
3012
|
}
|
|
2975
3013
|
};
|
|
2976
3014
|
|
|
2977
|
-
export { AutoPrintRegExp, CursorTool, DEFAULT_SCALE, DEFAULT_SCALE_DELTA, DEFAULT_SCALE_VALUE, MAX_AUTO_SCALE, MAX_SCALE, MIN_SCALE,
|
|
3015
|
+
export { AutoPrintRegExp, CursorTool, DEFAULT_SCALE, DEFAULT_SCALE_DELTA, DEFAULT_SCALE_VALUE, MAX_AUTO_SCALE, MAX_SCALE, MIN_SCALE, PDFSlick, PresentationModeState, ProgressBar, RendererType, RenderingStates, SCROLLBAR_PADDING, ScrollMode, SidebarView, SpreadMode, TextLayerMode, UNKNOWN_SCALE, VERTICAL_PADDING, animationStarted, apiPageLayoutToViewerModes, apiPageModeToSidebarView, approximateFraction, backtrackBeforeAllVisibleElements, binarySearchFirstItem, calcRound, create, docStyle, floorToDivide, getActiveOrFocusedElement, getPageSizeInches, getVisibleElements, initialState, isPortraitOrientation, isValidRotation, isValidScrollMode, isValidSpreadMode, normalizeWheelEventDelta, normalizeWheelEventDirection, parseQueryString, removeNullCharacters, scrollIntoView, toggleCheckedBtn, toggleExpandedBtn, watchScroll };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { type getVisibleElements } from "./ui_utils";
|
|
2
|
-
import { PDFThumbnailView } from "./pdf_thumbnail_view";
|
|
3
1
|
import { IRenderableView } from "pdfjs-dist/types/web/interfaces.js";
|
|
4
2
|
import { PDFThumbnailViewer } from "./pdf_thumbnail_viewer";
|
|
5
3
|
import { PDFViewer } from "pdfjs-dist/web/pdf_viewer.mjs";
|
|
4
|
+
import { getVisibleElements } from "./ui_utils";
|
|
6
5
|
/**
|
|
7
6
|
* Controls rendering of the views for pages and thumbnails.
|
|
8
7
|
*/
|
|
@@ -38,7 +37,11 @@ declare class PDFRenderingQueue {
|
|
|
38
37
|
* @param {boolean} scrolledDown
|
|
39
38
|
* @param {boolean} [preRenderExtra]
|
|
40
39
|
*/
|
|
41
|
-
getHighestPriority
|
|
40
|
+
getHighestPriority<T extends {
|
|
41
|
+
div: HTMLElement;
|
|
42
|
+
id: number;
|
|
43
|
+
detailView?: IRenderableView;
|
|
44
|
+
} & IRenderableView>(visible: ReturnType<typeof getVisibleElements<T>>, views: T[], scrolledDown: boolean, preRenderExtra?: boolean, ignoreDetailViews?: boolean): IRenderableView | null;
|
|
42
45
|
/**
|
|
43
46
|
* @param {IRenderableView} view
|
|
44
47
|
* @returns {boolean}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf_rendering_queue.d.ts","sourceRoot":"","sources":["../../lib/pdf_rendering_queue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pdf_rendering_queue.d.ts","sourceRoot":"","sources":["../../lib/pdf_rendering_queue.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAmB,MAAM,YAAY,CAAC;AAIjE;;GAEG;AACH,cAAM,iBAAiB;IACrB,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC9C,MAAM,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;IAC5B,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,WAAW,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,IAAI,CAAC;IAClD,QAAQ,EAAE,OAAO,CAAC;IAClB,sBAAsB,EAAE,OAAO,CAAC;;IAmBhC;;OAEG;IACH,SAAS,CAAC,SAAS,EAAE,SAAS;IAI9B;;OAEG;IACH,kBAAkB,CAAC,kBAAkB,EAAE,kBAAkB;IAIzD;;;OAGG;IACH,iBAAiB,CAAC,IAAI,EAAE,eAAe;IAIvC;;OAEG;IACH,qBAAqB,CAAC,qBAAqB,CAAC,EAAE,MAAM;IA4BpD;;;;;OAKG;IACH,kBAAkB,CAChB,CAAC,SAAS;QAAE,GAAG,EAAE,WAAW,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,eAAe,CAAA;KAAE,GAAG,eAAe,EAE1F,OAAO,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC,EACjD,KAAK,EAAE,CAAC,EAAE,EACV,YAAY,EAAE,OAAO,EACrB,cAAc,UAAQ,EACtB,iBAAiB,UAAQ,GACxB,eAAe,GAAG,IAAI;IAwEzB;;;OAGG;IACH,cAAc,CAAC,IAAI,EAAE,eAAe;IAIpC;;;;;;OAMG;IACH,UAAU,CAAC,IAAI,EAAE,eAAe;CA4BjC;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -15,6 +15,12 @@ import type { PDFRenderingQueue } from "./pdf_rendering_queue";
|
|
|
15
15
|
* The default value is `null`.
|
|
16
16
|
* @property {IPDFLinkService} linkService - The navigation/linking service.
|
|
17
17
|
* @property {PDFRenderingQueue} renderingQueue - The rendering queue object.
|
|
18
|
+
* @property {number} [maxCanvasPixels] - The maximum supported canvas size in
|
|
19
|
+
* total pixels, i.e. width * height. Use `-1` for no limit, or `0` for
|
|
20
|
+
* CSS-only zooming. The default value is 4096 * 8192 (32 mega-pixels).
|
|
21
|
+
* @property {number} [maxCanvasDim] - The maximum supported canvas dimension,
|
|
22
|
+
* in either width or height. Use `-1` for no limit.
|
|
23
|
+
* The default value is 32767.
|
|
18
24
|
* @property {Object} [pageColors] - Overwrites background and foreground colors
|
|
19
25
|
* with user defined ones in order to improve readability in high contrast
|
|
20
26
|
* mode.
|
|
@@ -34,6 +40,8 @@ type PDFThumbnailViewOptions = {
|
|
|
34
40
|
optionalContentConfigPromise?: Promise<OptionalContentConfig>;
|
|
35
41
|
linkService: NonNullable<PDFViewerOptions['linkService']>;
|
|
36
42
|
renderingQueue: PDFRenderingQueue;
|
|
43
|
+
maxCanvasPixels?: number;
|
|
44
|
+
maxCanvasDim?: number;
|
|
37
45
|
pageColors: {
|
|
38
46
|
background: any;
|
|
39
47
|
foreground: any;
|
|
@@ -53,6 +61,8 @@ declare class PDFThumbnailView {
|
|
|
53
61
|
_optionalContentConfigPromise: PDFThumbnailViewOptions['optionalContentConfigPromise'] | null;
|
|
54
62
|
linkService: PDFThumbnailViewOptions['linkService'];
|
|
55
63
|
renderingQueue: PDFThumbnailViewOptions['renderingQueue'];
|
|
64
|
+
maxCanvasPixels: number;
|
|
65
|
+
maxCanvasDim: number;
|
|
56
66
|
pageColors: PDFThumbnailViewOptions['pageColors'];
|
|
57
67
|
enableHWA: boolean | null;
|
|
58
68
|
store: StoreApi<PDFSlickState>;
|
|
@@ -74,7 +84,7 @@ declare class PDFThumbnailView {
|
|
|
74
84
|
/**
|
|
75
85
|
* @param {PDFThumbnailViewOptions} options
|
|
76
86
|
*/
|
|
77
|
-
constructor({ container, eventBus, id, defaultViewport, optionalContentConfigPromise, linkService, renderingQueue, pageColors, enableHWA, store, thumbnailWidth, }: PDFThumbnailViewOptions);
|
|
87
|
+
constructor({ container, eventBus, id, defaultViewport, optionalContentConfigPromise, linkService, renderingQueue, maxCanvasPixels, maxCanvasDim, pageColors, enableHWA, store, thumbnailWidth, }: PDFThumbnailViewOptions);
|
|
78
88
|
setPdfPage(pdfPage: PDFPageProxy): void;
|
|
79
89
|
reset(): void;
|
|
80
90
|
update({ rotation }: {
|
|
@@ -85,7 +95,7 @@ declare class PDFThumbnailView {
|
|
|
85
95
|
* rather than calling this one directly.
|
|
86
96
|
*/
|
|
87
97
|
cancelRendering(): void;
|
|
88
|
-
draw(): Promise<
|
|
98
|
+
draw(): Promise<undefined>;
|
|
89
99
|
setImage(pageView: PDFPageView): void;
|
|
90
100
|
/**
|
|
91
101
|
* @param {string|null} label
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf_thumbnail_view.d.ts","sourceRoot":"","sources":["../../lib/pdf_thumbnail_view.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pdf_thumbnail_view.d.ts","sourceRoot":"","sources":["../../lib/pdf_thumbnail_view.ts"],"names":[],"mappings":"AAyBA,OAAO,EAEL,YAAY,EACZ,YAAY,EACZ,UAAU,EAEX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAC1F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAa/D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,cAAM,gBAAgB;;IAGpB,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAe9C,MAAM,CAA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