@poe-platform/safe-bash 0.1.780 → 0.1.782
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/dist/image-ast/index.browser.js +200 -165
- package/dist/image-ast/index.js +200 -165
- package/dist/pdf-ast/index.js +200 -165
- package/dist/safe-bash/command-chunks/{chunk-ZY6PMCW5.js → chunk-ADBFNLLK.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-QLYJUVVM.js → chunk-GBHSE6ZO.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3444RZLY.js → chunk-GZXLPWT5.js} +200 -165
- package/dist/safe-bash-command-ffmpeg/index.js +5745 -5715
- package/dist/safe-bash-command-imagemagick/index.js +2 -2
- package/dist/safe-bash-command-pandoc/command.js +3 -3
- package/dist/safe-bash-command-pandoc/index.js +3 -3
- package/dist/safe-bash-command-pdfimages/index.js +200 -165
- package/dist/safe-bash-command-pdfinfo/index.js +200 -165
- package/dist/safe-bash-command-pdftk/index.js +200 -165
- package/dist/safe-bash-command-pdftoppm/index.js +200 -165
- package/dist/safe-bash-command-pdftotext/index.js +200 -165
- package/dist/safe-bash-command-qpdf/index.js +200 -165
- package/dist/safe-bash-command-sips/index.js +2 -2
- package/dist/safe-bash-command-soffice/index.js +1 -1
- package/dist/safe-bash-command-ssconvert/index.js +200 -165
- package/dist/safe-bash-command-wkhtmltopdf/index.js +201 -165
- package/package.json +2 -2
- package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +73 -5
package/dist/pdf-ast/index.js
CHANGED
|
@@ -26881,7 +26881,7 @@ function cosString(value, span) {
|
|
|
26881
26881
|
if (typeof value === "string") {
|
|
26882
26882
|
let needsUtf16 = false;
|
|
26883
26883
|
for (let i = 0; i < value.length; i++) {
|
|
26884
|
-
if (value.charCodeAt(i)
|
|
26884
|
+
if (!PDF_DOC_ENCODING_REVERSE.has(value.charCodeAt(i))) {
|
|
26885
26885
|
needsUtf16 = true;
|
|
26886
26886
|
break;
|
|
26887
26887
|
}
|
|
@@ -26899,7 +26899,7 @@ function cosString(value, span) {
|
|
|
26899
26899
|
}
|
|
26900
26900
|
const bytes = new Uint8Array(value.length);
|
|
26901
26901
|
for (let i = 0; i < value.length; i++) {
|
|
26902
|
-
bytes[i] = value.charCodeAt(i)
|
|
26902
|
+
bytes[i] = PDF_DOC_ENCODING_REVERSE.get(value.charCodeAt(i));
|
|
26903
26903
|
}
|
|
26904
26904
|
return { kind: "string", format: "literal", bytes, span };
|
|
26905
26905
|
}
|
|
@@ -27046,6 +27046,9 @@ var PDF_DOC_ENCODING_MAP = {
|
|
|
27046
27046
|
160: 8364,
|
|
27047
27047
|
173: 65533
|
|
27048
27048
|
};
|
|
27049
|
+
var PDF_DOC_ENCODING_REVERSE = new Map(
|
|
27050
|
+
Array.from({ length: 256 }, (_, byte) => [PDF_DOC_ENCODING_MAP[byte] ?? byte, byte])
|
|
27051
|
+
);
|
|
27049
27052
|
function decodeUtf16UnitsWithSurrogateCheck(units) {
|
|
27050
27053
|
let out = "";
|
|
27051
27054
|
for (let i = 0; i < units.length; i++) {
|
|
@@ -27339,6 +27342,7 @@ var CosByteLexer = class {
|
|
|
27339
27342
|
const start = this.pos;
|
|
27340
27343
|
this.pos++;
|
|
27341
27344
|
let depth = 1;
|
|
27345
|
+
let recovery;
|
|
27342
27346
|
const out = [];
|
|
27343
27347
|
while (this.pos < this.end && depth > 0) {
|
|
27344
27348
|
const b = this.bytes[this.pos++];
|
|
@@ -27373,7 +27377,15 @@ var CosByteLexer = class {
|
|
|
27373
27377
|
out.push(b);
|
|
27374
27378
|
} else if (b === 41) {
|
|
27375
27379
|
depth--;
|
|
27376
|
-
if (depth > 0)
|
|
27380
|
+
if (depth > 0) {
|
|
27381
|
+
const next = this.bytes[this.pos];
|
|
27382
|
+
const afterLine = next === 13 && this.bytes[this.pos + 1] === 10 ? this.pos + 2 : this.pos + 1;
|
|
27383
|
+
const delimiter = this.bytes[afterLine];
|
|
27384
|
+
if (!recovery && this.pos + 2 < this.end && (next === 10 || next === 13) && (delimiter === 47 || delimiter === 62)) {
|
|
27385
|
+
recovery = { offset: this.pos, length: out.length };
|
|
27386
|
+
}
|
|
27387
|
+
out.push(b);
|
|
27388
|
+
}
|
|
27377
27389
|
} else if (b === 13) {
|
|
27378
27390
|
if (this.pos < this.end && this.bytes[this.pos] === 10) this.pos++;
|
|
27379
27391
|
out.push(10);
|
|
@@ -27384,6 +27396,10 @@ var CosByteLexer = class {
|
|
|
27384
27396
|
throw new PdfError("E_LIMIT", "PDF literal string exceeds maximum byte length");
|
|
27385
27397
|
}
|
|
27386
27398
|
}
|
|
27399
|
+
if (depth > 0 && recovery) {
|
|
27400
|
+
this.pos = recovery.offset;
|
|
27401
|
+
out.length = recovery.length;
|
|
27402
|
+
}
|
|
27387
27403
|
return {
|
|
27388
27404
|
kind: "string",
|
|
27389
27405
|
bytes: Uint8Array.from(out),
|
|
@@ -39152,6 +39168,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
39152
39168
|
};
|
|
39153
39169
|
const initialState = {
|
|
39154
39170
|
ctm: [1, 0, 0, 1, 0, 0],
|
|
39171
|
+
initialCtm: [1, 0, 0, 1, 0, 0],
|
|
39155
39172
|
strokeColor: { r: 0, g: 0, b: 0 },
|
|
39156
39173
|
fillColor: { r: 0, g: 0, b: 0 },
|
|
39157
39174
|
strokeAlpha: 1,
|
|
@@ -39449,6 +39466,116 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
39449
39466
|
] }], void 0, void 0, resources, activeFonts, depth);
|
|
39450
39467
|
stateStack.pop();
|
|
39451
39468
|
};
|
|
39469
|
+
const paintPattern = (segments, fillRule, resources, activeFonts, depth, mcid, actualText) => {
|
|
39470
|
+
const st = curState(), doc = params.cosDoc;
|
|
39471
|
+
if (!st.fillPatternName || !doc || !resources) return false;
|
|
39472
|
+
if (depth >= 8) throw new PdfError("E_LIMIT", "Pattern nesting exceeds the form depth limit");
|
|
39473
|
+
const patterns = doc.resolveDict(dictGet(resources, "Pattern"));
|
|
39474
|
+
const pattern = patterns && doc.resolve(dictGet(patterns, st.fillPatternName));
|
|
39475
|
+
const dict = pattern?.kind === "stream" ? pattern.dict : pattern?.kind === "dict" ? pattern : void 0;
|
|
39476
|
+
if (!dict) return false;
|
|
39477
|
+
const nums = (key, fallback) => {
|
|
39478
|
+
const array = doc.resolveArray(dictGet(dict, key));
|
|
39479
|
+
return array ? array.items.map((item, i) => {
|
|
39480
|
+
const value = doc.resolve(item);
|
|
39481
|
+
return value?.kind === "number" ? value.value : fallback[i] ?? 0;
|
|
39482
|
+
}) : fallback;
|
|
39483
|
+
};
|
|
39484
|
+
let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
|
|
39485
|
+
const include = (x, y) => {
|
|
39486
|
+
x0 = Math.min(x0, x);
|
|
39487
|
+
y0 = Math.min(y0, y);
|
|
39488
|
+
x1 = Math.max(x1, x);
|
|
39489
|
+
y1 = Math.max(y1, y);
|
|
39490
|
+
};
|
|
39491
|
+
for (const segment of segments) {
|
|
39492
|
+
if (segment.kind === "close") continue;
|
|
39493
|
+
include(segment.x, segment.y);
|
|
39494
|
+
if (segment.kind === "cubic") {
|
|
39495
|
+
include(segment.x1, segment.y1);
|
|
39496
|
+
include(segment.x2, segment.y2);
|
|
39497
|
+
}
|
|
39498
|
+
if (segment.kind === "rect") include(segment.x + segment.width, segment.y + segment.height);
|
|
39499
|
+
}
|
|
39500
|
+
const [originX, originY] = params.origin ?? [0, 0];
|
|
39501
|
+
const clip = st.clipRect ?? [originX, originY, originX + params.width, originY + params.height];
|
|
39502
|
+
const bounds = [Math.max(x0, clip[0]), Math.max(y0, clip[1]), Math.min(x1, clip[2]), Math.min(y1, clip[3])];
|
|
39503
|
+
if (!(bounds[2] > bounds[0] && bounds[3] > bounds[1])) return true;
|
|
39504
|
+
const matrix = multiplyMatrices(nums("Matrix", [1, 0, 0, 1, 0, 0]), st.initialCtm);
|
|
39505
|
+
const type = doc.resolve(dictGet(dict, "PatternType"));
|
|
39506
|
+
stateStack.push({ ...st, clipRect: bounds, clipPaths: [...st.clipPaths ?? [], { segments, fillRule }] });
|
|
39507
|
+
try {
|
|
39508
|
+
if (type?.kind === "number" && type.value === 2) {
|
|
39509
|
+
const shading = doc.resolve(dictGet(dict, "Shading"));
|
|
39510
|
+
const shadingDict = shading?.kind === "stream" ? shading.dict : shading?.kind === "dict" ? shading : void 0;
|
|
39511
|
+
if (!shadingDict) return false;
|
|
39512
|
+
const image = renderShadingDictToImage(
|
|
39513
|
+
doc,
|
|
39514
|
+
shadingDict,
|
|
39515
|
+
matrix,
|
|
39516
|
+
bounds,
|
|
39517
|
+
st.fillAlpha,
|
|
39518
|
+
"PatternShading_" + st.fillPatternName,
|
|
39519
|
+
bounds,
|
|
39520
|
+
shading?.kind === "stream" ? shading : void 0,
|
|
39521
|
+
st.blendMode
|
|
39522
|
+
);
|
|
39523
|
+
if (image) emit({ kind: "image", value: image });
|
|
39524
|
+
return !!image;
|
|
39525
|
+
}
|
|
39526
|
+
if (pattern?.kind !== "stream") return false;
|
|
39527
|
+
const xStepNode = doc.resolve(dictGet(dict, "XStep"));
|
|
39528
|
+
const yStepNode = doc.resolve(dictGet(dict, "YStep"));
|
|
39529
|
+
const xStep = xStepNode?.kind === "number" ? Math.abs(xStepNode.value) : 0;
|
|
39530
|
+
const yStep = yStepNode?.kind === "number" ? Math.abs(yStepNode.value) : 0;
|
|
39531
|
+
const determinant = matrix[0] * matrix[3] - matrix[1] * matrix[2];
|
|
39532
|
+
if (!xStep || !yStep || !determinant) return true;
|
|
39533
|
+
const inverse = [
|
|
39534
|
+
matrix[3] / determinant,
|
|
39535
|
+
-matrix[1] / determinant,
|
|
39536
|
+
-matrix[2] / determinant,
|
|
39537
|
+
matrix[0] / determinant,
|
|
39538
|
+
(matrix[2] * matrix[5] - matrix[3] * matrix[4]) / determinant,
|
|
39539
|
+
(matrix[1] * matrix[4] - matrix[0] * matrix[5]) / determinant
|
|
39540
|
+
];
|
|
39541
|
+
const corners = [[bounds[0], bounds[1]], [bounds[2], bounds[1]], [bounds[2], bounds[3]], [bounds[0], bounds[3]]].map(([x, y]) => transformPoint(inverse, x, y));
|
|
39542
|
+
const box = nums("BBox", [0, 0, xStep, yStep]);
|
|
39543
|
+
const ix0 = Math.floor((Math.min(...corners.map((p) => p[0])) - box[2]) / xStep) + 1;
|
|
39544
|
+
const ix1 = Math.ceil((Math.max(...corners.map((p) => p[0])) - box[0]) / xStep) - 1;
|
|
39545
|
+
const iy0 = Math.floor((Math.min(...corners.map((p) => p[1])) - box[3]) / yStep) + 1;
|
|
39546
|
+
const iy1 = Math.ceil((Math.max(...corners.map((p) => p[1])) - box[1]) / yStep) - 1;
|
|
39547
|
+
if ((ix1 - ix0 + 1) * (iy1 - iy0 + 1) > 2e4) throw new PdfError("E_LIMIT", "Pattern tile count exceeds 20000");
|
|
39548
|
+
const nodes = parseContentStream(doc.decodeStream(pattern));
|
|
39549
|
+
const patternResources = doc.resolveDict(dictGet(dict, "Resources")) ?? resources;
|
|
39550
|
+
const patternFonts = new Map(activeFonts);
|
|
39551
|
+
for (const [key, font] of resolvePageFonts(doc, patternResources)) patternFonts.set(key, font);
|
|
39552
|
+
for (let iy = iy0; iy <= iy1; iy++) {
|
|
39553
|
+
for (let ix = ix0; ix <= ix1; ix++) {
|
|
39554
|
+
const tileCtm = multiplyMatrices([1, 0, 0, 1, ix * xStep, iy * yStep], matrix);
|
|
39555
|
+
const points = [[box[0], box[1]], [box[2], box[1]], [box[2], box[3]], [box[0], box[3]]].map(([x, y]) => transformPoint(tileCtm, x, y));
|
|
39556
|
+
const tileClip = [
|
|
39557
|
+
...points.map(([x, y], i) => ({ kind: i === 0 ? "move" : "line", x, y })),
|
|
39558
|
+
{ kind: "close" }
|
|
39559
|
+
];
|
|
39560
|
+
stateStack.push({
|
|
39561
|
+
...curState(),
|
|
39562
|
+
fillPatternName: void 0,
|
|
39563
|
+
ctm: tileCtm,
|
|
39564
|
+
initialCtm: tileCtm,
|
|
39565
|
+
clipPaths: [...curState().clipPaths ?? [], tileClip]
|
|
39566
|
+
});
|
|
39567
|
+
try {
|
|
39568
|
+
walkNodes(nodes, mcid, actualText, patternResources, patternFonts, depth + 1);
|
|
39569
|
+
} finally {
|
|
39570
|
+
stateStack.pop();
|
|
39571
|
+
}
|
|
39572
|
+
}
|
|
39573
|
+
}
|
|
39574
|
+
return true;
|
|
39575
|
+
} finally {
|
|
39576
|
+
stateStack.pop();
|
|
39577
|
+
}
|
|
39578
|
+
};
|
|
39452
39579
|
const paintForm = (form, activeResources, activeFonts, depth, mcid, actualText, maskGroup = false) => {
|
|
39453
39580
|
const st = curState();
|
|
39454
39581
|
const group = params.cosDoc.resolveDict(dictGet(form.dict, "Group"));
|
|
@@ -39507,7 +39634,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
39507
39634
|
}
|
|
39508
39635
|
const parentOperations = capturedOperations;
|
|
39509
39636
|
const children = [];
|
|
39510
|
-
const nextState = { ...st, ctm: nextCtm };
|
|
39637
|
+
const nextState = { ...st, ctm: nextCtm, initialCtm: nextCtm };
|
|
39511
39638
|
if (compositeGroup) {
|
|
39512
39639
|
capturedOperations = children;
|
|
39513
39640
|
nextState.fillAlpha = nextState.strokeAlpha = 1;
|
|
@@ -39665,136 +39792,15 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
39665
39792
|
}
|
|
39666
39793
|
const isFill = ["f", "F", "f*", "B", "B*", "b", "b*"].includes(node.paint);
|
|
39667
39794
|
const isStroke = ["S", "s", "B", "B*", "b", "b*"].includes(node.paint);
|
|
39668
|
-
|
|
39669
|
-
|
|
39670
|
-
|
|
39671
|
-
|
|
39672
|
-
|
|
39673
|
-
|
|
39674
|
-
|
|
39675
|
-
|
|
39676
|
-
|
|
39677
|
-
for (const s of transformedSegments) {
|
|
39678
|
-
if (s.kind === "move" || s.kind === "line") {
|
|
39679
|
-
pMinX = Math.min(pMinX, s.x);
|
|
39680
|
-
pMinY = Math.min(pMinY, s.y);
|
|
39681
|
-
pMaxX = Math.max(pMaxX, s.x);
|
|
39682
|
-
pMaxY = Math.max(pMaxY, s.y);
|
|
39683
|
-
} else if (s.kind === "cubic") {
|
|
39684
|
-
pMinX = Math.min(pMinX, s.x1, s.x2, s.x);
|
|
39685
|
-
pMinY = Math.min(pMinY, s.y1, s.y2, s.y);
|
|
39686
|
-
pMaxX = Math.max(pMaxX, s.x1, s.x2, s.x);
|
|
39687
|
-
pMaxY = Math.max(pMaxY, s.y1, s.y2, s.y);
|
|
39688
|
-
} else if (s.kind === "rect") {
|
|
39689
|
-
pMinX = Math.min(pMinX, s.x);
|
|
39690
|
-
pMinY = Math.min(pMinY, s.y);
|
|
39691
|
-
pMaxX = Math.max(pMaxX, s.x + s.width);
|
|
39692
|
-
pMaxY = Math.max(pMaxY, s.y + s.height);
|
|
39693
|
-
}
|
|
39694
|
-
}
|
|
39695
|
-
if (Number.isFinite(pMinX) && Number.isFinite(pMinY) && pMaxX > pMinX && pMaxY > pMinY) {
|
|
39696
|
-
const shading = params.cosDoc.resolve(dictGet(patDict, "Shading"));
|
|
39697
|
-
const shDict = shading?.kind === "stream" ? shading.dict : shading?.kind === "dict" ? shading : void 0;
|
|
39698
|
-
if (shDict) {
|
|
39699
|
-
let patMatrix = [1, 0, 0, 1, 0, 0];
|
|
39700
|
-
const pmArr = params.cosDoc.resolveArray(dictGet(patDict, "Matrix"));
|
|
39701
|
-
if (pmArr && pmArr.items.length >= 6) {
|
|
39702
|
-
const mn = (idx, fb = 0) => {
|
|
39703
|
-
const r = params.cosDoc.resolve(pmArr.items[idx]);
|
|
39704
|
-
return r?.kind === "number" ? r.value : fb;
|
|
39705
|
-
};
|
|
39706
|
-
patMatrix = [mn(0, 1), mn(1, 0), mn(2, 0), mn(3, 1), mn(4, 0), mn(5, 0)];
|
|
39707
|
-
}
|
|
39708
|
-
const patClip = st.clipRect ? [
|
|
39709
|
-
Math.max(st.clipRect[0], pMinX),
|
|
39710
|
-
Math.max(st.clipRect[1], pMinY),
|
|
39711
|
-
Math.min(st.clipRect[2], pMaxX),
|
|
39712
|
-
Math.min(st.clipRect[3], pMaxY)
|
|
39713
|
-
] : [pMinX, pMinY, pMaxX, pMaxY];
|
|
39714
|
-
const shImg = renderShadingDictToImage(
|
|
39715
|
-
params.cosDoc,
|
|
39716
|
-
shDict,
|
|
39717
|
-
patMatrix,
|
|
39718
|
-
patClip,
|
|
39719
|
-
st.fillAlpha,
|
|
39720
|
-
"PatternShading_" + st.fillPatternName,
|
|
39721
|
-
patClip,
|
|
39722
|
-
shading?.kind === "stream" ? shading : void 0,
|
|
39723
|
-
st.blendMode
|
|
39724
|
-
);
|
|
39725
|
-
if (shImg) {
|
|
39726
|
-
emit({ kind: "image", value: shImg });
|
|
39727
|
-
evaluatedFillPattern = true;
|
|
39728
|
-
}
|
|
39729
|
-
}
|
|
39730
|
-
}
|
|
39731
|
-
} else if (patNode?.kind === "stream") {
|
|
39732
|
-
let pMinX = Infinity, pMinY = Infinity, pMaxX = -Infinity, pMaxY = -Infinity;
|
|
39733
|
-
for (const s of transformedSegments) {
|
|
39734
|
-
if (s.kind === "move" || s.kind === "line") {
|
|
39735
|
-
pMinX = Math.min(pMinX, s.x);
|
|
39736
|
-
pMinY = Math.min(pMinY, s.y);
|
|
39737
|
-
pMaxX = Math.max(pMaxX, s.x);
|
|
39738
|
-
pMaxY = Math.max(pMaxY, s.y);
|
|
39739
|
-
} else if (s.kind === "cubic") {
|
|
39740
|
-
pMinX = Math.min(pMinX, s.x1, s.x2, s.x);
|
|
39741
|
-
pMinY = Math.min(pMinY, s.y1, s.y2, s.y);
|
|
39742
|
-
pMaxX = Math.max(pMaxX, s.x1, s.x2, s.x);
|
|
39743
|
-
pMaxY = Math.max(pMaxY, s.y1, s.y2, s.y);
|
|
39744
|
-
} else if (s.kind === "rect") {
|
|
39745
|
-
pMinX = Math.min(pMinX, s.x);
|
|
39746
|
-
pMinY = Math.min(pMinY, s.y);
|
|
39747
|
-
pMaxX = Math.max(pMaxX, s.x + s.width);
|
|
39748
|
-
pMaxY = Math.max(pMaxY, s.y + s.height);
|
|
39749
|
-
}
|
|
39750
|
-
}
|
|
39751
|
-
if (Number.isFinite(pMinX) && Number.isFinite(pMinY) && pMaxX > pMinX && pMaxY > pMinY) {
|
|
39752
|
-
const xsNode = params.cosDoc.resolve(dictGet(patNode.dict, "XStep"));
|
|
39753
|
-
const ysNode = params.cosDoc.resolve(dictGet(patNode.dict, "YStep"));
|
|
39754
|
-
const xStep = xsNode?.kind === "number" && Math.abs(xsNode.value) > 1e-3 ? Math.abs(xsNode.value) : 40;
|
|
39755
|
-
const yStep = ysNode?.kind === "number" && Math.abs(ysNode.value) > 1e-3 ? Math.abs(ysNode.value) : 40;
|
|
39756
|
-
let patMatrix = [1, 0, 0, 1, 0, 0];
|
|
39757
|
-
const pmArr = params.cosDoc.resolveArray(dictGet(patNode.dict, "Matrix"));
|
|
39758
|
-
if (pmArr && pmArr.items.length >= 6) {
|
|
39759
|
-
const mn = (idx, fb = 0) => {
|
|
39760
|
-
const r = params.cosDoc.resolve(pmArr.items[idx]);
|
|
39761
|
-
return r?.kind === "number" ? r.value : fb;
|
|
39762
|
-
};
|
|
39763
|
-
patMatrix = [mn(0, 1), mn(1, 0), mn(2, 0), mn(3, 1), mn(4, 0), mn(5, 0)];
|
|
39764
|
-
}
|
|
39765
|
-
const tileClip = st.clipRect ? [
|
|
39766
|
-
Math.max(st.clipRect[0], pMinX),
|
|
39767
|
-
Math.max(st.clipRect[1], pMinY),
|
|
39768
|
-
Math.min(st.clipRect[2], pMaxX),
|
|
39769
|
-
Math.min(st.clipRect[3], pMaxY)
|
|
39770
|
-
] : [pMinX, pMinY, pMaxX, pMaxY];
|
|
39771
|
-
const patNodes = parseContentStream(params.cosDoc.decodeStream(patNode));
|
|
39772
|
-
const patResDict = params.cosDoc.resolveDict(dictGet(patNode.dict, "Resources")) ?? activeResources;
|
|
39773
|
-
const patFonts = new Map(activeFonts);
|
|
39774
|
-
for (const [fk, fv] of resolvePageFonts(params.cosDoc, patResDict).entries()) {
|
|
39775
|
-
patFonts.set(fk, fv);
|
|
39776
|
-
}
|
|
39777
|
-
const ixStart = Math.floor(pMinX / xStep);
|
|
39778
|
-
const ixEnd = Math.min(ixStart + 8, Math.ceil(pMaxX / xStep) - 1);
|
|
39779
|
-
const iyStart = Math.floor(pMinY / yStep);
|
|
39780
|
-
const iyEnd = Math.min(iyStart + 8, Math.ceil(pMaxY / yStep) - 1);
|
|
39781
|
-
for (let iy = iyStart; iy <= iyEnd; iy++) {
|
|
39782
|
-
for (let ix = ixStart; ix <= ixEnd; ix++) {
|
|
39783
|
-
const tileCtm = multiplyMatrices([1, 0, 0, 1, ix * xStep, iy * yStep], patMatrix);
|
|
39784
|
-
stateStack.push({
|
|
39785
|
-
...st,
|
|
39786
|
-
fillPatternName: void 0,
|
|
39787
|
-
ctm: tileCtm,
|
|
39788
|
-
clipRect: tileClip
|
|
39789
|
-
});
|
|
39790
|
-
walkNodes(patNodes, mcid, actualText, patResDict, patFonts, depth + 1);
|
|
39791
|
-
if (stateStack.length > 1) stateStack.pop();
|
|
39792
|
-
}
|
|
39793
|
-
}
|
|
39794
|
-
evaluatedFillPattern = true;
|
|
39795
|
-
}
|
|
39796
|
-
}
|
|
39797
|
-
}
|
|
39795
|
+
const evaluatedFillPattern = isFill && paintPattern(
|
|
39796
|
+
transformedSegments,
|
|
39797
|
+
node.paint.includes("*") ? "evenodd" : "nonzero",
|
|
39798
|
+
activeResources,
|
|
39799
|
+
activeFonts,
|
|
39800
|
+
depth,
|
|
39801
|
+
mcid,
|
|
39802
|
+
actualText
|
|
39803
|
+
);
|
|
39798
39804
|
if (evaluatedFillPattern && !isStroke) {
|
|
39799
39805
|
applyClip();
|
|
39800
39806
|
break;
|
|
@@ -39995,10 +40001,19 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
39995
40001
|
if (st.textRenderMode >= 4 && st.textRenderMode <= 7) pendingTextClip.push(...transformedGlyphSegs);
|
|
39996
40002
|
const isFillGlyph = st.textRenderMode === 0 || st.textRenderMode === 2 || st.textRenderMode === 4 || st.textRenderMode === 6;
|
|
39997
40003
|
const isStrokeGlyph = st.textRenderMode === 1 || st.textRenderMode === 2 || st.textRenderMode === 5 || st.textRenderMode === 6;
|
|
40004
|
+
const patterned = isFillGlyph && paintPattern(
|
|
40005
|
+
transformedGlyphSegs,
|
|
40006
|
+
"nonzero",
|
|
40007
|
+
activeResources,
|
|
40008
|
+
activeFonts,
|
|
40009
|
+
depth,
|
|
40010
|
+
mcid,
|
|
40011
|
+
actualText
|
|
40012
|
+
);
|
|
39998
40013
|
const paint = {
|
|
39999
40014
|
segments: transformedGlyphSegs,
|
|
40000
|
-
fillColor: isFillGlyph ? st.fillColor : void 0,
|
|
40001
|
-
fillAlpha: isFillGlyph ? st.fillAlpha : void 0,
|
|
40015
|
+
fillColor: isFillGlyph && !patterned ? st.fillColor : void 0,
|
|
40016
|
+
fillAlpha: isFillGlyph && !patterned ? st.fillAlpha : void 0,
|
|
40002
40017
|
strokeColor: isStrokeGlyph ? st.strokeColor : void 0,
|
|
40003
40018
|
strokeAlpha: isStrokeGlyph ? st.strokeAlpha : void 0,
|
|
40004
40019
|
strokeWidth: isStrokeGlyph ? st.strokeWidth : 0,
|
|
@@ -44335,10 +44350,14 @@ function computePdfBlendRgb(cbR, cbG, cbB, csR, csG, csB, mode) {
|
|
|
44335
44350
|
blendChannelSeparable(cbB, csB, mode)
|
|
44336
44351
|
];
|
|
44337
44352
|
}
|
|
44338
|
-
function blendPixel(rgba, width, height, px, py, color, alpha, blendMode, clipMask) {
|
|
44353
|
+
function blendPixel(rgba, width, height, px, py, color, alpha, blendMode, clipMask, groupAlpha) {
|
|
44339
44354
|
if (px < 0 || py < 0 || px >= width || py >= height || alpha <= 0) return;
|
|
44340
44355
|
const a = Math.min(1, Math.max(0, alpha)) * (clipMask ? clipMask[(py * width + px) * 4 + 3] / 255 : 1);
|
|
44341
44356
|
const idx = (py * width + px) * 4;
|
|
44357
|
+
if (groupAlpha) {
|
|
44358
|
+
const pixel = py * width + px;
|
|
44359
|
+
groupAlpha[pixel] = a + groupAlpha[pixel] * (1 - a);
|
|
44360
|
+
}
|
|
44342
44361
|
const csR = Math.min(1, Math.max(0, color.r));
|
|
44343
44362
|
const csG = Math.min(1, Math.max(0, color.g));
|
|
44344
44363
|
const csB = Math.min(1, Math.max(0, color.b));
|
|
@@ -44470,7 +44489,7 @@ function pathsToEdges(paths, closeSubpaths = false) {
|
|
|
44470
44489
|
}
|
|
44471
44490
|
return edges;
|
|
44472
44491
|
}
|
|
44473
|
-
function fillEdgesScanline4x4(rgba, width, height, edges, color, alpha = 1, fillRule = "nonzero", clipScreen, antialias = true, blendMode, clipMask) {
|
|
44492
|
+
function fillEdgesScanline4x4(rgba, width, height, edges, color, alpha = 1, fillRule = "nonzero", clipScreen, antialias = true, blendMode, clipMask, groupAlpha) {
|
|
44474
44493
|
if (edges.length === 0) return;
|
|
44475
44494
|
let minY = Infinity;
|
|
44476
44495
|
let maxY = -Infinity;
|
|
@@ -44536,7 +44555,7 @@ function fillEdgesScanline4x4(rgba, width, height, edges, color, alpha = 1, fill
|
|
|
44536
44555
|
const count = rowCounts[px];
|
|
44537
44556
|
if (count > 0) {
|
|
44538
44557
|
const cov = antialias ? count / 16 : count >= 8 ? 1 : 0;
|
|
44539
|
-
blendPixel(rgba, width, height, px, py, color, cov * alpha, blendMode, clipMask);
|
|
44558
|
+
blendPixel(rgba, width, height, px, py, color, cov * alpha, blendMode, clipMask, groupAlpha);
|
|
44540
44559
|
}
|
|
44541
44560
|
}
|
|
44542
44561
|
}
|
|
@@ -44615,22 +44634,19 @@ function hasCompositingEffects(operations, includeSoftMasks = false) {
|
|
|
44615
44634
|
return operations.some((operation) => includeSoftMasks && !!operation.value.softMask || !!operation.value.blendMode && operation.value.blendMode !== "Normal" && operation.value.blendMode !== "Compatible" || operation.kind === "group" && hasCompositingEffects(operation.value.operations, includeSoftMasks));
|
|
44616
44635
|
}
|
|
44617
44636
|
function needsGroupBackdrop(group) {
|
|
44618
|
-
return group.isolated === false &&
|
|
44637
|
+
return group.isolated === false && hasCompositingEffects(group.operations, true);
|
|
44619
44638
|
}
|
|
44620
44639
|
function containsBackdropGroup(operations) {
|
|
44621
44640
|
return operations.some((operation) => operation.kind === "group" && (needsGroupBackdrop(operation.value) || containsBackdropGroup(operation.value.operations)));
|
|
44622
44641
|
}
|
|
44623
|
-
function
|
|
44624
|
-
const baseScale = options.scale ?? (options.dpi ? options.dpi / 72 : 1.5);
|
|
44625
|
-
const scaleX = options.dpiX !== void 0 ? options.dpiX / 72 : baseScale;
|
|
44626
|
-
const scaleY = options.dpiY !== void 0 ? options.dpiY / 72 : baseScale;
|
|
44627
|
-
const scale = scaleX;
|
|
44642
|
+
function renderDisplayListLayer(displayList, options, scale, backdrop) {
|
|
44628
44643
|
const [originX, originY] = displayList.origin ?? [0, 0];
|
|
44629
44644
|
const pageTop = originY + displayList.height;
|
|
44630
44645
|
const toScreen = (x, y) => [(x - originX) * scale, (pageTop - y) * scale];
|
|
44631
44646
|
const width = Math.max(1, Math.round(displayList.width * scale));
|
|
44632
44647
|
const height = Math.max(1, Math.round(displayList.height * scale));
|
|
44633
|
-
const rgba = new Uint8Array(width * height * 4);
|
|
44648
|
+
const rgba = backdrop ? backdrop.slice() : new Uint8Array(width * height * 4);
|
|
44649
|
+
const groupAlpha = backdrop ? new Float32Array(width * height) : void 0;
|
|
44634
44650
|
const deferBackground = !options.transparent && hasCompositingEffects(paintOperations(displayList));
|
|
44635
44651
|
const transparent = options.transparent || deferBackground;
|
|
44636
44652
|
const bg = options.background ?? { r: 1, g: 1, b: 1 };
|
|
@@ -44638,7 +44654,7 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
44638
44654
|
const bgG = transparent ? 0 : Math.round(bg.g * 255);
|
|
44639
44655
|
const bgB = transparent ? 0 : Math.round(bg.b * 255);
|
|
44640
44656
|
const bgA = transparent ? 0 : 255;
|
|
44641
|
-
for (let i = 0; i < width * height; i++) {
|
|
44657
|
+
for (let i = 0; !backdrop && i < width * height; i++) {
|
|
44642
44658
|
rgba[i * 4] = bgR;
|
|
44643
44659
|
rgba[i * 4 + 1] = bgG;
|
|
44644
44660
|
rgba[i * 4 + 2] = bgB;
|
|
@@ -44656,20 +44672,12 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
44656
44672
|
let operation = original.kind === "glyph" ? { kind: "path", value: glyphPaint(original.value) } : original;
|
|
44657
44673
|
if (operation.kind === "group") {
|
|
44658
44674
|
const group = operation.value;
|
|
44659
|
-
|
|
44660
|
-
|
|
44661
|
-
|
|
44662
|
-
|
|
44663
|
-
|
|
44664
|
-
|
|
44665
|
-
decodedRgba: rgba.slice(),
|
|
44666
|
-
matrix: [width / scale, 0, 0, height / scale, originX, pageTop - height / scale],
|
|
44667
|
-
colorSpace: "DeviceRGB",
|
|
44668
|
-
bitsPerComponent: 8,
|
|
44669
|
-
...group.bboxClip ? { clipPaths: [group.bboxClip] } : {}
|
|
44670
|
-
} }, ...operations];
|
|
44671
|
-
}
|
|
44672
|
-
const bitmap = renderDisplayListToBitmap({ ...displayList, rotation: 0, operations }, { ...options, scale, dpiX: void 0, dpiY: void 0, cropRect: void 0, useCropBox: false, transparent: true });
|
|
44675
|
+
const bitmap = renderDisplayListLayer(
|
|
44676
|
+
{ ...displayList, operations: group.operations },
|
|
44677
|
+
{ ...options, transparent: true },
|
|
44678
|
+
scale,
|
|
44679
|
+
needsGroupBackdrop(group) ? rgba : void 0
|
|
44680
|
+
);
|
|
44673
44681
|
for (let i = 3; i < bitmap.data.length; i += 4) bitmap.data[i] = Math.round(bitmap.data[i] * group.alpha);
|
|
44674
44682
|
operation = { kind: "image", value: {
|
|
44675
44683
|
name: "TransparencyGroup",
|
|
@@ -44739,7 +44747,7 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
44739
44747
|
if (path.fillColor) {
|
|
44740
44748
|
const edges = pathsToEdges(segmentsToScreenPaths(path.segments, displayList.height, scale, toScreen), true);
|
|
44741
44749
|
const clipScreen = path.clipRect ? [(path.clipRect[0] - originX) * scale, (pageTop - path.clipRect[3]) * scale, (path.clipRect[2] - originX) * scale, (pageTop - path.clipRect[1]) * scale] : void 0;
|
|
44742
|
-
fillEdgesScanline4x4(rgba, width, height, edges, path.fillColor, path.fillAlpha ?? 1, path.fillRule ?? "nonzero", clipScreen, original.kind === "glyph" ? aaTxt : aaVec, path.blendMode, clipMask);
|
|
44750
|
+
fillEdgesScanline4x4(rgba, width, height, edges, path.fillColor, path.fillAlpha ?? 1, path.fillRule ?? "nonzero", clipScreen, original.kind === "glyph" ? aaTxt : aaVec, path.blendMode, clipMask, groupAlpha);
|
|
44743
44751
|
}
|
|
44744
44752
|
if (path.strokeColor) {
|
|
44745
44753
|
const rawSw = path.strokeWidth * scale * (path.strokeMatrix ? Math.hypot(path.strokeMatrix[0], path.strokeMatrix[1]) : 1);
|
|
@@ -44757,7 +44765,8 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
44757
44765
|
clipScreen,
|
|
44758
44766
|
original.kind === "glyph" ? aaTxt : aaVec,
|
|
44759
44767
|
path.blendMode,
|
|
44760
|
-
clipMask
|
|
44768
|
+
clipMask,
|
|
44769
|
+
groupAlpha
|
|
44761
44770
|
);
|
|
44762
44771
|
}
|
|
44763
44772
|
} else if (operation.kind === "image") {
|
|
@@ -44821,12 +44830,31 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
44821
44830
|
},
|
|
44822
44831
|
sample[3] / 255,
|
|
44823
44832
|
img.blendMode,
|
|
44824
|
-
clipMask
|
|
44833
|
+
clipMask,
|
|
44834
|
+
groupAlpha
|
|
44825
44835
|
);
|
|
44826
44836
|
}
|
|
44827
44837
|
}
|
|
44828
44838
|
}
|
|
44829
44839
|
}
|
|
44840
|
+
if (backdrop && groupAlpha) {
|
|
44841
|
+
for (let i = 0; i < rgba.length; i += 4) {
|
|
44842
|
+
const alpha = groupAlpha[i / 4];
|
|
44843
|
+
if (alpha === 0) {
|
|
44844
|
+
rgba.fill(0, i, i + 4);
|
|
44845
|
+
continue;
|
|
44846
|
+
}
|
|
44847
|
+
const factor = backdrop[i + 3] / 255 * (1 / alpha - 1);
|
|
44848
|
+
for (let channel = 0; channel < 3; channel++) {
|
|
44849
|
+
const color = rgba[i + channel];
|
|
44850
|
+
rgba[i + channel] = Math.max(0, Math.min(
|
|
44851
|
+
255,
|
|
44852
|
+
Math.round(color + (color - backdrop[i + channel]) * factor)
|
|
44853
|
+
));
|
|
44854
|
+
}
|
|
44855
|
+
rgba[i + 3] = Math.round(alpha * 255);
|
|
44856
|
+
}
|
|
44857
|
+
}
|
|
44830
44858
|
if (deferBackground) {
|
|
44831
44859
|
for (let i = 0; i < rgba.length; i += 4) {
|
|
44832
44860
|
const alpha = rgba[i + 3] / 255;
|
|
@@ -44836,7 +44864,14 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
44836
44864
|
rgba[i + 3] = 255;
|
|
44837
44865
|
}
|
|
44838
44866
|
}
|
|
44839
|
-
|
|
44867
|
+
return { width, height, data: rgba };
|
|
44868
|
+
}
|
|
44869
|
+
function renderDisplayListToBitmap(displayList, options = {}) {
|
|
44870
|
+
const baseScale = options.scale ?? (options.dpi ? options.dpi / 72 : 1.5);
|
|
44871
|
+
const scaleX = options.dpiX !== void 0 ? options.dpiX / 72 : baseScale;
|
|
44872
|
+
const scaleY = options.dpiY !== void 0 ? options.dpiY / 72 : baseScale;
|
|
44873
|
+
let result = renderDisplayListLayer(displayList, options, scaleX);
|
|
44874
|
+
const { width, height, data: rgba } = result;
|
|
44840
44875
|
if (Math.abs(scaleX - scaleY) > 1e-6) {
|
|
44841
44876
|
const targetW = Math.max(1, Math.round(displayList.width * scaleX));
|
|
44842
44877
|
const targetH = Math.max(1, Math.round(displayList.height * scaleY));
|
|
@@ -48,11 +48,11 @@ import {
|
|
|
48
48
|
trimImage,
|
|
49
49
|
unflattenImage,
|
|
50
50
|
unpremultiplyRgbaImage
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-GBHSE6ZO.js";
|
|
52
52
|
import {
|
|
53
53
|
PdfDocument,
|
|
54
54
|
encodePng
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-GZXLPWT5.js";
|
|
56
56
|
import {
|
|
57
57
|
createLuaFilterCapability
|
|
58
58
|
} from "./chunk-Y2KHC6TZ.js";
|