@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
|
@@ -26566,7 +26566,7 @@ function cosString(value, span) {
|
|
|
26566
26566
|
if (typeof value === "string") {
|
|
26567
26567
|
let needsUtf16 = false;
|
|
26568
26568
|
for (let i = 0; i < value.length; i++) {
|
|
26569
|
-
if (value.charCodeAt(i)
|
|
26569
|
+
if (!PDF_DOC_ENCODING_REVERSE.has(value.charCodeAt(i))) {
|
|
26570
26570
|
needsUtf16 = true;
|
|
26571
26571
|
break;
|
|
26572
26572
|
}
|
|
@@ -26584,7 +26584,7 @@ function cosString(value, span) {
|
|
|
26584
26584
|
}
|
|
26585
26585
|
const bytes = new Uint8Array(value.length);
|
|
26586
26586
|
for (let i = 0; i < value.length; i++) {
|
|
26587
|
-
bytes[i] = value.charCodeAt(i)
|
|
26587
|
+
bytes[i] = PDF_DOC_ENCODING_REVERSE.get(value.charCodeAt(i));
|
|
26588
26588
|
}
|
|
26589
26589
|
return { kind: "string", format: "literal", bytes, span };
|
|
26590
26590
|
}
|
|
@@ -26731,6 +26731,9 @@ var PDF_DOC_ENCODING_MAP = {
|
|
|
26731
26731
|
160: 8364,
|
|
26732
26732
|
173: 65533
|
|
26733
26733
|
};
|
|
26734
|
+
var PDF_DOC_ENCODING_REVERSE = new Map(
|
|
26735
|
+
Array.from({ length: 256 }, (_, byte) => [PDF_DOC_ENCODING_MAP[byte] ?? byte, byte])
|
|
26736
|
+
);
|
|
26734
26737
|
function decodeUtf16UnitsWithSurrogateCheck(units) {
|
|
26735
26738
|
let out = "";
|
|
26736
26739
|
for (let i = 0; i < units.length; i++) {
|
|
@@ -27022,6 +27025,7 @@ var CosByteLexer = class {
|
|
|
27022
27025
|
const start = this.pos;
|
|
27023
27026
|
this.pos++;
|
|
27024
27027
|
let depth = 1;
|
|
27028
|
+
let recovery;
|
|
27025
27029
|
const out = [];
|
|
27026
27030
|
while (this.pos < this.end && depth > 0) {
|
|
27027
27031
|
const b = this.bytes[this.pos++];
|
|
@@ -27056,7 +27060,15 @@ var CosByteLexer = class {
|
|
|
27056
27060
|
out.push(b);
|
|
27057
27061
|
} else if (b === 41) {
|
|
27058
27062
|
depth--;
|
|
27059
|
-
if (depth > 0)
|
|
27063
|
+
if (depth > 0) {
|
|
27064
|
+
const next = this.bytes[this.pos];
|
|
27065
|
+
const afterLine = next === 13 && this.bytes[this.pos + 1] === 10 ? this.pos + 2 : this.pos + 1;
|
|
27066
|
+
const delimiter = this.bytes[afterLine];
|
|
27067
|
+
if (!recovery && this.pos + 2 < this.end && (next === 10 || next === 13) && (delimiter === 47 || delimiter === 62)) {
|
|
27068
|
+
recovery = { offset: this.pos, length: out.length };
|
|
27069
|
+
}
|
|
27070
|
+
out.push(b);
|
|
27071
|
+
}
|
|
27060
27072
|
} else if (b === 13) {
|
|
27061
27073
|
if (this.pos < this.end && this.bytes[this.pos] === 10) this.pos++;
|
|
27062
27074
|
out.push(10);
|
|
@@ -27067,6 +27079,10 @@ var CosByteLexer = class {
|
|
|
27067
27079
|
throw new PdfError("E_LIMIT", "PDF literal string exceeds maximum byte length");
|
|
27068
27080
|
}
|
|
27069
27081
|
}
|
|
27082
|
+
if (depth > 0 && recovery) {
|
|
27083
|
+
this.pos = recovery.offset;
|
|
27084
|
+
out.length = recovery.length;
|
|
27085
|
+
}
|
|
27070
27086
|
return {
|
|
27071
27087
|
kind: "string",
|
|
27072
27088
|
bytes: Uint8Array.from(out),
|
|
@@ -38437,6 +38453,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
38437
38453
|
};
|
|
38438
38454
|
const initialState = {
|
|
38439
38455
|
ctm: [1, 0, 0, 1, 0, 0],
|
|
38456
|
+
initialCtm: [1, 0, 0, 1, 0, 0],
|
|
38440
38457
|
strokeColor: { r: 0, g: 0, b: 0 },
|
|
38441
38458
|
fillColor: { r: 0, g: 0, b: 0 },
|
|
38442
38459
|
strokeAlpha: 1,
|
|
@@ -38734,6 +38751,116 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
38734
38751
|
] }], void 0, void 0, resources, activeFonts, depth);
|
|
38735
38752
|
stateStack.pop();
|
|
38736
38753
|
};
|
|
38754
|
+
const paintPattern = (segments, fillRule, resources, activeFonts, depth, mcid, actualText) => {
|
|
38755
|
+
const st = curState(), doc = params.cosDoc;
|
|
38756
|
+
if (!st.fillPatternName || !doc || !resources) return false;
|
|
38757
|
+
if (depth >= 8) throw new PdfError("E_LIMIT", "Pattern nesting exceeds the form depth limit");
|
|
38758
|
+
const patterns = doc.resolveDict(dictGet(resources, "Pattern"));
|
|
38759
|
+
const pattern = patterns && doc.resolve(dictGet(patterns, st.fillPatternName));
|
|
38760
|
+
const dict = pattern?.kind === "stream" ? pattern.dict : pattern?.kind === "dict" ? pattern : void 0;
|
|
38761
|
+
if (!dict) return false;
|
|
38762
|
+
const nums = (key, fallback) => {
|
|
38763
|
+
const array = doc.resolveArray(dictGet(dict, key));
|
|
38764
|
+
return array ? array.items.map((item, i) => {
|
|
38765
|
+
const value = doc.resolve(item);
|
|
38766
|
+
return value?.kind === "number" ? value.value : fallback[i] ?? 0;
|
|
38767
|
+
}) : fallback;
|
|
38768
|
+
};
|
|
38769
|
+
let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
|
|
38770
|
+
const include = (x, y) => {
|
|
38771
|
+
x0 = Math.min(x0, x);
|
|
38772
|
+
y0 = Math.min(y0, y);
|
|
38773
|
+
x1 = Math.max(x1, x);
|
|
38774
|
+
y1 = Math.max(y1, y);
|
|
38775
|
+
};
|
|
38776
|
+
for (const segment of segments) {
|
|
38777
|
+
if (segment.kind === "close") continue;
|
|
38778
|
+
include(segment.x, segment.y);
|
|
38779
|
+
if (segment.kind === "cubic") {
|
|
38780
|
+
include(segment.x1, segment.y1);
|
|
38781
|
+
include(segment.x2, segment.y2);
|
|
38782
|
+
}
|
|
38783
|
+
if (segment.kind === "rect") include(segment.x + segment.width, segment.y + segment.height);
|
|
38784
|
+
}
|
|
38785
|
+
const [originX, originY] = params.origin ?? [0, 0];
|
|
38786
|
+
const clip = st.clipRect ?? [originX, originY, originX + params.width, originY + params.height];
|
|
38787
|
+
const bounds = [Math.max(x0, clip[0]), Math.max(y0, clip[1]), Math.min(x1, clip[2]), Math.min(y1, clip[3])];
|
|
38788
|
+
if (!(bounds[2] > bounds[0] && bounds[3] > bounds[1])) return true;
|
|
38789
|
+
const matrix = multiplyMatrices(nums("Matrix", [1, 0, 0, 1, 0, 0]), st.initialCtm);
|
|
38790
|
+
const type = doc.resolve(dictGet(dict, "PatternType"));
|
|
38791
|
+
stateStack.push({ ...st, clipRect: bounds, clipPaths: [...st.clipPaths ?? [], { segments, fillRule }] });
|
|
38792
|
+
try {
|
|
38793
|
+
if (type?.kind === "number" && type.value === 2) {
|
|
38794
|
+
const shading = doc.resolve(dictGet(dict, "Shading"));
|
|
38795
|
+
const shadingDict = shading?.kind === "stream" ? shading.dict : shading?.kind === "dict" ? shading : void 0;
|
|
38796
|
+
if (!shadingDict) return false;
|
|
38797
|
+
const image = renderShadingDictToImage(
|
|
38798
|
+
doc,
|
|
38799
|
+
shadingDict,
|
|
38800
|
+
matrix,
|
|
38801
|
+
bounds,
|
|
38802
|
+
st.fillAlpha,
|
|
38803
|
+
"PatternShading_" + st.fillPatternName,
|
|
38804
|
+
bounds,
|
|
38805
|
+
shading?.kind === "stream" ? shading : void 0,
|
|
38806
|
+
st.blendMode
|
|
38807
|
+
);
|
|
38808
|
+
if (image) emit({ kind: "image", value: image });
|
|
38809
|
+
return !!image;
|
|
38810
|
+
}
|
|
38811
|
+
if (pattern?.kind !== "stream") return false;
|
|
38812
|
+
const xStepNode = doc.resolve(dictGet(dict, "XStep"));
|
|
38813
|
+
const yStepNode = doc.resolve(dictGet(dict, "YStep"));
|
|
38814
|
+
const xStep = xStepNode?.kind === "number" ? Math.abs(xStepNode.value) : 0;
|
|
38815
|
+
const yStep = yStepNode?.kind === "number" ? Math.abs(yStepNode.value) : 0;
|
|
38816
|
+
const determinant = matrix[0] * matrix[3] - matrix[1] * matrix[2];
|
|
38817
|
+
if (!xStep || !yStep || !determinant) return true;
|
|
38818
|
+
const inverse = [
|
|
38819
|
+
matrix[3] / determinant,
|
|
38820
|
+
-matrix[1] / determinant,
|
|
38821
|
+
-matrix[2] / determinant,
|
|
38822
|
+
matrix[0] / determinant,
|
|
38823
|
+
(matrix[2] * matrix[5] - matrix[3] * matrix[4]) / determinant,
|
|
38824
|
+
(matrix[1] * matrix[4] - matrix[0] * matrix[5]) / determinant
|
|
38825
|
+
];
|
|
38826
|
+
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));
|
|
38827
|
+
const box = nums("BBox", [0, 0, xStep, yStep]);
|
|
38828
|
+
const ix0 = Math.floor((Math.min(...corners.map((p) => p[0])) - box[2]) / xStep) + 1;
|
|
38829
|
+
const ix1 = Math.ceil((Math.max(...corners.map((p) => p[0])) - box[0]) / xStep) - 1;
|
|
38830
|
+
const iy0 = Math.floor((Math.min(...corners.map((p) => p[1])) - box[3]) / yStep) + 1;
|
|
38831
|
+
const iy1 = Math.ceil((Math.max(...corners.map((p) => p[1])) - box[1]) / yStep) - 1;
|
|
38832
|
+
if ((ix1 - ix0 + 1) * (iy1 - iy0 + 1) > 2e4) throw new PdfError("E_LIMIT", "Pattern tile count exceeds 20000");
|
|
38833
|
+
const nodes = parseContentStream(doc.decodeStream(pattern));
|
|
38834
|
+
const patternResources = doc.resolveDict(dictGet(dict, "Resources")) ?? resources;
|
|
38835
|
+
const patternFonts = new Map(activeFonts);
|
|
38836
|
+
for (const [key, font] of resolvePageFonts(doc, patternResources)) patternFonts.set(key, font);
|
|
38837
|
+
for (let iy = iy0; iy <= iy1; iy++) {
|
|
38838
|
+
for (let ix = ix0; ix <= ix1; ix++) {
|
|
38839
|
+
const tileCtm = multiplyMatrices([1, 0, 0, 1, ix * xStep, iy * yStep], matrix);
|
|
38840
|
+
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));
|
|
38841
|
+
const tileClip = [
|
|
38842
|
+
...points.map(([x, y], i) => ({ kind: i === 0 ? "move" : "line", x, y })),
|
|
38843
|
+
{ kind: "close" }
|
|
38844
|
+
];
|
|
38845
|
+
stateStack.push({
|
|
38846
|
+
...curState(),
|
|
38847
|
+
fillPatternName: void 0,
|
|
38848
|
+
ctm: tileCtm,
|
|
38849
|
+
initialCtm: tileCtm,
|
|
38850
|
+
clipPaths: [...curState().clipPaths ?? [], tileClip]
|
|
38851
|
+
});
|
|
38852
|
+
try {
|
|
38853
|
+
walkNodes(nodes, mcid, actualText, patternResources, patternFonts, depth + 1);
|
|
38854
|
+
} finally {
|
|
38855
|
+
stateStack.pop();
|
|
38856
|
+
}
|
|
38857
|
+
}
|
|
38858
|
+
}
|
|
38859
|
+
return true;
|
|
38860
|
+
} finally {
|
|
38861
|
+
stateStack.pop();
|
|
38862
|
+
}
|
|
38863
|
+
};
|
|
38737
38864
|
const paintForm = (form, activeResources, activeFonts, depth, mcid, actualText, maskGroup = false) => {
|
|
38738
38865
|
const st = curState();
|
|
38739
38866
|
const group = params.cosDoc.resolveDict(dictGet(form.dict, "Group"));
|
|
@@ -38792,7 +38919,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
38792
38919
|
}
|
|
38793
38920
|
const parentOperations = capturedOperations;
|
|
38794
38921
|
const children = [];
|
|
38795
|
-
const nextState = { ...st, ctm: nextCtm };
|
|
38922
|
+
const nextState = { ...st, ctm: nextCtm, initialCtm: nextCtm };
|
|
38796
38923
|
if (compositeGroup) {
|
|
38797
38924
|
capturedOperations = children;
|
|
38798
38925
|
nextState.fillAlpha = nextState.strokeAlpha = 1;
|
|
@@ -38950,136 +39077,15 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
38950
39077
|
}
|
|
38951
39078
|
const isFill = ["f", "F", "f*", "B", "B*", "b", "b*"].includes(node.paint);
|
|
38952
39079
|
const isStroke = ["S", "s", "B", "B*", "b", "b*"].includes(node.paint);
|
|
38953
|
-
|
|
38954
|
-
|
|
38955
|
-
|
|
38956
|
-
|
|
38957
|
-
|
|
38958
|
-
|
|
38959
|
-
|
|
38960
|
-
|
|
38961
|
-
|
|
38962
|
-
for (const s of transformedSegments) {
|
|
38963
|
-
if (s.kind === "move" || s.kind === "line") {
|
|
38964
|
-
pMinX = Math.min(pMinX, s.x);
|
|
38965
|
-
pMinY = Math.min(pMinY, s.y);
|
|
38966
|
-
pMaxX = Math.max(pMaxX, s.x);
|
|
38967
|
-
pMaxY = Math.max(pMaxY, s.y);
|
|
38968
|
-
} else if (s.kind === "cubic") {
|
|
38969
|
-
pMinX = Math.min(pMinX, s.x1, s.x2, s.x);
|
|
38970
|
-
pMinY = Math.min(pMinY, s.y1, s.y2, s.y);
|
|
38971
|
-
pMaxX = Math.max(pMaxX, s.x1, s.x2, s.x);
|
|
38972
|
-
pMaxY = Math.max(pMaxY, s.y1, s.y2, s.y);
|
|
38973
|
-
} else if (s.kind === "rect") {
|
|
38974
|
-
pMinX = Math.min(pMinX, s.x);
|
|
38975
|
-
pMinY = Math.min(pMinY, s.y);
|
|
38976
|
-
pMaxX = Math.max(pMaxX, s.x + s.width);
|
|
38977
|
-
pMaxY = Math.max(pMaxY, s.y + s.height);
|
|
38978
|
-
}
|
|
38979
|
-
}
|
|
38980
|
-
if (Number.isFinite(pMinX) && Number.isFinite(pMinY) && pMaxX > pMinX && pMaxY > pMinY) {
|
|
38981
|
-
const shading = params.cosDoc.resolve(dictGet(patDict, "Shading"));
|
|
38982
|
-
const shDict = shading?.kind === "stream" ? shading.dict : shading?.kind === "dict" ? shading : void 0;
|
|
38983
|
-
if (shDict) {
|
|
38984
|
-
let patMatrix = [1, 0, 0, 1, 0, 0];
|
|
38985
|
-
const pmArr = params.cosDoc.resolveArray(dictGet(patDict, "Matrix"));
|
|
38986
|
-
if (pmArr && pmArr.items.length >= 6) {
|
|
38987
|
-
const mn = (idx, fb = 0) => {
|
|
38988
|
-
const r = params.cosDoc.resolve(pmArr.items[idx]);
|
|
38989
|
-
return r?.kind === "number" ? r.value : fb;
|
|
38990
|
-
};
|
|
38991
|
-
patMatrix = [mn(0, 1), mn(1, 0), mn(2, 0), mn(3, 1), mn(4, 0), mn(5, 0)];
|
|
38992
|
-
}
|
|
38993
|
-
const patClip = st.clipRect ? [
|
|
38994
|
-
Math.max(st.clipRect[0], pMinX),
|
|
38995
|
-
Math.max(st.clipRect[1], pMinY),
|
|
38996
|
-
Math.min(st.clipRect[2], pMaxX),
|
|
38997
|
-
Math.min(st.clipRect[3], pMaxY)
|
|
38998
|
-
] : [pMinX, pMinY, pMaxX, pMaxY];
|
|
38999
|
-
const shImg = renderShadingDictToImage(
|
|
39000
|
-
params.cosDoc,
|
|
39001
|
-
shDict,
|
|
39002
|
-
patMatrix,
|
|
39003
|
-
patClip,
|
|
39004
|
-
st.fillAlpha,
|
|
39005
|
-
"PatternShading_" + st.fillPatternName,
|
|
39006
|
-
patClip,
|
|
39007
|
-
shading?.kind === "stream" ? shading : void 0,
|
|
39008
|
-
st.blendMode
|
|
39009
|
-
);
|
|
39010
|
-
if (shImg) {
|
|
39011
|
-
emit({ kind: "image", value: shImg });
|
|
39012
|
-
evaluatedFillPattern = true;
|
|
39013
|
-
}
|
|
39014
|
-
}
|
|
39015
|
-
}
|
|
39016
|
-
} else if (patNode?.kind === "stream") {
|
|
39017
|
-
let pMinX = Infinity, pMinY = Infinity, pMaxX = -Infinity, pMaxY = -Infinity;
|
|
39018
|
-
for (const s of transformedSegments) {
|
|
39019
|
-
if (s.kind === "move" || s.kind === "line") {
|
|
39020
|
-
pMinX = Math.min(pMinX, s.x);
|
|
39021
|
-
pMinY = Math.min(pMinY, s.y);
|
|
39022
|
-
pMaxX = Math.max(pMaxX, s.x);
|
|
39023
|
-
pMaxY = Math.max(pMaxY, s.y);
|
|
39024
|
-
} else if (s.kind === "cubic") {
|
|
39025
|
-
pMinX = Math.min(pMinX, s.x1, s.x2, s.x);
|
|
39026
|
-
pMinY = Math.min(pMinY, s.y1, s.y2, s.y);
|
|
39027
|
-
pMaxX = Math.max(pMaxX, s.x1, s.x2, s.x);
|
|
39028
|
-
pMaxY = Math.max(pMaxY, s.y1, s.y2, s.y);
|
|
39029
|
-
} else if (s.kind === "rect") {
|
|
39030
|
-
pMinX = Math.min(pMinX, s.x);
|
|
39031
|
-
pMinY = Math.min(pMinY, s.y);
|
|
39032
|
-
pMaxX = Math.max(pMaxX, s.x + s.width);
|
|
39033
|
-
pMaxY = Math.max(pMaxY, s.y + s.height);
|
|
39034
|
-
}
|
|
39035
|
-
}
|
|
39036
|
-
if (Number.isFinite(pMinX) && Number.isFinite(pMinY) && pMaxX > pMinX && pMaxY > pMinY) {
|
|
39037
|
-
const xsNode = params.cosDoc.resolve(dictGet(patNode.dict, "XStep"));
|
|
39038
|
-
const ysNode = params.cosDoc.resolve(dictGet(patNode.dict, "YStep"));
|
|
39039
|
-
const xStep = xsNode?.kind === "number" && Math.abs(xsNode.value) > 1e-3 ? Math.abs(xsNode.value) : 40;
|
|
39040
|
-
const yStep = ysNode?.kind === "number" && Math.abs(ysNode.value) > 1e-3 ? Math.abs(ysNode.value) : 40;
|
|
39041
|
-
let patMatrix = [1, 0, 0, 1, 0, 0];
|
|
39042
|
-
const pmArr = params.cosDoc.resolveArray(dictGet(patNode.dict, "Matrix"));
|
|
39043
|
-
if (pmArr && pmArr.items.length >= 6) {
|
|
39044
|
-
const mn = (idx, fb = 0) => {
|
|
39045
|
-
const r = params.cosDoc.resolve(pmArr.items[idx]);
|
|
39046
|
-
return r?.kind === "number" ? r.value : fb;
|
|
39047
|
-
};
|
|
39048
|
-
patMatrix = [mn(0, 1), mn(1, 0), mn(2, 0), mn(3, 1), mn(4, 0), mn(5, 0)];
|
|
39049
|
-
}
|
|
39050
|
-
const tileClip = st.clipRect ? [
|
|
39051
|
-
Math.max(st.clipRect[0], pMinX),
|
|
39052
|
-
Math.max(st.clipRect[1], pMinY),
|
|
39053
|
-
Math.min(st.clipRect[2], pMaxX),
|
|
39054
|
-
Math.min(st.clipRect[3], pMaxY)
|
|
39055
|
-
] : [pMinX, pMinY, pMaxX, pMaxY];
|
|
39056
|
-
const patNodes = parseContentStream(params.cosDoc.decodeStream(patNode));
|
|
39057
|
-
const patResDict = params.cosDoc.resolveDict(dictGet(patNode.dict, "Resources")) ?? activeResources;
|
|
39058
|
-
const patFonts = new Map(activeFonts);
|
|
39059
|
-
for (const [fk, fv] of resolvePageFonts(params.cosDoc, patResDict).entries()) {
|
|
39060
|
-
patFonts.set(fk, fv);
|
|
39061
|
-
}
|
|
39062
|
-
const ixStart = Math.floor(pMinX / xStep);
|
|
39063
|
-
const ixEnd = Math.min(ixStart + 8, Math.ceil(pMaxX / xStep) - 1);
|
|
39064
|
-
const iyStart = Math.floor(pMinY / yStep);
|
|
39065
|
-
const iyEnd = Math.min(iyStart + 8, Math.ceil(pMaxY / yStep) - 1);
|
|
39066
|
-
for (let iy = iyStart; iy <= iyEnd; iy++) {
|
|
39067
|
-
for (let ix = ixStart; ix <= ixEnd; ix++) {
|
|
39068
|
-
const tileCtm = multiplyMatrices([1, 0, 0, 1, ix * xStep, iy * yStep], patMatrix);
|
|
39069
|
-
stateStack.push({
|
|
39070
|
-
...st,
|
|
39071
|
-
fillPatternName: void 0,
|
|
39072
|
-
ctm: tileCtm,
|
|
39073
|
-
clipRect: tileClip
|
|
39074
|
-
});
|
|
39075
|
-
walkNodes(patNodes, mcid, actualText, patResDict, patFonts, depth + 1);
|
|
39076
|
-
if (stateStack.length > 1) stateStack.pop();
|
|
39077
|
-
}
|
|
39078
|
-
}
|
|
39079
|
-
evaluatedFillPattern = true;
|
|
39080
|
-
}
|
|
39081
|
-
}
|
|
39082
|
-
}
|
|
39080
|
+
const evaluatedFillPattern = isFill && paintPattern(
|
|
39081
|
+
transformedSegments,
|
|
39082
|
+
node.paint.includes("*") ? "evenodd" : "nonzero",
|
|
39083
|
+
activeResources,
|
|
39084
|
+
activeFonts,
|
|
39085
|
+
depth,
|
|
39086
|
+
mcid,
|
|
39087
|
+
actualText
|
|
39088
|
+
);
|
|
39083
39089
|
if (evaluatedFillPattern && !isStroke) {
|
|
39084
39090
|
applyClip();
|
|
39085
39091
|
break;
|
|
@@ -39280,10 +39286,19 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
39280
39286
|
if (st.textRenderMode >= 4 && st.textRenderMode <= 7) pendingTextClip.push(...transformedGlyphSegs);
|
|
39281
39287
|
const isFillGlyph = st.textRenderMode === 0 || st.textRenderMode === 2 || st.textRenderMode === 4 || st.textRenderMode === 6;
|
|
39282
39288
|
const isStrokeGlyph = st.textRenderMode === 1 || st.textRenderMode === 2 || st.textRenderMode === 5 || st.textRenderMode === 6;
|
|
39289
|
+
const patterned = isFillGlyph && paintPattern(
|
|
39290
|
+
transformedGlyphSegs,
|
|
39291
|
+
"nonzero",
|
|
39292
|
+
activeResources,
|
|
39293
|
+
activeFonts,
|
|
39294
|
+
depth,
|
|
39295
|
+
mcid,
|
|
39296
|
+
actualText
|
|
39297
|
+
);
|
|
39283
39298
|
const paint = {
|
|
39284
39299
|
segments: transformedGlyphSegs,
|
|
39285
|
-
fillColor: isFillGlyph ? st.fillColor : void 0,
|
|
39286
|
-
fillAlpha: isFillGlyph ? st.fillAlpha : void 0,
|
|
39300
|
+
fillColor: isFillGlyph && !patterned ? st.fillColor : void 0,
|
|
39301
|
+
fillAlpha: isFillGlyph && !patterned ? st.fillAlpha : void 0,
|
|
39287
39302
|
strokeColor: isStrokeGlyph ? st.strokeColor : void 0,
|
|
39288
39303
|
strokeAlpha: isStrokeGlyph ? st.strokeAlpha : void 0,
|
|
39289
39304
|
strokeWidth: isStrokeGlyph ? st.strokeWidth : 0,
|
|
@@ -43091,10 +43106,14 @@ function computePdfBlendRgb(cbR, cbG, cbB, csR, csG, csB, mode) {
|
|
|
43091
43106
|
blendChannelSeparable(cbB, csB, mode)
|
|
43092
43107
|
];
|
|
43093
43108
|
}
|
|
43094
|
-
function blendPixel(rgba, width, height, px, py, color, alpha, blendMode, clipMask) {
|
|
43109
|
+
function blendPixel(rgba, width, height, px, py, color, alpha, blendMode, clipMask, groupAlpha) {
|
|
43095
43110
|
if (px < 0 || py < 0 || px >= width || py >= height || alpha <= 0) return;
|
|
43096
43111
|
const a = Math.min(1, Math.max(0, alpha)) * (clipMask ? clipMask[(py * width + px) * 4 + 3] / 255 : 1);
|
|
43097
43112
|
const idx = (py * width + px) * 4;
|
|
43113
|
+
if (groupAlpha) {
|
|
43114
|
+
const pixel = py * width + px;
|
|
43115
|
+
groupAlpha[pixel] = a + groupAlpha[pixel] * (1 - a);
|
|
43116
|
+
}
|
|
43098
43117
|
const csR = Math.min(1, Math.max(0, color.r));
|
|
43099
43118
|
const csG = Math.min(1, Math.max(0, color.g));
|
|
43100
43119
|
const csB = Math.min(1, Math.max(0, color.b));
|
|
@@ -43226,7 +43245,7 @@ function pathsToEdges(paths, closeSubpaths = false) {
|
|
|
43226
43245
|
}
|
|
43227
43246
|
return edges;
|
|
43228
43247
|
}
|
|
43229
|
-
function fillEdgesScanline4x4(rgba, width, height, edges, color, alpha = 1, fillRule = "nonzero", clipScreen, antialias = true, blendMode, clipMask) {
|
|
43248
|
+
function fillEdgesScanline4x4(rgba, width, height, edges, color, alpha = 1, fillRule = "nonzero", clipScreen, antialias = true, blendMode, clipMask, groupAlpha) {
|
|
43230
43249
|
if (edges.length === 0) return;
|
|
43231
43250
|
let minY = Infinity;
|
|
43232
43251
|
let maxY = -Infinity;
|
|
@@ -43292,7 +43311,7 @@ function fillEdgesScanline4x4(rgba, width, height, edges, color, alpha = 1, fill
|
|
|
43292
43311
|
const count = rowCounts[px];
|
|
43293
43312
|
if (count > 0) {
|
|
43294
43313
|
const cov = antialias ? count / 16 : count >= 8 ? 1 : 0;
|
|
43295
|
-
blendPixel(rgba, width, height, px, py, color, cov * alpha, blendMode, clipMask);
|
|
43314
|
+
blendPixel(rgba, width, height, px, py, color, cov * alpha, blendMode, clipMask, groupAlpha);
|
|
43296
43315
|
}
|
|
43297
43316
|
}
|
|
43298
43317
|
}
|
|
@@ -43371,19 +43390,16 @@ function hasCompositingEffects(operations, includeSoftMasks = false) {
|
|
|
43371
43390
|
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));
|
|
43372
43391
|
}
|
|
43373
43392
|
function needsGroupBackdrop(group) {
|
|
43374
|
-
return group.isolated === false &&
|
|
43393
|
+
return group.isolated === false && hasCompositingEffects(group.operations, true);
|
|
43375
43394
|
}
|
|
43376
|
-
function
|
|
43377
|
-
const baseScale = options.scale ?? (options.dpi ? options.dpi / 72 : 1.5);
|
|
43378
|
-
const scaleX = options.dpiX !== void 0 ? options.dpiX / 72 : baseScale;
|
|
43379
|
-
const scaleY = options.dpiY !== void 0 ? options.dpiY / 72 : baseScale;
|
|
43380
|
-
const scale = scaleX;
|
|
43395
|
+
function renderDisplayListLayer(displayList, options, scale, backdrop) {
|
|
43381
43396
|
const [originX, originY] = displayList.origin ?? [0, 0];
|
|
43382
43397
|
const pageTop = originY + displayList.height;
|
|
43383
43398
|
const toScreen = (x, y) => [(x - originX) * scale, (pageTop - y) * scale];
|
|
43384
43399
|
const width = Math.max(1, Math.round(displayList.width * scale));
|
|
43385
43400
|
const height = Math.max(1, Math.round(displayList.height * scale));
|
|
43386
|
-
const rgba = new Uint8Array(width * height * 4);
|
|
43401
|
+
const rgba = backdrop ? backdrop.slice() : new Uint8Array(width * height * 4);
|
|
43402
|
+
const groupAlpha = backdrop ? new Float32Array(width * height) : void 0;
|
|
43387
43403
|
const deferBackground = !options.transparent && hasCompositingEffects(paintOperations(displayList));
|
|
43388
43404
|
const transparent = options.transparent || deferBackground;
|
|
43389
43405
|
const bg = options.background ?? { r: 1, g: 1, b: 1 };
|
|
@@ -43391,7 +43407,7 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
43391
43407
|
const bgG = transparent ? 0 : Math.round(bg.g * 255);
|
|
43392
43408
|
const bgB = transparent ? 0 : Math.round(bg.b * 255);
|
|
43393
43409
|
const bgA = transparent ? 0 : 255;
|
|
43394
|
-
for (let i = 0; i < width * height; i++) {
|
|
43410
|
+
for (let i = 0; !backdrop && i < width * height; i++) {
|
|
43395
43411
|
rgba[i * 4] = bgR;
|
|
43396
43412
|
rgba[i * 4 + 1] = bgG;
|
|
43397
43413
|
rgba[i * 4 + 2] = bgB;
|
|
@@ -43409,20 +43425,12 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
43409
43425
|
let operation = original.kind === "glyph" ? { kind: "path", value: glyphPaint(original.value) } : original;
|
|
43410
43426
|
if (operation.kind === "group") {
|
|
43411
43427
|
const group = operation.value;
|
|
43412
|
-
|
|
43413
|
-
|
|
43414
|
-
|
|
43415
|
-
|
|
43416
|
-
|
|
43417
|
-
|
|
43418
|
-
decodedRgba: rgba.slice(),
|
|
43419
|
-
matrix: [width / scale, 0, 0, height / scale, originX, pageTop - height / scale],
|
|
43420
|
-
colorSpace: "DeviceRGB",
|
|
43421
|
-
bitsPerComponent: 8,
|
|
43422
|
-
...group.bboxClip ? { clipPaths: [group.bboxClip] } : {}
|
|
43423
|
-
} }, ...operations];
|
|
43424
|
-
}
|
|
43425
|
-
const bitmap = renderDisplayListToBitmap({ ...displayList, rotation: 0, operations }, { ...options, scale, dpiX: void 0, dpiY: void 0, cropRect: void 0, useCropBox: false, transparent: true });
|
|
43428
|
+
const bitmap = renderDisplayListLayer(
|
|
43429
|
+
{ ...displayList, operations: group.operations },
|
|
43430
|
+
{ ...options, transparent: true },
|
|
43431
|
+
scale,
|
|
43432
|
+
needsGroupBackdrop(group) ? rgba : void 0
|
|
43433
|
+
);
|
|
43426
43434
|
for (let i = 3; i < bitmap.data.length; i += 4) bitmap.data[i] = Math.round(bitmap.data[i] * group.alpha);
|
|
43427
43435
|
operation = { kind: "image", value: {
|
|
43428
43436
|
name: "TransparencyGroup",
|
|
@@ -43492,7 +43500,7 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
43492
43500
|
if (path.fillColor) {
|
|
43493
43501
|
const edges = pathsToEdges(segmentsToScreenPaths(path.segments, displayList.height, scale, toScreen), true);
|
|
43494
43502
|
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;
|
|
43495
|
-
fillEdgesScanline4x4(rgba, width, height, edges, path.fillColor, path.fillAlpha ?? 1, path.fillRule ?? "nonzero", clipScreen, original.kind === "glyph" ? aaTxt : aaVec, path.blendMode, clipMask);
|
|
43503
|
+
fillEdgesScanline4x4(rgba, width, height, edges, path.fillColor, path.fillAlpha ?? 1, path.fillRule ?? "nonzero", clipScreen, original.kind === "glyph" ? aaTxt : aaVec, path.blendMode, clipMask, groupAlpha);
|
|
43496
43504
|
}
|
|
43497
43505
|
if (path.strokeColor) {
|
|
43498
43506
|
const rawSw = path.strokeWidth * scale * (path.strokeMatrix ? Math.hypot(path.strokeMatrix[0], path.strokeMatrix[1]) : 1);
|
|
@@ -43510,7 +43518,8 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
43510
43518
|
clipScreen,
|
|
43511
43519
|
original.kind === "glyph" ? aaTxt : aaVec,
|
|
43512
43520
|
path.blendMode,
|
|
43513
|
-
clipMask
|
|
43521
|
+
clipMask,
|
|
43522
|
+
groupAlpha
|
|
43514
43523
|
);
|
|
43515
43524
|
}
|
|
43516
43525
|
} else if (operation.kind === "image") {
|
|
@@ -43574,12 +43583,31 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
43574
43583
|
},
|
|
43575
43584
|
sample[3] / 255,
|
|
43576
43585
|
img.blendMode,
|
|
43577
|
-
clipMask
|
|
43586
|
+
clipMask,
|
|
43587
|
+
groupAlpha
|
|
43578
43588
|
);
|
|
43579
43589
|
}
|
|
43580
43590
|
}
|
|
43581
43591
|
}
|
|
43582
43592
|
}
|
|
43593
|
+
if (backdrop && groupAlpha) {
|
|
43594
|
+
for (let i = 0; i < rgba.length; i += 4) {
|
|
43595
|
+
const alpha = groupAlpha[i / 4];
|
|
43596
|
+
if (alpha === 0) {
|
|
43597
|
+
rgba.fill(0, i, i + 4);
|
|
43598
|
+
continue;
|
|
43599
|
+
}
|
|
43600
|
+
const factor = backdrop[i + 3] / 255 * (1 / alpha - 1);
|
|
43601
|
+
for (let channel = 0; channel < 3; channel++) {
|
|
43602
|
+
const color = rgba[i + channel];
|
|
43603
|
+
rgba[i + channel] = Math.max(0, Math.min(
|
|
43604
|
+
255,
|
|
43605
|
+
Math.round(color + (color - backdrop[i + channel]) * factor)
|
|
43606
|
+
));
|
|
43607
|
+
}
|
|
43608
|
+
rgba[i + 3] = Math.round(alpha * 255);
|
|
43609
|
+
}
|
|
43610
|
+
}
|
|
43583
43611
|
if (deferBackground) {
|
|
43584
43612
|
for (let i = 0; i < rgba.length; i += 4) {
|
|
43585
43613
|
const alpha = rgba[i + 3] / 255;
|
|
@@ -43589,7 +43617,14 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
43589
43617
|
rgba[i + 3] = 255;
|
|
43590
43618
|
}
|
|
43591
43619
|
}
|
|
43592
|
-
|
|
43620
|
+
return { width, height, data: rgba };
|
|
43621
|
+
}
|
|
43622
|
+
function renderDisplayListToBitmap(displayList, options = {}) {
|
|
43623
|
+
const baseScale = options.scale ?? (options.dpi ? options.dpi / 72 : 1.5);
|
|
43624
|
+
const scaleX = options.dpiX !== void 0 ? options.dpiX / 72 : baseScale;
|
|
43625
|
+
const scaleY = options.dpiY !== void 0 ? options.dpiY / 72 : baseScale;
|
|
43626
|
+
let result = renderDisplayListLayer(displayList, options, scaleX);
|
|
43627
|
+
const { width, height, data: rgba } = result;
|
|
43593
43628
|
if (Math.abs(scaleX - scaleY) > 1e-6) {
|
|
43594
43629
|
const targetW = Math.max(1, Math.round(displayList.width * scaleX));
|
|
43595
43630
|
const targetH = Math.max(1, Math.round(displayList.height * scaleY));
|