Bug 1894705 - Update PDF.js to new version c419c8333b1b509fe90242135d9594aa026a8724 r=pdfjs-reviewers,marco

Differential Revision: https://phabricator.services.mozilla.com/D209258
This commit is contained in:
Calixte 2024-05-02 15:52:52 +00:00
parent 6027bfbb3f
commit 619edd4cf2
8 changed files with 505 additions and 495 deletions

View file

@ -827,6 +827,12 @@ class BaseFilterFactory {
addHCMFilter(fgColor, bgColor) {
return "none";
}
addAlphaFilter(map) {
return "none";
}
addLuminosityFilter(map) {
return "none";
}
addHighlightHCMFilter(filterName, fgColor, bgColor, newFgColor, newBgColor) {
return "none";
}
@ -1011,6 +1017,27 @@ class DOMFilterFactory extends BaseFilterFactory {
}
return this.#_defs;
}
#createTables(maps) {
if (maps.length === 1) {
const mapR = maps[0];
const buffer = new Array(256);
for (let i = 0; i < 256; i++) {
buffer[i] = mapR[i] / 255;
}
const table = buffer.join(",");
return [table, table, table];
}
const [mapR, mapG, mapB] = maps;
const bufferR = new Array(256);
const bufferG = new Array(256);
const bufferB = new Array(256);
for (let i = 0; i < 256; i++) {
bufferR[i] = mapR[i] / 255;
bufferG[i] = mapG[i] / 255;
bufferB[i] = mapB[i] / 255;
}
return [bufferR.join(","), bufferG.join(","), bufferB.join(",")];
}
addFilter(maps) {
if (!maps) {
return "none";
@ -1019,29 +1046,8 @@ class DOMFilterFactory extends BaseFilterFactory {
if (value) {
return value;
}
let tableR, tableG, tableB, key;
if (maps.length === 1) {
const mapR = maps[0];
const buffer = new Array(256);
for (let i = 0; i < 256; i++) {
buffer[i] = mapR[i] / 255;
}
key = tableR = tableG = tableB = buffer.join(",");
} else {
const [mapR, mapG, mapB] = maps;
const bufferR = new Array(256);
const bufferG = new Array(256);
const bufferB = new Array(256);
for (let i = 0; i < 256; i++) {
bufferR[i] = mapR[i] / 255;
bufferG[i] = mapG[i] / 255;
bufferB[i] = mapB[i] / 255;
}
tableR = bufferR.join(",");
tableG = bufferG.join(",");
tableB = bufferB.join(",");
key = `${tableR}${tableG}${tableB}`;
}
const [tableR, tableG, tableB] = this.#createTables(maps);
const key = maps.length === 1 ? tableR : `${tableR}${tableG}${tableB}`;
value = this.#cache.get(key);
if (value) {
this.#cache.set(maps, value);
@ -1109,6 +1115,54 @@ class DOMFilterFactory extends BaseFilterFactory {
info.url = `url(#${id})`;
return info.url;
}
addAlphaFilter(map) {
let value = this.#cache.get(map);
if (value) {
return value;
}
const [tableA] = this.#createTables([map]);
const key = `alpha_${tableA}`;
value = this.#cache.get(key);
if (value) {
this.#cache.set(map, value);
return value;
}
const id = `g_${this.#docId}_alpha_map_${this.#id++}`;
const url = `url(#${id})`;
this.#cache.set(map, url);
this.#cache.set(key, url);
const filter = this.#createFilter(id);
this.#addTransferMapAlphaConversion(tableA, filter);
return url;
}
addLuminosityFilter(map) {
let value = this.#cache.get(map || "luminosity");
if (value) {
return value;
}
let tableA, key;
if (map) {
[tableA] = this.#createTables([map]);
key = `luminosity_${tableA}`;
} else {
key = "luminosity";
}
value = this.#cache.get(key);
if (value) {
this.#cache.set(map, value);
return value;
}
const id = `g_${this.#docId}_luminosity_map_${this.#id++}`;
const url = `url(#${id})`;
this.#cache.set(map, url);
this.#cache.set(key, url);
const filter = this.#createFilter(id);
this.#addLuminosityConversion(filter);
if (map) {
this.#addTransferMapAlphaConversion(tableA, filter);
}
return url;
}
addHighlightHCMFilter(filterName, fgColor, bgColor, newFgColor, newBgColor) {
const key = `${fgColor}-${bgColor}-${newFgColor}-${newBgColor}`;
let info = this.#hcmCache.get(filterName);
@ -1179,6 +1233,12 @@ class DOMFilterFactory extends BaseFilterFactory {
}
this.#id = 0;
}
#addLuminosityConversion(filter) {
const feColorMatrix = this.#document.createElementNS(SVG_NS, "feColorMatrix");
feColorMatrix.setAttribute("type", "matrix");
feColorMatrix.setAttribute("values", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0");
filter.append(feColorMatrix);
}
#addGrayConversion(filter) {
const feColorMatrix = this.#document.createElementNS(SVG_NS, "feColorMatrix");
feColorMatrix.setAttribute("type", "matrix");
@ -1205,6 +1265,11 @@ class DOMFilterFactory extends BaseFilterFactory {
this.#appendFeFunc(feComponentTransfer, "feFuncG", gTable);
this.#appendFeFunc(feComponentTransfer, "feFuncB", bTable);
}
#addTransferMapAlphaConversion(aTable, filter) {
const feComponentTransfer = this.#document.createElementNS(SVG_NS, "feComponentTransfer");
filter.append(feComponentTransfer);
this.#appendFeFunc(feComponentTransfer, "feFuncA", aTable);
}
#getRGB(color) {
this.#defs.style.color = color;
return getRGB(getComputedStyle(this.#defs).getPropertyValue("color"));
@ -5651,7 +5716,6 @@ function grayToRGBA(src, dest) {
const MIN_FONT_SIZE = 16;
const MAX_FONT_SIZE = 100;
const MAX_GROUP_SIZE = 4096;
const EXECUTION_TIME = 15;
const EXECUTION_STEPS = 10;
const MAX_SIZE_TO_COMPILE = 1000;
@ -6203,72 +6267,6 @@ function resetCtxToDefault(ctx) {
ctx.filter = "none";
}
}
function composeSMaskBackdrop(bytes, r0, g0, b0) {
const length = bytes.length;
for (let i = 3; i < length; i += 4) {
const alpha = bytes[i];
if (alpha === 0) {
bytes[i - 3] = r0;
bytes[i - 2] = g0;
bytes[i - 1] = b0;
} else if (alpha < 255) {
const alpha_ = 255 - alpha;
bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
}
}
}
function composeSMaskAlpha(maskData, layerData, transferMap) {
const length = maskData.length;
const scale = 1 / 255;
for (let i = 3; i < length; i += 4) {
const alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
layerData[i] = layerData[i] * alpha * scale | 0;
}
}
function composeSMaskLuminosity(maskData, layerData, transferMap) {
const length = maskData.length;
for (let i = 3; i < length; i += 4) {
const y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
}
}
function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap, layerOffsetX, layerOffsetY, maskOffsetX, maskOffsetY) {
const hasBackdrop = !!backdrop;
const r0 = hasBackdrop ? backdrop[0] : 0;
const g0 = hasBackdrop ? backdrop[1] : 0;
const b0 = hasBackdrop ? backdrop[2] : 0;
const composeFn = subtype === "Luminosity" ? composeSMaskLuminosity : composeSMaskAlpha;
const PIXELS_TO_PROCESS = 1048576;
const chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
for (let row = 0; row < height; row += chunkSize) {
const chunkHeight = Math.min(chunkSize, height - row);
const maskData = maskCtx.getImageData(layerOffsetX - maskOffsetX, row + (layerOffsetY - maskOffsetY), width, chunkHeight);
const layerData = layerCtx.getImageData(layerOffsetX, row + layerOffsetY, width, chunkHeight);
if (hasBackdrop) {
composeSMaskBackdrop(maskData.data, r0, g0, b0);
}
composeFn(maskData.data, layerData.data, transferMap);
layerCtx.putImageData(layerData, layerOffsetX, row + layerOffsetY);
}
}
function composeSMask(ctx, smask, layerCtx, layerBox) {
const layerOffsetX = layerBox[0];
const layerOffsetY = layerBox[1];
const layerWidth = layerBox[2] - layerOffsetX;
const layerHeight = layerBox[3] - layerOffsetY;
if (layerWidth === 0 || layerHeight === 0) {
return;
}
genericComposeSMask(smask.context, layerCtx, layerWidth, layerHeight, smask.subtype, smask.backdrop, smask.transferMap, layerOffsetX, layerOffsetY, smask.offsetX, smask.offsetY);
ctx.save();
ctx.globalAlpha = 1;
ctx.globalCompositeOperation = "source-over";
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.drawImage(layerCtx.canvas, 0, 0);
ctx.restore();
}
function getImageSmoothingEnabled(transform, interpolate) {
if (interpolate) {
return true;
@ -6669,12 +6667,73 @@ class CanvasGraphics {
}
const smask = this.current.activeSMask;
const suspendedCtx = this.suspendedCtx;
composeSMask(suspendedCtx, smask, this.ctx, dirtyBox);
this.composeSMask(suspendedCtx, smask, this.ctx, dirtyBox);
this.ctx.save();
this.ctx.setTransform(1, 0, 0, 1, 0, 0);
this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);
this.ctx.restore();
}
composeSMask(ctx, smask, layerCtx, layerBox) {
const layerOffsetX = layerBox[0];
const layerOffsetY = layerBox[1];
const layerWidth = layerBox[2] - layerOffsetX;
const layerHeight = layerBox[3] - layerOffsetY;
if (layerWidth === 0 || layerHeight === 0) {
return;
}
this.genericComposeSMask(smask.context, layerCtx, layerWidth, layerHeight, smask.subtype, smask.backdrop, smask.transferMap, layerOffsetX, layerOffsetY, smask.offsetX, smask.offsetY);
ctx.save();
ctx.globalAlpha = 1;
ctx.globalCompositeOperation = "source-over";
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.drawImage(layerCtx.canvas, 0, 0);
ctx.restore();
}
genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap, layerOffsetX, layerOffsetY, maskOffsetX, maskOffsetY) {
let maskCanvas = maskCtx.canvas;
let maskX = layerOffsetX - maskOffsetX;
let maskY = layerOffsetY - maskOffsetY;
if (backdrop) {
if (maskX < 0 || maskY < 0 || maskX + width > maskCanvas.width || maskY + height > maskCanvas.height) {
const canvas = this.cachedCanvases.getCanvas("maskExtension", width, height);
const ctx = canvas.context;
ctx.drawImage(maskCanvas, -maskX, -maskY);
if (backdrop.some(c => c !== 0)) {
ctx.globalCompositeOperation = "destination-atop";
ctx.fillStyle = Util.makeHexColor(...backdrop);
ctx.fillRect(0, 0, width, height);
ctx.globalCompositeOperation = "source-over";
}
maskCanvas = canvas.canvas;
maskX = maskY = 0;
} else if (backdrop.some(c => c !== 0)) {
maskCtx.save();
maskCtx.globalAlpha = 1;
maskCtx.setTransform(1, 0, 0, 1, 0, 0);
const clip = new Path2D();
clip.rect(maskX, maskY, width, height);
maskCtx.clip(clip);
maskCtx.globalCompositeOperation = "destination-atop";
maskCtx.fillStyle = Util.makeHexColor(...backdrop);
maskCtx.fillRect(maskX, maskY, width, height);
maskCtx.restore();
}
}
layerCtx.save();
layerCtx.globalAlpha = 1;
layerCtx.setTransform(1, 0, 0, 1, 0, 0);
if (subtype === "Alpha" && transferMap) {
layerCtx.filter = this.filterFactory.addAlphaFilter(transferMap);
} else if (subtype === "Luminosity") {
layerCtx.filter = this.filterFactory.addLuminosityFilter(transferMap);
}
const clip = new Path2D();
clip.rect(layerOffsetX, layerOffsetY, width, height);
layerCtx.clip(clip);
layerCtx.globalCompositeOperation = "destination-in";
layerCtx.drawImage(maskCanvas, maskX, maskY, width, height, layerOffsetX, layerOffsetY, width, height);
layerCtx.restore();
}
save() {
if (this.inSMaskMode) {
copyCtxState(this.ctx, this.suspendedCtx);
@ -7357,18 +7416,8 @@ class CanvasGraphics {
bounds = Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
const offsetX = Math.floor(bounds[0]);
const offsetY = Math.floor(bounds[1]);
let drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
let drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
let scaleX = 1,
scaleY = 1;
if (drawnWidth > MAX_GROUP_SIZE) {
scaleX = drawnWidth / MAX_GROUP_SIZE;
drawnWidth = MAX_GROUP_SIZE;
}
if (drawnHeight > MAX_GROUP_SIZE) {
scaleY = drawnHeight / MAX_GROUP_SIZE;
drawnHeight = MAX_GROUP_SIZE;
}
const drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
const drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
this.current.startNewPathAndClipBox([0, 0, drawnWidth, drawnHeight]);
let cacheId = "groupAt" + this.groupLevel;
if (group.smask) {
@ -7376,7 +7425,6 @@ class CanvasGraphics {
}
const scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight);
const groupCtx = scratchCanvas.context;
groupCtx.scale(1 / scaleX, 1 / scaleY);
groupCtx.translate(-offsetX, -offsetY);
groupCtx.transform(...currentTransform);
if (group.smask) {
@ -7385,8 +7433,6 @@ class CanvasGraphics {
context: groupCtx,
offsetX,
offsetY,
scaleX,
scaleY,
subtype: group.smask.subtype,
backdrop: group.smask.backdrop,
transferMap: group.smask.transferMap || null,
@ -7395,7 +7441,6 @@ class CanvasGraphics {
} else {
currentCtx.setTransform(1, 0, 0, 1, 0, 0);
currentCtx.translate(offsetX, offsetY);
currentCtx.scale(scaleX, scaleY);
currentCtx.save();
}
copyCtxState(currentCtx, groupCtx);
@ -9308,7 +9353,7 @@ function getDocument(src) {
}
const fetchDocParams = {
docId,
apiVersion: "4.2.55",
apiVersion: "4.3.8",
data,
password,
disableAutoFetch,
@ -9393,6 +9438,9 @@ function getDataProp(val) {
}
throw new Error("Invalid PDF binary data: either TypedArray, " + "string, or array-like object is expected in the data property.");
}
function isRefProxy(ref) {
return typeof ref === "object" && Number.isInteger(ref?.num) && ref.num >= 0 && Number.isInteger(ref?.gen) && ref.gen >= 0;
}
class PDFDocumentLoadingTask {
static #docId = 0;
constructor() {
@ -9576,6 +9624,9 @@ class PDFDocumentProxy {
destroy() {
return this.loadingTask.destroy();
}
cachedPageNumber(ref) {
return this._transport.cachedPageNumber(ref);
}
get loadingParams() {
return this._transport.loadingParams;
}
@ -10193,6 +10244,7 @@ class WorkerTransport {
#methodPromises = new Map();
#pageCache = new Map();
#pagePromises = new Map();
#pageRefCache = new Map();
#passwordCapability = null;
constructor(messageHandler, loadingTask, networkStream, params, factory) {
this.messageHandler = messageHandler;
@ -10281,6 +10333,7 @@ class WorkerTransport {
}
this.#pageCache.clear();
this.#pagePromises.clear();
this.#pageRefCache.clear();
if (this.hasOwnProperty("annotationStorage")) {
this.annotationStorage.resetModified();
}
@ -10610,6 +10663,9 @@ class WorkerTransport {
if (this.destroyed) {
throw new Error("Transport destroyed");
}
if (pageInfo.refStr) {
this.#pageRefCache.set(pageInfo.refStr, pageNumber);
}
const page = new PDFPageProxy(pageIndex, pageInfo, this, this._params.pdfBug);
this.#pageCache.set(pageIndex, page);
return page;
@ -10618,7 +10674,7 @@ class WorkerTransport {
return promise;
}
getPageIndex(ref) {
if (typeof ref !== "object" || !Number.isInteger(ref?.num) || ref.num < 0 || !Number.isInteger(ref?.gen) || ref.gen < 0) {
if (!isRefProxy(ref)) {
return Promise.reject(new Error("Invalid pageIndex request."));
}
return this.messageHandler.sendWithPromise("GetPageIndex", {
@ -10729,6 +10785,13 @@ class WorkerTransport {
this.filterFactory.destroy(true);
cleanupTextLayer();
}
cachedPageNumber(ref) {
if (!isRefProxy(ref)) {
return null;
}
const refStr = ref.gen === 0 ? `${ref.num}R` : `${ref.num}R${ref.gen}`;
return this.#pageRefCache.get(refStr) ?? null;
}
get loadingParams() {
const {
disableAutoFetch,
@ -10950,8 +11013,8 @@ class InternalRenderTask {
}
}
}
const version = "4.2.55";
const build = "85e64b5c1";
const version = "4.3.8";
const build = "c419c8333";
;// CONCATENATED MODULE: ./src/shared/scripting_utils.js
function makeColorComp(n) {
@ -11898,6 +11961,9 @@ class LinkAnnotationElement extends AnnotationElement {
}
#bindAttachment(link, attachment, dest = null) {
link.href = this.linkService.getAnchorUrl("");
if (attachment.description) {
link.title = attachment.description;
}
link.onclick = () => {
this.downloadManager?.openOrDownloadData(attachment.content, attachment.filename, dest);
return false;
@ -13486,14 +13552,16 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
});
const {
filename,
content
content,
description
} = this.data.file;
this.filename = getFilenameFromUrl(filename, true);
this.content = content;
this.linkService.eventBus?.dispatch("fileattachmentannotation", {
source: this,
filename,
content
content,
description
});
}
render() {
@ -17736,8 +17804,8 @@ class DrawLayer {
const pdfjsVersion = "4.2.55";
const pdfjsBuild = "85e64b5c1";
const pdfjsVersion = "4.3.8";
const pdfjsBuild = "c419c8333";
var __webpack_exports__AbortException = __webpack_exports__.AbortException;
var __webpack_exports__AnnotationEditorLayer = __webpack_exports__.AnnotationEditorLayer;

View file

@ -3956,8 +3956,8 @@ function initSandbox(params) {
;// CONCATENATED MODULE: ./src/pdf.scripting.js
const pdfjsVersion = "4.2.55";
const pdfjsBuild = "85e64b5c1";
const pdfjsVersion = "4.3.8";
const pdfjsBuild = "c419c8333";
globalThis.pdfjsScripting = {
initSandbox: initSandbox
};

View file

@ -1221,6 +1221,9 @@ function readUint32(data, offset) {
function isWhiteSpace(ch) {
return ch === 0x20 || ch === 0x09 || ch === 0x0d || ch === 0x0a;
}
function isNumberArray(arr, len) {
return Array.isArray(arr) && (len === null || arr.length === len) && arr.every(x => typeof x === "number");
}
function parseXFAPath(path) {
const positionPattern = /(.+)\[(\d+)\]$/;
return path.split(".").map(component => {
@ -17144,6 +17147,7 @@ class CFFFont {
function getUint32(data, offset) {
return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
}
@ -17781,7 +17785,7 @@ class Commands {
cmds = [];
add(cmd, args) {
if (args) {
if (args.some(arg => typeof arg !== "number")) {
if (!isNumberArray(args, null)) {
warn(`Commands.add - "${cmd}" has at least one non-number arg: "${args}".`);
const newArgs = args.map(arg => typeof arg === "number" ? arg : 0);
this.cmds.push(cmd, ...newArgs);
@ -17807,20 +17811,20 @@ class CompiledFont {
charCode,
glyphId
} = lookupCmap(this.cmap, unicode);
let fn = this.compiledGlyphs[glyphId];
let fn = this.compiledGlyphs[glyphId],
compileEx;
if (!fn) {
try {
fn = this.compiledGlyphs[glyphId] = this.compileGlyph(this.glyphs[glyphId], glyphId);
fn = this.compileGlyph(this.glyphs[glyphId], glyphId);
} catch (ex) {
this.compiledGlyphs[glyphId] = NOOP;
if (this.compiledCharCodeToGlyphId[charCode] === undefined) {
this.compiledCharCodeToGlyphId[charCode] = glyphId;
}
throw ex;
fn = NOOP;
compileEx = ex;
}
this.compiledGlyphs[glyphId] = fn;
}
if (this.compiledCharCodeToGlyphId[charCode] === undefined) {
this.compiledCharCodeToGlyphId[charCode] = glyphId;
this.compiledCharCodeToGlyphId[charCode] ??= glyphId;
if (compileEx) {
throw compileEx;
}
return fn;
}
@ -26375,6 +26379,7 @@ class GlobalImageCache {
class PDFFunctionFactory {
constructor({
xref,
@ -26450,15 +26455,8 @@ function toNumberArray(arr) {
if (!Array.isArray(arr)) {
return null;
}
const length = arr.length;
for (let i = 0; i < length; i++) {
if (typeof arr[i] !== "number") {
const result = new Array(length);
for (let j = 0; j < length; j++) {
result[j] = +arr[j];
}
return result;
}
if (!isNumberArray(arr, null)) {
return arr.map(x => +x);
}
return arr;
}
@ -29533,6 +29531,7 @@ class PDFImage {
const DefaultPartialEvaluatorOptions = Object.freeze({
@ -32213,56 +32212,85 @@ class PartialEvaluator {
let defaultWidth = 0;
const glyphsVMetrics = [];
let defaultVMetrics;
let i, ii, j, jj, start, code, widths;
if (properties.composite) {
defaultWidth = dict.has("DW") ? dict.get("DW") : 1000;
widths = dict.get("W");
if (widths) {
for (i = 0, ii = widths.length; i < ii; i++) {
start = xref.fetchIfRef(widths[i++]);
code = xref.fetchIfRef(widths[i]);
const dw = dict.get("DW");
defaultWidth = Number.isInteger(dw) ? dw : 1000;
const widths = dict.get("W");
if (Array.isArray(widths)) {
for (let i = 0, ii = widths.length; i < ii; i++) {
let start = xref.fetchIfRef(widths[i++]);
if (!Number.isInteger(start)) {
break;
}
const code = xref.fetchIfRef(widths[i]);
if (Array.isArray(code)) {
for (j = 0, jj = code.length; j < jj; j++) {
glyphsWidths[start++] = xref.fetchIfRef(code[j]);
for (const c of code) {
const width = xref.fetchIfRef(c);
if (typeof width === "number") {
glyphsWidths[start] = width;
}
start++;
}
} else {
} else if (Number.isInteger(code)) {
const width = xref.fetchIfRef(widths[++i]);
for (j = start; j <= code; j++) {
if (typeof width !== "number") {
continue;
}
for (let j = start; j <= code; j++) {
glyphsWidths[j] = width;
}
} else {
break;
}
}
}
if (properties.vertical) {
let vmetrics = dict.getArray("DW2") || [880, -1000];
const dw2 = dict.getArray("DW2");
let vmetrics = isNumberArray(dw2, 2) ? dw2 : [880, -1000];
defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]];
vmetrics = dict.get("W2");
if (vmetrics) {
for (i = 0, ii = vmetrics.length; i < ii; i++) {
start = xref.fetchIfRef(vmetrics[i++]);
code = xref.fetchIfRef(vmetrics[i]);
if (Array.isArray(vmetrics)) {
for (let i = 0, ii = vmetrics.length; i < ii; i++) {
let start = xref.fetchIfRef(vmetrics[i++]);
if (!Number.isInteger(start)) {
break;
}
const code = xref.fetchIfRef(vmetrics[i]);
if (Array.isArray(code)) {
for (j = 0, jj = code.length; j < jj; j++) {
glyphsVMetrics[start++] = [xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j])];
for (let j = 0, jj = code.length; j < jj; j++) {
const vmetric = [xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j])];
if (isNumberArray(vmetric, null)) {
glyphsVMetrics[start] = vmetric;
}
start++;
}
} else {
} else if (Number.isInteger(code)) {
const vmetric = [xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i])];
for (j = start; j <= code; j++) {
if (!isNumberArray(vmetric, null)) {
continue;
}
for (let j = start; j <= code; j++) {
glyphsVMetrics[j] = vmetric;
}
} else {
break;
}
}
}
}
} else {
const firstChar = properties.firstChar;
widths = dict.get("Widths");
if (widths) {
j = firstChar;
for (i = 0, ii = widths.length; i < ii; i++) {
glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
const widths = dict.get("Widths");
if (Array.isArray(widths)) {
let j = properties.firstChar;
for (const w of widths) {
const width = xref.fetchIfRef(w);
if (typeof width === "number") {
glyphsWidths[j] = width;
}
j++;
}
defaultWidth = parseFloat(descriptor.get("MissingWidth")) || 0;
const missingWidth = descriptor.get("MissingWidth");
defaultWidth = typeof missingWidth === "number" ? missingWidth : 0;
} else {
const baseFontName = dict.get("BaseFont");
if (baseFontName instanceof Name) {
@ -32364,8 +32392,14 @@ class PartialEvaluator {
}
composite = true;
}
const firstChar = dict.get("FirstChar") || 0,
lastChar = dict.get("LastChar") || (composite ? 0xffff : 0xff);
let firstChar = dict.get("FirstChar");
if (!Number.isInteger(firstChar)) {
firstChar = 0;
}
let lastChar = dict.get("LastChar");
if (!Number.isInteger(lastChar)) {
lastChar = composite ? 0xffff : 0xff;
}
const descriptor = dict.get("FontDescriptor");
const toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
if (descriptor) {
@ -32470,9 +32504,13 @@ class PartialEvaluator {
const isType3Font = type === "Type3";
if (!descriptor) {
if (isType3Font) {
let bbox = dict.getArray("FontBBox");
if (!isNumberArray(bbox, 4)) {
bbox = [0, 0, 0, 0];
}
descriptor = new Dict(null);
descriptor.set("FontName", Name.get(type));
descriptor.set("FontBBox", dict.getArray("FontBBox") || [0, 0, 0, 0]);
descriptor.set("FontBBox", bbox);
} else {
let baseFontName = dict.get("BaseFont");
if (!(baseFontName instanceof Name)) {
@ -32510,11 +32548,15 @@ class PartialEvaluator {
properties.systemFontInfo = getFontSubstitution(this.systemFontCache, this.idFactory, this.options.standardFontDataUrl, baseFontName, standardFontName, type);
}
const newProperties = await this.extractDataStructures(dict, properties);
if (widths) {
if (Array.isArray(widths)) {
const glyphWidths = [];
let j = firstChar;
for (const width of widths) {
glyphWidths[j++] = this.xref.fetchIfRef(width);
for (const w of widths) {
const width = this.xref.fetchIfRef(w);
if (typeof width === "number") {
glyphWidths[j] = width;
}
j++;
}
newProperties.widths = glyphWidths;
} else {
@ -32588,9 +32630,37 @@ class PartialEvaluator {
}
}
let fontMatrix = dict.getArray("FontMatrix");
if (!Array.isArray(fontMatrix) || fontMatrix.length !== 6 || fontMatrix.some(x => typeof x !== "number")) {
if (!isNumberArray(fontMatrix, 6)) {
fontMatrix = FONT_IDENTITY_MATRIX;
}
let bbox = descriptor.getArray("FontBBox") || dict.getArray("FontBBox");
if (!isNumberArray(bbox, 4)) {
bbox = undefined;
}
let ascent = descriptor.get("Ascent");
if (typeof ascent !== "number") {
ascent = undefined;
}
let descent = descriptor.get("Descent");
if (typeof descent !== "number") {
descent = undefined;
}
let xHeight = descriptor.get("XHeight");
if (typeof xHeight !== "number") {
xHeight = 0;
}
let capHeight = descriptor.get("CapHeight");
if (typeof capHeight !== "number") {
capHeight = 0;
}
let flags = descriptor.get("Flags");
if (!Number.isInteger(flags)) {
flags = 0;
}
let italicAngle = descriptor.get("ItalicAngle");
if (typeof italicAngle !== "number") {
italicAngle = 0;
}
const properties = {
type,
name: fontName.name,
@ -32607,13 +32677,13 @@ class PartialEvaluator {
firstChar,
lastChar,
toUnicode,
bbox: descriptor.getArray("FontBBox") || dict.getArray("FontBBox"),
ascent: descriptor.get("Ascent"),
descent: descriptor.get("Descent"),
xHeight: descriptor.get("XHeight") || 0,
capHeight: descriptor.get("CapHeight") || 0,
flags: descriptor.get("Flags"),
italicAngle: descriptor.get("ItalicAngle") || 0,
bbox,
ascent,
descent,
xHeight,
capHeight,
flags,
italicAngle,
isType3Font,
cssFontInfo,
scaleFactors: glyphScaleFactors,
@ -33932,7 +34002,6 @@ class FileSpec {
if (root.has("FS")) {
this.fs = root.get("FS");
}
this.description = root.has("Desc") ? stringToPDFString(root.get("Desc")) : "";
if (root.has("RF")) {
warn("Related file specifications are not supported");
}
@ -33971,10 +34040,19 @@ class FileSpec {
}
return content;
}
get description() {
let description = "";
const desc = this.root?.get("Desc");
if (desc && typeof desc === "string") {
description = stringToPDFString(desc);
}
return shadow(this, "description", description);
}
get serializable() {
return {
filename: this.filename,
content: this.content
content: this.content,
description: this.description
};
}
}
@ -55361,7 +55439,7 @@ class WorkerMessageHandler {
docId,
apiVersion
} = docParams;
const workerVersion = "4.2.55";
const workerVersion = "4.3.8";
if (apiVersion !== workerVersion) {
throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
}
@ -55578,6 +55656,7 @@ class WorkerMessageHandler {
return {
rotate,
ref,
refStr: ref?.toString() ?? null,
userUnit,
view
};
@ -55923,8 +56002,8 @@ if (typeof window === "undefined" && !isNodeJS && typeof self !== "undefined" &&
;// CONCATENATED MODULE: ./src/pdf.worker.js
const pdfjsVersion = "4.2.55";
const pdfjsBuild = "85e64b5c1";
const pdfjsVersion = "4.3.8";
const pdfjsBuild = "c419c8333";
var __webpack_exports__WorkerMessageHandler = __webpack_exports__.WorkerMessageHandler;
export { __webpack_exports__WorkerMessageHandler as WorkerMessageHandler };

View file

@ -884,7 +884,6 @@
.pdfViewer .page canvas{
margin:0;
display:block;
}
.pdfViewer .page canvas .structTree{

View file

@ -808,44 +808,8 @@ const LinkTarget = {
PARENT: 3,
TOP: 4
};
function addLinkAttributes(link, {
url,
target,
rel,
enabled = true
} = {}) {
if (!url || typeof url !== "string") {
throw new Error('A valid "url" parameter must provided.');
}
if (enabled) {
link.href = link.title = url;
} else {
link.href = "";
link.title = `Disabled: ${url}`;
link.onclick = () => false;
}
let targetStr = "";
switch (target) {
case LinkTarget.NONE:
break;
case LinkTarget.SELF:
targetStr = "_self";
break;
case LinkTarget.BLANK:
targetStr = "_blank";
break;
case LinkTarget.PARENT:
targetStr = "_parent";
break;
case LinkTarget.TOP:
targetStr = "_top";
break;
}
link.target = targetStr;
link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
}
class PDFLinkService {
#pagesRefCache = new Map();
externalLinkEnabled = true;
constructor({
eventBus,
externalLinkTarget = null,
@ -855,7 +819,6 @@ class PDFLinkService {
this.eventBus = eventBus;
this.externalLinkTarget = externalLinkTarget;
this.externalLinkRel = externalLinkRel;
this.externalLinkEnabled = true;
this._ignoreDestinationZoom = ignoreDestinationZoom;
this.baseUrl = null;
this.pdfDocument = null;
@ -865,7 +828,6 @@ class PDFLinkService {
setDocument(pdfDocument, baseUrl = null) {
this.baseUrl = baseUrl;
this.pdfDocument = pdfDocument;
this.#pagesRefCache.clear();
}
setViewer(pdfViewer) {
this.pdfViewer = pdfViewer;
@ -877,42 +839,56 @@ class PDFLinkService {
return this.pdfDocument ? this.pdfDocument.numPages : 0;
}
get page() {
return this.pdfViewer.currentPageNumber;
return this.pdfDocument ? this.pdfViewer.currentPageNumber : 1;
}
set page(value) {
this.pdfViewer.currentPageNumber = value;
if (this.pdfDocument) {
this.pdfViewer.currentPageNumber = value;
}
}
get rotation() {
return this.pdfViewer.pagesRotation;
return this.pdfDocument ? this.pdfViewer.pagesRotation : 0;
}
set rotation(value) {
this.pdfViewer.pagesRotation = value;
if (this.pdfDocument) {
this.pdfViewer.pagesRotation = value;
}
}
get isInPresentationMode() {
return this.pdfViewer.isInPresentationMode;
return this.pdfDocument ? this.pdfViewer.isInPresentationMode : false;
}
#goToDestinationHelper(rawDest, namedDest = null, explicitDest) {
const destRef = explicitDest[0];
let pageNumber;
if (typeof destRef === "object" && destRef !== null) {
pageNumber = this._cachedPageNumber(destRef);
async goToDestination(dest) {
if (!this.pdfDocument) {
return;
}
let namedDest, explicitDest, pageNumber;
if (typeof dest === "string") {
namedDest = dest;
explicitDest = await this.pdfDocument.getDestination(dest);
} else {
namedDest = null;
explicitDest = await dest;
}
if (!Array.isArray(explicitDest)) {
console.error(`goToDestination: "${explicitDest}" is not a valid destination array, for dest="${dest}".`);
return;
}
const [destRef] = explicitDest;
if (destRef && typeof destRef === "object") {
pageNumber = this.pdfDocument.cachedPageNumber(destRef);
if (!pageNumber) {
this.pdfDocument.getPageIndex(destRef).then(pageIndex => {
this.cachePageRef(pageIndex + 1, destRef);
this.#goToDestinationHelper(rawDest, namedDest, explicitDest);
}).catch(() => {
console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid page reference, for dest="${rawDest}".`);
});
return;
try {
pageNumber = (await this.pdfDocument.getPageIndex(destRef)) + 1;
} catch {
console.error(`goToDestination: "${destRef}" is not a valid page reference, for dest="${dest}".`);
return;
}
}
} else if (Number.isInteger(destRef)) {
pageNumber = destRef + 1;
} else {
console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid destination reference, for dest="${rawDest}".`);
return;
}
if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
console.error(`PDFLinkService.#goToDestinationHelper: "${pageNumber}" is not ` + `a valid page number, for dest="${rawDest}".`);
console.error(`goToDestination: "${pageNumber}" is not a valid page number, for dest="${dest}".`);
return;
}
if (this.pdfHistory) {
@ -929,24 +905,6 @@ class PDFLinkService {
ignoreDestinationZoom: this._ignoreDestinationZoom
});
}
async goToDestination(dest) {
if (!this.pdfDocument) {
return;
}
let namedDest, explicitDest;
if (typeof dest === "string") {
namedDest = dest;
explicitDest = await this.pdfDocument.getDestination(dest);
} else {
namedDest = null;
explicitDest = await dest;
}
if (!Array.isArray(explicitDest)) {
console.error(`PDFLinkService.goToDestination: "${explicitDest}" is not ` + `a valid destination array, for dest="${dest}".`);
return;
}
this.#goToDestinationHelper(dest, namedDest, explicitDest);
}
goToPage(val) {
if (!this.pdfDocument) {
return;
@ -965,12 +923,37 @@ class PDFLinkService {
});
}
addLinkAttributes(link, url, newWindow = false) {
addLinkAttributes(link, {
url,
target: newWindow ? LinkTarget.BLANK : this.externalLinkTarget,
rel: this.externalLinkRel,
enabled: this.externalLinkEnabled
});
if (!url || typeof url !== "string") {
throw new Error('A valid "url" parameter must provided.');
}
const target = newWindow ? LinkTarget.BLANK : this.externalLinkTarget,
rel = this.externalLinkRel;
if (this.externalLinkEnabled) {
link.href = link.title = url;
} else {
link.href = "";
link.title = `Disabled: ${url}`;
link.onclick = () => false;
}
let targetStr = "";
switch (target) {
case LinkTarget.NONE:
break;
case LinkTarget.SELF:
targetStr = "_self";
break;
case LinkTarget.BLANK:
targetStr = "_blank";
break;
case LinkTarget.PARENT:
targetStr = "_parent";
break;
case LinkTarget.TOP:
targetStr = "_top";
break;
}
link.target = targetStr;
link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
}
getDestinationHash(dest) {
if (typeof dest === "string") {
@ -1071,6 +1054,9 @@ class PDFLinkService {
console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not a valid destination.`);
}
executeNamedAction(action) {
if (!this.pdfDocument) {
return;
}
switch (action) {
case "GoBack":
this.pdfHistory?.back();
@ -1099,28 +1085,17 @@ class PDFLinkService {
});
}
async executeSetOCGState(action) {
const pdfDocument = this.pdfDocument;
const optionalContentConfig = await this.pdfViewer.optionalContentConfigPromise;
if (!this.pdfDocument) {
return;
}
const pdfDocument = this.pdfDocument,
optionalContentConfig = await this.pdfViewer.optionalContentConfigPromise;
if (pdfDocument !== this.pdfDocument) {
return;
}
optionalContentConfig.setOCGState(action);
this.pdfViewer.optionalContentConfigPromise = Promise.resolve(optionalContentConfig);
}
cachePageRef(pageNum, pageRef) {
if (!pageRef) {
return;
}
const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
this.#pagesRefCache.set(refStr, pageNum);
}
_cachedPageNumber(pageRef) {
if (!pageRef) {
return null;
}
const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
return this.#pagesRefCache.get(refStr) || null;
}
static #isValidExplicitDest(dest) {
if (!Array.isArray(dest) || dest.length < 2) {
return false;
@ -1167,42 +1142,8 @@ class PDFLinkService {
return true;
}
}
class SimpleLinkService {
constructor() {
this.externalLinkEnabled = true;
}
get pagesCount() {
return 0;
}
get page() {
return 0;
}
set page(value) {}
get rotation() {
return 0;
}
set rotation(value) {}
get isInPresentationMode() {
return false;
}
async goToDestination(dest) {}
goToPage(val) {}
addLinkAttributes(link, url, newWindow = false) {
addLinkAttributes(link, {
url,
enabled: this.externalLinkEnabled
});
}
getDestinationHash(dest) {
return "#";
}
getAnchorUrl(hash) {
return "#";
}
setHash(hash) {}
executeNamedAction(action) {}
executeSetOCGState(action) {}
cachePageRef(pageNum, pageRef) {}
class SimpleLinkService extends PDFLinkService {
setDocument(pdfDocument, baseUrl = null) {}
}
;// CONCATENATED MODULE: ./web/pdfjs.js
@ -5933,7 +5874,7 @@ class PDFViewer {
#scaleTimeoutId = null;
#textLayerMode = TextLayerMode.ENABLE;
constructor(options) {
const viewerVersion = "4.2.55";
const viewerVersion = "4.3.8";
if (version !== viewerVersion) {
throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`);
}
@ -6363,11 +6304,7 @@ class PDFViewer {
});
this._pages.push(pageView);
}
const firstPageView = this._pages[0];
if (firstPageView) {
firstPageView.setPdfPage(firstPdfPage);
this.linkService.cachePageRef(1, firstPdfPage.ref);
}
this._pages[0]?.setPdfPage(firstPdfPage);
if (this._scrollMode === ScrollMode.PAGE) {
this.#ensurePageViewVisible();
} else if (this._spreadMode !== SpreadMode.NONE) {
@ -6401,7 +6338,6 @@ class PDFViewer {
if (!pageView.pdfPage) {
pageView.setPdfPage(pdfPage);
}
this.linkService.cachePageRef(pageNum, pdfPage.ref);
if (--getPagesLeft === 0) {
this._pagesCapability.resolve();
}
@ -6908,9 +6844,6 @@ class PDFViewer {
if (!pageView.pdfPage) {
pageView.setPdfPage(pdfPage);
}
if (!this.linkService._cachedPageNumber?.(pdfPage.ref)) {
this.linkService.cachePageRef(pageView.id, pdfPage.ref);
}
return pdfPage;
} catch (reason) {
console.error("Unable to get page for page view", reason);
@ -9625,8 +9558,8 @@ function webViewerReportTelemetry({
const pdfjsVersion = "4.2.55";
const pdfjsBuild = "85e64b5c1";
const pdfjsVersion = "4.3.8";
const pdfjsBuild = "c419c8333";
const AppConstants = null;
window.PDFViewerApplication = PDFViewerApplication;
window.PDFViewerApplicationConstants = AppConstants;

View file

@ -2417,7 +2417,6 @@
.pdfViewer .page canvas{
margin:0;
display:block;
}
.pdfViewer .page canvas .structTree{

View file

@ -808,44 +808,8 @@ const LinkTarget = {
PARENT: 3,
TOP: 4
};
function addLinkAttributes(link, {
url,
target,
rel,
enabled = true
} = {}) {
if (!url || typeof url !== "string") {
throw new Error('A valid "url" parameter must provided.');
}
if (enabled) {
link.href = link.title = url;
} else {
link.href = "";
link.title = `Disabled: ${url}`;
link.onclick = () => false;
}
let targetStr = "";
switch (target) {
case LinkTarget.NONE:
break;
case LinkTarget.SELF:
targetStr = "_self";
break;
case LinkTarget.BLANK:
targetStr = "_blank";
break;
case LinkTarget.PARENT:
targetStr = "_parent";
break;
case LinkTarget.TOP:
targetStr = "_top";
break;
}
link.target = targetStr;
link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
}
class PDFLinkService {
#pagesRefCache = new Map();
externalLinkEnabled = true;
constructor({
eventBus,
externalLinkTarget = null,
@ -855,7 +819,6 @@ class PDFLinkService {
this.eventBus = eventBus;
this.externalLinkTarget = externalLinkTarget;
this.externalLinkRel = externalLinkRel;
this.externalLinkEnabled = true;
this._ignoreDestinationZoom = ignoreDestinationZoom;
this.baseUrl = null;
this.pdfDocument = null;
@ -865,7 +828,6 @@ class PDFLinkService {
setDocument(pdfDocument, baseUrl = null) {
this.baseUrl = baseUrl;
this.pdfDocument = pdfDocument;
this.#pagesRefCache.clear();
}
setViewer(pdfViewer) {
this.pdfViewer = pdfViewer;
@ -877,42 +839,56 @@ class PDFLinkService {
return this.pdfDocument ? this.pdfDocument.numPages : 0;
}
get page() {
return this.pdfViewer.currentPageNumber;
return this.pdfDocument ? this.pdfViewer.currentPageNumber : 1;
}
set page(value) {
this.pdfViewer.currentPageNumber = value;
if (this.pdfDocument) {
this.pdfViewer.currentPageNumber = value;
}
}
get rotation() {
return this.pdfViewer.pagesRotation;
return this.pdfDocument ? this.pdfViewer.pagesRotation : 0;
}
set rotation(value) {
this.pdfViewer.pagesRotation = value;
if (this.pdfDocument) {
this.pdfViewer.pagesRotation = value;
}
}
get isInPresentationMode() {
return this.pdfViewer.isInPresentationMode;
return this.pdfDocument ? this.pdfViewer.isInPresentationMode : false;
}
#goToDestinationHelper(rawDest, namedDest = null, explicitDest) {
const destRef = explicitDest[0];
let pageNumber;
if (typeof destRef === "object" && destRef !== null) {
pageNumber = this._cachedPageNumber(destRef);
async goToDestination(dest) {
if (!this.pdfDocument) {
return;
}
let namedDest, explicitDest, pageNumber;
if (typeof dest === "string") {
namedDest = dest;
explicitDest = await this.pdfDocument.getDestination(dest);
} else {
namedDest = null;
explicitDest = await dest;
}
if (!Array.isArray(explicitDest)) {
console.error(`goToDestination: "${explicitDest}" is not a valid destination array, for dest="${dest}".`);
return;
}
const [destRef] = explicitDest;
if (destRef && typeof destRef === "object") {
pageNumber = this.pdfDocument.cachedPageNumber(destRef);
if (!pageNumber) {
this.pdfDocument.getPageIndex(destRef).then(pageIndex => {
this.cachePageRef(pageIndex + 1, destRef);
this.#goToDestinationHelper(rawDest, namedDest, explicitDest);
}).catch(() => {
console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid page reference, for dest="${rawDest}".`);
});
return;
try {
pageNumber = (await this.pdfDocument.getPageIndex(destRef)) + 1;
} catch {
console.error(`goToDestination: "${destRef}" is not a valid page reference, for dest="${dest}".`);
return;
}
}
} else if (Number.isInteger(destRef)) {
pageNumber = destRef + 1;
} else {
console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid destination reference, for dest="${rawDest}".`);
return;
}
if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
console.error(`PDFLinkService.#goToDestinationHelper: "${pageNumber}" is not ` + `a valid page number, for dest="${rawDest}".`);
console.error(`goToDestination: "${pageNumber}" is not a valid page number, for dest="${dest}".`);
return;
}
if (this.pdfHistory) {
@ -929,24 +905,6 @@ class PDFLinkService {
ignoreDestinationZoom: this._ignoreDestinationZoom
});
}
async goToDestination(dest) {
if (!this.pdfDocument) {
return;
}
let namedDest, explicitDest;
if (typeof dest === "string") {
namedDest = dest;
explicitDest = await this.pdfDocument.getDestination(dest);
} else {
namedDest = null;
explicitDest = await dest;
}
if (!Array.isArray(explicitDest)) {
console.error(`PDFLinkService.goToDestination: "${explicitDest}" is not ` + `a valid destination array, for dest="${dest}".`);
return;
}
this.#goToDestinationHelper(dest, namedDest, explicitDest);
}
goToPage(val) {
if (!this.pdfDocument) {
return;
@ -965,12 +923,37 @@ class PDFLinkService {
});
}
addLinkAttributes(link, url, newWindow = false) {
addLinkAttributes(link, {
url,
target: newWindow ? LinkTarget.BLANK : this.externalLinkTarget,
rel: this.externalLinkRel,
enabled: this.externalLinkEnabled
});
if (!url || typeof url !== "string") {
throw new Error('A valid "url" parameter must provided.');
}
const target = newWindow ? LinkTarget.BLANK : this.externalLinkTarget,
rel = this.externalLinkRel;
if (this.externalLinkEnabled) {
link.href = link.title = url;
} else {
link.href = "";
link.title = `Disabled: ${url}`;
link.onclick = () => false;
}
let targetStr = "";
switch (target) {
case LinkTarget.NONE:
break;
case LinkTarget.SELF:
targetStr = "_self";
break;
case LinkTarget.BLANK:
targetStr = "_blank";
break;
case LinkTarget.PARENT:
targetStr = "_parent";
break;
case LinkTarget.TOP:
targetStr = "_top";
break;
}
link.target = targetStr;
link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
}
getDestinationHash(dest) {
if (typeof dest === "string") {
@ -1071,6 +1054,9 @@ class PDFLinkService {
console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not a valid destination.`);
}
executeNamedAction(action) {
if (!this.pdfDocument) {
return;
}
switch (action) {
case "GoBack":
this.pdfHistory?.back();
@ -1099,28 +1085,17 @@ class PDFLinkService {
});
}
async executeSetOCGState(action) {
const pdfDocument = this.pdfDocument;
const optionalContentConfig = await this.pdfViewer.optionalContentConfigPromise;
if (!this.pdfDocument) {
return;
}
const pdfDocument = this.pdfDocument,
optionalContentConfig = await this.pdfViewer.optionalContentConfigPromise;
if (pdfDocument !== this.pdfDocument) {
return;
}
optionalContentConfig.setOCGState(action);
this.pdfViewer.optionalContentConfigPromise = Promise.resolve(optionalContentConfig);
}
cachePageRef(pageNum, pageRef) {
if (!pageRef) {
return;
}
const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
this.#pagesRefCache.set(refStr, pageNum);
}
_cachedPageNumber(pageRef) {
if (!pageRef) {
return null;
}
const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
return this.#pagesRefCache.get(refStr) || null;
}
static #isValidExplicitDest(dest) {
if (!Array.isArray(dest) || dest.length < 2) {
return false;
@ -1167,42 +1142,8 @@ class PDFLinkService {
return true;
}
}
class SimpleLinkService {
constructor() {
this.externalLinkEnabled = true;
}
get pagesCount() {
return 0;
}
get page() {
return 0;
}
set page(value) {}
get rotation() {
return 0;
}
set rotation(value) {}
get isInPresentationMode() {
return false;
}
async goToDestination(dest) {}
goToPage(val) {}
addLinkAttributes(link, url, newWindow = false) {
addLinkAttributes(link, {
url,
enabled: this.externalLinkEnabled
});
}
getDestinationHash(dest) {
return "#";
}
getAnchorUrl(hash) {
return "#";
}
setHash(hash) {}
executeNamedAction(action) {}
executeSetOCGState(action) {}
cachePageRef(pageNum, pageRef) {}
class SimpleLinkService extends PDFLinkService {
setDocument(pdfDocument, baseUrl = null) {}
}
;// CONCATENATED MODULE: ./web/pdfjs.js
@ -2663,8 +2604,12 @@ class PDFAttachmentViewer extends BaseTreeViewer {
}
_bindLink(element, {
content,
description,
filename
}) {
if (description) {
element.title = description;
}
element.onclick = () => {
this.downloadManager.openOrDownloadData(content, filename);
return false;
@ -2687,12 +2632,14 @@ class PDFAttachmentViewer extends BaseTreeViewer {
for (const name in attachments) {
const item = attachments[name];
const content = item.content,
description = item.description,
filename = getFilenameFromUrl(item.filename, true);
const div = document.createElement("div");
div.className = "treeItem";
const element = document.createElement("a");
this._bindLink(element, {
content,
description,
filename
});
element.textContent = this._normalizeTextContent(filename);
@ -2704,7 +2651,8 @@ class PDFAttachmentViewer extends BaseTreeViewer {
}
#appendAttachment({
filename,
content
content,
description
}) {
const renderedPromise = this._renderedCapability.promise;
renderedPromise.then(() => {
@ -2719,7 +2667,8 @@ class PDFAttachmentViewer extends BaseTreeViewer {
}
attachments[filename] = {
filename,
content
content,
description
};
this.render({
attachments,
@ -4954,17 +4903,8 @@ class PDFOutlineViewer extends BaseTreeViewer {
}
if (Array.isArray(explicitDest)) {
const [destRef] = explicitDest;
if (typeof destRef === "object" && destRef !== null) {
pageNumber = this.linkService._cachedPageNumber(destRef);
if (!pageNumber) {
try {
pageNumber = (await pdfDocument.getPageIndex(destRef)) + 1;
if (pdfDocument !== this._pdfDocument) {
return null;
}
this.linkService.cachePageRef(pageNumber, destRef);
} catch {}
}
if (destRef && typeof destRef === "object") {
pageNumber = pdfDocument.cachedPageNumber(destRef);
} else if (Number.isInteger(destRef)) {
pageNumber = destRef + 1;
}
@ -8514,7 +8454,7 @@ class PDFViewer {
#scaleTimeoutId = null;
#textLayerMode = TextLayerMode.ENABLE;
constructor(options) {
const viewerVersion = "4.2.55";
const viewerVersion = "4.3.8";
if (version !== viewerVersion) {
throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`);
}
@ -8944,11 +8884,7 @@ class PDFViewer {
});
this._pages.push(pageView);
}
const firstPageView = this._pages[0];
if (firstPageView) {
firstPageView.setPdfPage(firstPdfPage);
this.linkService.cachePageRef(1, firstPdfPage.ref);
}
this._pages[0]?.setPdfPage(firstPdfPage);
if (this._scrollMode === ScrollMode.PAGE) {
this.#ensurePageViewVisible();
} else if (this._spreadMode !== SpreadMode.NONE) {
@ -8982,7 +8918,6 @@ class PDFViewer {
if (!pageView.pdfPage) {
pageView.setPdfPage(pdfPage);
}
this.linkService.cachePageRef(pageNum, pdfPage.ref);
if (--getPagesLeft === 0) {
this._pagesCapability.resolve();
}
@ -9489,9 +9424,6 @@ class PDFViewer {
if (!pageView.pdfPage) {
pageView.setPdfPage(pdfPage);
}
if (!this.linkService._cachedPageNumber?.(pdfPage.ref)) {
this.linkService.cachePageRef(pageView.id, pdfPage.ref);
}
return pdfPage;
} catch (reason) {
console.error("Unable to get page for page view", reason);
@ -12732,8 +12664,8 @@ function webViewerReportTelemetry({
const pdfjsVersion = "4.2.55";
const pdfjsBuild = "85e64b5c1";
const pdfjsVersion = "4.3.8";
const pdfjsBuild = "c419c8333";
const AppConstants = null;
window.PDFViewerApplication = PDFViewerApplication;
window.PDFViewerApplicationConstants = AppConstants;

View file

@ -20,8 +20,8 @@ origin:
# Human-readable identifier for this version/release
# Generally "version NNN", "tag SSS", "bookmark SSS"
release: 85e64b5c16c9aaef738f421733c12911a441cec6 (2024-04-28T21:27:47Z).
revision: 85e64b5c16c9aaef738f421733c12911a441cec6
release: c419c8333b1b509fe90242135d9594aa026a8724 (2024-05-02T12:41:02Z).
revision: c419c8333b1b509fe90242135d9594aa026a8724
# The package's license, where possible using the mnemonic from
# https://spdx.org/licenses/