@yudaocode/univer-pdfs 1.6.211 → 1.6.213
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/PDF_BROWSER_RENDERING_CONTRACT.md +129 -0
- package/README.md +1 -0
- package/lib/cjs/index.js +1439 -241
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/jsx/index.js +861 -208
- package/lib/cjs/jsx/index.js.map +1 -1
- package/lib/es/{chunk-72OJSR4Z.js → chunk-4A226M74.js} +898 -210
- package/lib/es/chunk-4A226M74.js.map +1 -0
- package/lib/es/index.js +530 -16
- package/lib/es/index.js.map +1 -1
- package/lib/es/jsx/index.js +1 -1
- package/lib/types/index.d.ts +24 -54
- package/lib/types/jsx/index.d.ts +2 -2
- package/lib/types/jsx/jsx-dev-runtime.d.ts +1 -1
- package/lib/types/jsx/jsx-runtime.d.ts +1 -1
- package/lib/types/{jsx-dev-runtime-5tXCUq4v.d.ts → jsx-dev-runtime-Ch1WuW58.d.ts} +190 -2
- package/package.json +3 -2
- package/lib/es/chunk-72OJSR4Z.js.map +0 -1
package/lib/cjs/index.js
CHANGED
|
@@ -85,6 +85,7 @@ __export(src_exports, {
|
|
|
85
85
|
PdfIoTargetError: () => PdfIoTargetError,
|
|
86
86
|
PdfListKind: () => PdfListKind,
|
|
87
87
|
PdfListPresetId: () => PdfListPresetId,
|
|
88
|
+
PdfRenderError: () => PdfRenderError,
|
|
88
89
|
PdfSelectionService: () => PdfSelectionService,
|
|
89
90
|
PdfTableBorderStyle: () => PdfTableBorderStyle,
|
|
90
91
|
PdfTableCellVerticalAlign: () => PdfTableCellVerticalAlign,
|
|
@@ -136,8 +137,11 @@ __export(src_exports, {
|
|
|
136
137
|
buildMinimalTestTrueTypeFont: () => buildMinimalTestTrueTypeFont,
|
|
137
138
|
buildOverlayImportCandidateSnapshot: () => buildOverlayImportCandidateSnapshot,
|
|
138
139
|
buildPdfTemplateFromOcrFields: () => buildPdfTemplateFromOcrFields,
|
|
140
|
+
calculatePdfTableRowCapacity: () => calculatePdfTableRowCapacity,
|
|
139
141
|
canonicalJsonStringify: () => canonicalJsonStringify,
|
|
142
|
+
clearPdfFontUrlCache: () => clearPdfFontUrlCache,
|
|
140
143
|
cmykToRgb: () => cmykToRgb,
|
|
144
|
+
collectMissingGlyphsFromPdfUnit: () => collectMissingGlyphsFromPdfUnit,
|
|
141
145
|
collectPdfInputContractHints: () => collectPdfInputContractHints,
|
|
142
146
|
collectUsedCodePointsFromPdfUnit: () => collectUsedCodePointsFromPdfUnit,
|
|
143
147
|
comparePdfBytes: () => comparePdfBytes,
|
|
@@ -167,6 +171,7 @@ __export(src_exports, {
|
|
|
167
171
|
createDefaultElement: () => createDefaultElement,
|
|
168
172
|
createDefaultPdfUnitData: () => createDefaultPdfUnitData,
|
|
169
173
|
createHttpSilentPrintAdapter: () => createHttpSilentPrintAdapter,
|
|
174
|
+
createPdfBrowserFidelitySamples: () => createPdfBrowserFidelitySamples,
|
|
170
175
|
createPdfJsxNode: () => createPdfJsxNode,
|
|
171
176
|
detectCJKCharacters: () => detectCJKCharacters,
|
|
172
177
|
detectCJKInPdfInputs: () => detectCJKInPdfInputs,
|
|
@@ -314,6 +319,7 @@ __export(src_exports, {
|
|
|
314
319
|
verifyPdfAuditSeal: () => verifyPdfAuditSeal,
|
|
315
320
|
verifyPdfUnitSignature: () => verifyPdfUnitSignature,
|
|
316
321
|
visitTemplateVariables: () => visitTemplateVariables,
|
|
322
|
+
wrapMixedCjkAndLatinLines: () => wrapMixedCjkAndLatinLines,
|
|
317
323
|
wrapPdfTextLines: () => wrapPdfTextLines
|
|
318
324
|
});
|
|
319
325
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -9573,6 +9579,94 @@ function drawVectorSvgOnPdfPage(pdfPage, pageHeight, left, top, width, height, s
|
|
|
9573
9579
|
}
|
|
9574
9580
|
|
|
9575
9581
|
// src/exporter/pdf-exporter.ts
|
|
9582
|
+
var PdfRenderError = class extends Error {
|
|
9583
|
+
constructor(code, message, extra) {
|
|
9584
|
+
super(message);
|
|
9585
|
+
this.name = "PdfRenderError";
|
|
9586
|
+
this.code = code;
|
|
9587
|
+
if (extra?.failedFonts) this.failedFonts = extra.failedFonts;
|
|
9588
|
+
if (extra?.missingGlyphs) this.missingGlyphs = extra.missingGlyphs;
|
|
9589
|
+
}
|
|
9590
|
+
};
|
|
9591
|
+
var pdfFontUrlByteCache = /* @__PURE__ */ new Map();
|
|
9592
|
+
function clearPdfFontUrlCache() {
|
|
9593
|
+
pdfFontUrlByteCache.clear();
|
|
9594
|
+
}
|
|
9595
|
+
function bytesToBase64Standard(bytes) {
|
|
9596
|
+
if (typeof Buffer !== "undefined") {
|
|
9597
|
+
return Buffer.from(bytes).toString("base64");
|
|
9598
|
+
}
|
|
9599
|
+
let bin = "";
|
|
9600
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
9601
|
+
bin += String.fromCharCode(bytes[i]);
|
|
9602
|
+
}
|
|
9603
|
+
return btoa(bin);
|
|
9604
|
+
}
|
|
9605
|
+
async function verifyFontSubresourceIntegrity(bytes, integrity) {
|
|
9606
|
+
const trimmed = integrity.trim();
|
|
9607
|
+
if (!trimmed) return;
|
|
9608
|
+
const m = trimmed.match(/^(sha256|sha384|sha512)-([A-Za-z0-9+/=_-]+)$/i);
|
|
9609
|
+
if (!m) {
|
|
9610
|
+
throw new Error(`Unsupported integrity format '${trimmed}' (expected sha256-/sha384-/sha512-).`);
|
|
9611
|
+
}
|
|
9612
|
+
const algoMap = {
|
|
9613
|
+
sha256: "SHA-256",
|
|
9614
|
+
sha384: "SHA-384",
|
|
9615
|
+
sha512: "SHA-512"
|
|
9616
|
+
};
|
|
9617
|
+
const algo = algoMap[m[1].toLowerCase()];
|
|
9618
|
+
const expectedB64 = m[2].replace(/-/g, "+").replace(/_/g, "/");
|
|
9619
|
+
const subtle = globalThis.crypto?.subtle;
|
|
9620
|
+
if (!subtle) {
|
|
9621
|
+
throw new Error("Web Crypto API is unavailable to verify font integrity.");
|
|
9622
|
+
}
|
|
9623
|
+
const digestBuf = await subtle.digest(
|
|
9624
|
+
algo,
|
|
9625
|
+
bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength)
|
|
9626
|
+
);
|
|
9627
|
+
const actualB64 = bytesToBase64Standard(new Uint8Array(digestBuf)).replace(/=+$/, "");
|
|
9628
|
+
const normExpected = expectedB64.replace(/=+$/, "");
|
|
9629
|
+
if (actualB64 !== normExpected) {
|
|
9630
|
+
throw new Error(`Font SRI integrity mismatch (${m[1]}).`);
|
|
9631
|
+
}
|
|
9632
|
+
}
|
|
9633
|
+
async function loadSingleFontCandidate(src) {
|
|
9634
|
+
let rawBytes;
|
|
9635
|
+
if (src.bytes != null) {
|
|
9636
|
+
rawBytes = src.bytes instanceof Uint8Array ? src.bytes : new Uint8Array(src.bytes);
|
|
9637
|
+
if (src.integrity) {
|
|
9638
|
+
await verifyFontSubresourceIntegrity(rawBytes, src.integrity);
|
|
9639
|
+
}
|
|
9640
|
+
} else if (src.url) {
|
|
9641
|
+
const cacheKey = `${src.url}|${src.integrity ?? ""}`;
|
|
9642
|
+
const cached = pdfFontUrlByteCache.get(cacheKey);
|
|
9643
|
+
if (cached) {
|
|
9644
|
+
rawBytes = cached;
|
|
9645
|
+
} else {
|
|
9646
|
+
let resp;
|
|
9647
|
+
try {
|
|
9648
|
+
resp = await fetch(src.url);
|
|
9649
|
+
} catch (err) {
|
|
9650
|
+
throw new Error(`Network error fetching '${src.url}': ${err?.message || String(err)}`);
|
|
9651
|
+
}
|
|
9652
|
+
if (!resp.ok) {
|
|
9653
|
+
throw new Error(`HTTP ${resp.status} fetching '${src.url}'.`);
|
|
9654
|
+
}
|
|
9655
|
+
const ab = await resp.arrayBuffer();
|
|
9656
|
+
rawBytes = new Uint8Array(ab);
|
|
9657
|
+
if (src.integrity) {
|
|
9658
|
+
await verifyFontSubresourceIntegrity(rawBytes, src.integrity);
|
|
9659
|
+
}
|
|
9660
|
+
inspectTrueTypeFont(rawBytes);
|
|
9661
|
+
pdfFontUrlByteCache.set(cacheKey, rawBytes);
|
|
9662
|
+
return rawBytes;
|
|
9663
|
+
}
|
|
9664
|
+
} else {
|
|
9665
|
+
throw new Error("Font source has neither bytes nor url.");
|
|
9666
|
+
}
|
|
9667
|
+
inspectTrueTypeFont(rawBytes);
|
|
9668
|
+
return rawBytes;
|
|
9669
|
+
}
|
|
9576
9670
|
function getByPath(data, path) {
|
|
9577
9671
|
if (!data || !path) return void 0;
|
|
9578
9672
|
return safeLookupVariablePath(data, path);
|
|
@@ -9777,11 +9871,166 @@ endbfchar`);
|
|
|
9777
9871
|
"end"
|
|
9778
9872
|
].join("\n");
|
|
9779
9873
|
}
|
|
9780
|
-
function
|
|
9781
|
-
const
|
|
9874
|
+
function registerSubsetType0FontInDoc(pdfDoc, fontBytes, usedCodePoints, fontTag) {
|
|
9875
|
+
const subset = subsetTrueTypeFont(fontBytes, usedCodePoints);
|
|
9876
|
+
const scale = 1e3 / (subset.unitsPerEm || 1e3);
|
|
9877
|
+
const fontFileStream = pdfDoc.context.flateStream(subset.subsetBytes, {
|
|
9878
|
+
Length1: subset.subsetBytes.byteLength
|
|
9879
|
+
});
|
|
9880
|
+
const fontFileRef = pdfDoc.context.register(fontFileStream);
|
|
9881
|
+
const scaledWidths = subset.gidAdvanceWidths.map((w) => Math.round(w * scale));
|
|
9882
|
+
const fontDescriptorRef = pdfDoc.context.register(
|
|
9883
|
+
pdfDoc.context.obj({
|
|
9884
|
+
Type: "FontDescriptor",
|
|
9885
|
+
FontName: fontTag,
|
|
9886
|
+
Flags: 32,
|
|
9887
|
+
FontBBox: subset.bbox.map((v) => Math.round(v * scale)),
|
|
9888
|
+
ItalicAngle: 0,
|
|
9889
|
+
Ascent: Math.round(subset.ascent * scale),
|
|
9890
|
+
Descent: Math.round(subset.descent * scale),
|
|
9891
|
+
CapHeight: Math.round(subset.ascent * scale),
|
|
9892
|
+
StemV: fontTag.includes("Bold") ? 140 : 80,
|
|
9893
|
+
FontFile2: fontFileRef
|
|
9894
|
+
})
|
|
9895
|
+
);
|
|
9896
|
+
const cidFontRef = pdfDoc.context.register(
|
|
9897
|
+
pdfDoc.context.obj({
|
|
9898
|
+
Type: "Font",
|
|
9899
|
+
Subtype: "CIDFontType2",
|
|
9900
|
+
BaseFont: fontTag,
|
|
9901
|
+
CIDSystemInfo: {
|
|
9902
|
+
Registry: import_pdf_lib3.PDFString.of("Adobe"),
|
|
9903
|
+
Ordering: import_pdf_lib3.PDFString.of("Identity"),
|
|
9904
|
+
Supplement: 0
|
|
9905
|
+
},
|
|
9906
|
+
FontDescriptor: fontDescriptorRef,
|
|
9907
|
+
DW: 1e3,
|
|
9908
|
+
W: [0, scaledWidths],
|
|
9909
|
+
CIDToGIDMap: "Identity"
|
|
9910
|
+
})
|
|
9911
|
+
);
|
|
9912
|
+
const toUnicodeCmap = buildToUnicodeCmapString(subset.codePointToGid);
|
|
9913
|
+
const toUnicodeRef = pdfDoc.context.register(pdfDoc.context.flateStream(toUnicodeCmap));
|
|
9914
|
+
const type0FontRef = pdfDoc.context.register(
|
|
9915
|
+
pdfDoc.context.obj({
|
|
9916
|
+
Type: "Font",
|
|
9917
|
+
Subtype: "Type0",
|
|
9918
|
+
BaseFont: fontTag,
|
|
9919
|
+
Encoding: "Identity-H",
|
|
9920
|
+
DescendantFonts: [cidFontRef],
|
|
9921
|
+
ToUnicode: toUnicodeRef
|
|
9922
|
+
})
|
|
9923
|
+
);
|
|
9924
|
+
return { type0FontRef, subset };
|
|
9925
|
+
}
|
|
9926
|
+
async function resolveRenderFontsForExport(snapshot, options) {
|
|
9927
|
+
const renderCfg = options?.render;
|
|
9928
|
+
const hasHostFonts = Boolean(renderCfg?.fonts && renderCfg.fonts.length > 0);
|
|
9929
|
+
const explicitMode = renderCfg?.cjkTextMode ?? options?.cjkTextMode;
|
|
9930
|
+
const requestedMode = explicitMode ?? (hasHostFonts ? "subset-ttf" : "raster-hd");
|
|
9931
|
+
if (requestedMode === "raster-hd" || requestedMode === "cid-vector") {
|
|
9932
|
+
return { effectiveMode: requestedMode };
|
|
9933
|
+
}
|
|
9934
|
+
const failedFonts = [];
|
|
9935
|
+
let normalFontBytes;
|
|
9936
|
+
let boldFontBytes = options?.customBoldFontBytes;
|
|
9937
|
+
if (hasHostFonts && renderCfg?.fonts) {
|
|
9938
|
+
const normalCandidates = renderCfg.fonts.map((f, index) => ({ f, index })).filter(({ f }) => f.weight !== "bold");
|
|
9939
|
+
const boldCandidates = renderCfg.fonts.map((f, index) => ({ f, index })).filter(({ f }) => f.weight === "bold");
|
|
9940
|
+
const primaryOrder = normalCandidates.length > 0 ? normalCandidates : boldCandidates;
|
|
9941
|
+
for (const { f, index } of primaryOrder) {
|
|
9942
|
+
try {
|
|
9943
|
+
normalFontBytes = await loadSingleFontCandidate(f);
|
|
9944
|
+
break;
|
|
9945
|
+
} catch (err) {
|
|
9946
|
+
failedFonts.push({
|
|
9947
|
+
index,
|
|
9948
|
+
family: f.family,
|
|
9949
|
+
weight: f.weight,
|
|
9950
|
+
url: f.url,
|
|
9951
|
+
reason: err?.message || String(err)
|
|
9952
|
+
});
|
|
9953
|
+
}
|
|
9954
|
+
}
|
|
9955
|
+
if (normalFontBytes && !boldFontBytes && boldCandidates.length > 0 && normalCandidates.length > 0) {
|
|
9956
|
+
for (const { f, index } of boldCandidates) {
|
|
9957
|
+
try {
|
|
9958
|
+
boldFontBytes = await loadSingleFontCandidate(f);
|
|
9959
|
+
break;
|
|
9960
|
+
} catch (err) {
|
|
9961
|
+
failedFonts.push({
|
|
9962
|
+
index,
|
|
9963
|
+
family: f.family,
|
|
9964
|
+
weight: f.weight,
|
|
9965
|
+
url: f.url,
|
|
9966
|
+
reason: err?.message || String(err)
|
|
9967
|
+
});
|
|
9968
|
+
}
|
|
9969
|
+
}
|
|
9970
|
+
}
|
|
9971
|
+
}
|
|
9972
|
+
if (!normalFontBytes && options?.customFontBytes && options.customFontBytes.byteLength > 0) {
|
|
9973
|
+
try {
|
|
9974
|
+
inspectTrueTypeFont(options.customFontBytes);
|
|
9975
|
+
normalFontBytes = options.customFontBytes;
|
|
9976
|
+
} catch (err) {
|
|
9977
|
+
failedFonts.push({
|
|
9978
|
+
index: failedFonts.length,
|
|
9979
|
+
reason: err?.message || String(err)
|
|
9980
|
+
});
|
|
9981
|
+
}
|
|
9982
|
+
}
|
|
9983
|
+
if (!normalFontBytes && snapshot?.resourceBindings) {
|
|
9984
|
+
const fontBinding = Object.values(snapshot.resourceBindings).find(
|
|
9985
|
+
(b) => b.type === "font" && Boolean(b.dataUri)
|
|
9986
|
+
);
|
|
9987
|
+
if (fontBinding?.dataUri) {
|
|
9988
|
+
try {
|
|
9989
|
+
const decoded = dataUriToBytes(fontBinding.dataUri);
|
|
9990
|
+
inspectTrueTypeFont(decoded);
|
|
9991
|
+
normalFontBytes = decoded;
|
|
9992
|
+
} catch (err) {
|
|
9993
|
+
failedFonts.push({
|
|
9994
|
+
index: failedFonts.length,
|
|
9995
|
+
family: fontBinding.name,
|
|
9996
|
+
reason: err?.message || String(err)
|
|
9997
|
+
});
|
|
9998
|
+
}
|
|
9999
|
+
}
|
|
10000
|
+
}
|
|
10001
|
+
if (normalFontBytes && normalFontBytes.byteLength > 0) {
|
|
10002
|
+
if (boldFontBytes) {
|
|
10003
|
+
try {
|
|
10004
|
+
inspectTrueTypeFont(boldFontBytes);
|
|
10005
|
+
} catch {
|
|
10006
|
+
boldFontBytes = void 0;
|
|
10007
|
+
}
|
|
10008
|
+
}
|
|
10009
|
+
return { effectiveMode: "subset-ttf", normalFontBytes, boldFontBytes };
|
|
10010
|
+
}
|
|
10011
|
+
const fallbackPolicy = renderCfg?.fallback ?? "error";
|
|
10012
|
+
const detailSummary = failedFonts.length > 0 ? failedFonts.map(
|
|
10013
|
+
(e) => `#${e.index}${e.family ? ` (${e.family})` : ""}${e.url ? ` [${e.url}]` : ""}: ${e.reason}`
|
|
10014
|
+
).join("; ") : "\u672A\u63D0\u4F9B\u53EF\u7528\u7684 TrueType (.ttf) \u5B57\u4F53\u5B57\u8282\u6216\u5730\u5740";
|
|
10015
|
+
if (fallbackPolicy === "raster-hd" || fallbackPolicy === "cid-vector") {
|
|
10016
|
+
renderCfg?.onWarning?.({
|
|
10017
|
+
code: "FONT_FALLBACK_ACTIVATED",
|
|
10018
|
+
message: `\u4E2D\u6587\u5B57\u4F53\u52A0\u8F7D\u5931\u8D25\uFF0C\u5DF2\u6309\u663E\u5F0F\u56DE\u9000\u7B56\u7565\u5207\u6362\u81F3 '${fallbackPolicy}'\uFF1A${detailSummary}`,
|
|
10019
|
+
details: { fallback: fallbackPolicy, failedFonts }
|
|
10020
|
+
});
|
|
10021
|
+
return { effectiveMode: fallbackPolicy };
|
|
10022
|
+
}
|
|
10023
|
+
throw new PdfRenderError(
|
|
10024
|
+
"FONT_UNAVAILABLE",
|
|
10025
|
+
`PDF \u5B50\u96C6\u5B57\u4F53\u4E0D\u53EF\u7528\uFF08cjkTextMode='subset-ttf'\uFF09\uFF1A${detailSummary}`,
|
|
10026
|
+
{ failedFonts }
|
|
10027
|
+
);
|
|
10028
|
+
}
|
|
10029
|
+
function initVectorCjkEmbedState(pdfDoc, snapshot, effectiveData, options, preResolved) {
|
|
10030
|
+
const requested = preResolved?.effectiveMode ?? options?.render?.cjkTextMode ?? options?.cjkTextMode ?? "raster-hd";
|
|
9782
10031
|
if (requested === "raster-hd") return null;
|
|
9783
|
-
let resolvedFontBytes = options?.customFontBytes;
|
|
9784
|
-
if ((!resolvedFontBytes || resolvedFontBytes.byteLength === 0) && snapshot?.resourceBindings) {
|
|
10032
|
+
let resolvedFontBytes = preResolved?.normalFontBytes ?? options?.customFontBytes;
|
|
10033
|
+
if ((!resolvedFontBytes || resolvedFontBytes.byteLength === 0) && !preResolved && snapshot?.resourceBindings) {
|
|
9785
10034
|
const fontBinding = Object.values(snapshot.resourceBindings).find(
|
|
9786
10035
|
(b) => b.type === "font" && Boolean(b.dataUri)
|
|
9787
10036
|
);
|
|
@@ -9793,62 +10042,69 @@ function initVectorCjkEmbedState(pdfDoc, snapshot, effectiveData, options) {
|
|
|
9793
10042
|
}
|
|
9794
10043
|
}
|
|
9795
10044
|
}
|
|
9796
|
-
if (requested === "subset-ttf"
|
|
10045
|
+
if (requested === "subset-ttf") {
|
|
10046
|
+
if (!resolvedFontBytes || resolvedFontBytes.byteLength === 0) {
|
|
10047
|
+
throw new PdfRenderError(
|
|
10048
|
+
"FONT_UNAVAILABLE",
|
|
10049
|
+
"PDF \u5B50\u96C6\u5B57\u4F53\u4E0D\u53EF\u7528\uFF08cjkTextMode='subset-ttf'\uFF09\uFF1A\u672A\u63D0\u4F9B\u6709\u6548\u7684 TrueType (.ttf) \u5B57\u4F53\u6570\u636E\u3002"
|
|
10050
|
+
);
|
|
10051
|
+
}
|
|
9797
10052
|
const usedCodePoints = collectUsedCodePointsFromPdfUnit(snapshot, effectiveData);
|
|
9798
|
-
const subset =
|
|
9799
|
-
|
|
9800
|
-
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
const fontFileRef = pdfDoc.context.register(fontFileStream);
|
|
9804
|
-
const scaledWidths = subset.gidAdvanceWidths.map((w) => Math.round(w * scale));
|
|
9805
|
-
const fontDescriptorRef2 = pdfDoc.context.register(
|
|
9806
|
-
pdfDoc.context.obj({
|
|
9807
|
-
Type: "FontDescriptor",
|
|
9808
|
-
FontName: "UNVPDF+SubsetTTF",
|
|
9809
|
-
Flags: 32,
|
|
9810
|
-
FontBBox: subset.bbox.map((v) => Math.round(v * scale)),
|
|
9811
|
-
ItalicAngle: 0,
|
|
9812
|
-
Ascent: Math.round(subset.ascent * scale),
|
|
9813
|
-
Descent: Math.round(subset.descent * scale),
|
|
9814
|
-
CapHeight: Math.round(subset.ascent * scale),
|
|
9815
|
-
StemV: 80,
|
|
9816
|
-
FontFile2: fontFileRef
|
|
9817
|
-
})
|
|
9818
|
-
);
|
|
9819
|
-
const cidFontRef2 = pdfDoc.context.register(
|
|
9820
|
-
pdfDoc.context.obj({
|
|
9821
|
-
Type: "Font",
|
|
9822
|
-
Subtype: "CIDFontType2",
|
|
9823
|
-
BaseFont: "UNVPDF+SubsetTTF",
|
|
9824
|
-
CIDSystemInfo: {
|
|
9825
|
-
Registry: import_pdf_lib3.PDFString.of("Adobe"),
|
|
9826
|
-
Ordering: import_pdf_lib3.PDFString.of("Identity"),
|
|
9827
|
-
Supplement: 0
|
|
9828
|
-
},
|
|
9829
|
-
FontDescriptor: fontDescriptorRef2,
|
|
9830
|
-
DW: 1e3,
|
|
9831
|
-
W: [0, scaledWidths],
|
|
9832
|
-
CIDToGIDMap: "Identity"
|
|
9833
|
-
})
|
|
10053
|
+
const { type0FontRef: type0FontRef2, subset } = registerSubsetType0FontInDoc(
|
|
10054
|
+
pdfDoc,
|
|
10055
|
+
resolvedFontBytes,
|
|
10056
|
+
usedCodePoints,
|
|
10057
|
+
"UNVPDF+SubsetTTF"
|
|
9834
10058
|
);
|
|
9835
|
-
const
|
|
9836
|
-
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
Subtype: "Type0",
|
|
9841
|
-
BaseFont: "UNVPDF+SubsetTTF",
|
|
9842
|
-
Encoding: "Identity-H",
|
|
9843
|
-
DescendantFonts: [cidFontRef2],
|
|
9844
|
-
ToUnicode: toUnicodeRef
|
|
9845
|
-
})
|
|
10059
|
+
const missingItems = collectMissingGlyphsFromPdfUnit(
|
|
10060
|
+
snapshot,
|
|
10061
|
+
(cp) => (subset.codePointToGid[cp] ?? 0) > 0,
|
|
10062
|
+
effectiveData,
|
|
10063
|
+
formatPdfTableCell
|
|
9846
10064
|
);
|
|
10065
|
+
if (missingItems.length > 0) {
|
|
10066
|
+
const missingPolicy = options?.render?.missingGlyph ?? "warn";
|
|
10067
|
+
if (missingPolicy === "error") {
|
|
10068
|
+
const desc = missingItems.map(
|
|
10069
|
+
(m) => `${m.pageId ? `${m.pageId}/` : ""}${m.elementId}: ${m.chars.map((c, idx) => `'${c}' (${m.codePoints[idx]})`).join(", ")}`
|
|
10070
|
+
).join("; ");
|
|
10071
|
+
throw new PdfRenderError(
|
|
10072
|
+
"MISSING_GLYPH",
|
|
10073
|
+
`PDF \u5B50\u96C6\u5B57\u4F53\u7F3A\u5C11\u6587\u6863\u6240\u9700\u5B57\u5F62\uFF1A${desc}`,
|
|
10074
|
+
{ missingGlyphs: missingItems }
|
|
10075
|
+
);
|
|
10076
|
+
}
|
|
10077
|
+
if (options?.render?.onWarning) {
|
|
10078
|
+
for (const item of missingItems) {
|
|
10079
|
+
options.render.onWarning({
|
|
10080
|
+
code: "MISSING_GLYPH",
|
|
10081
|
+
pageId: item.pageId,
|
|
10082
|
+
elementId: item.elementId,
|
|
10083
|
+
message: `\u5143\u7D20 ${item.elementId} \u542B\u5F53\u524D\u5B57\u4F53\u7F3A\u5931\u7684\u5B57\u5F62\uFF1A${item.chars.map((c, idx) => `'${c}' (${item.codePoints[idx]})`).join(", ")}`,
|
|
10084
|
+
details: { chars: item.chars, codePoints: item.codePoints }
|
|
10085
|
+
});
|
|
10086
|
+
}
|
|
10087
|
+
}
|
|
10088
|
+
}
|
|
10089
|
+
let boldType0FontRef;
|
|
10090
|
+
let boldSubset;
|
|
10091
|
+
const boldBytes = preResolved?.boldFontBytes ?? options?.customBoldFontBytes;
|
|
10092
|
+
if (boldBytes && boldBytes.byteLength > 0) {
|
|
10093
|
+
const regBold = registerSubsetType0FontInDoc(
|
|
10094
|
+
pdfDoc,
|
|
10095
|
+
boldBytes,
|
|
10096
|
+
usedCodePoints,
|
|
10097
|
+
"UNVPDF+SubsetTTFBold"
|
|
10098
|
+
);
|
|
10099
|
+
boldType0FontRef = regBold.type0FontRef;
|
|
10100
|
+
boldSubset = regBold.subset;
|
|
10101
|
+
}
|
|
9847
10102
|
return {
|
|
9848
10103
|
mode: "subset-ttf",
|
|
9849
10104
|
type0FontRef: type0FontRef2,
|
|
9850
10105
|
subset,
|
|
9851
|
-
pageFontKeys: /* @__PURE__ */ new WeakMap()
|
|
10106
|
+
pageFontKeys: /* @__PURE__ */ new WeakMap(),
|
|
10107
|
+
...boldType0FontRef ? { boldType0FontRef, boldSubset, boldPageFontKeys: /* @__PURE__ */ new WeakMap() } : {}
|
|
9852
10108
|
};
|
|
9853
10109
|
}
|
|
9854
10110
|
const fontDescriptorRef = pdfDoc.context.register(
|
|
@@ -9893,24 +10149,127 @@ function initVectorCjkEmbedState(pdfDoc, snapshot, effectiveData, options) {
|
|
|
9893
10149
|
pageFontKeys: /* @__PURE__ */ new WeakMap()
|
|
9894
10150
|
};
|
|
9895
10151
|
}
|
|
9896
|
-
function getOrRegisterPageCjkFontKey(page, state) {
|
|
10152
|
+
function getOrRegisterPageCjkFontKey(page, state, wantBold = false) {
|
|
10153
|
+
if (wantBold && state.boldType0FontRef && state.boldSubset && state.boldPageFontKeys) {
|
|
10154
|
+
const existingBold = state.boldPageFontKeys.get(page);
|
|
10155
|
+
if (existingBold) {
|
|
10156
|
+
return { fontKey: existingBold, activeSubset: state.boldSubset, usedDedicatedBold: true };
|
|
10157
|
+
}
|
|
10158
|
+
const boldKey = page.node.newFontDictionary("FSubB", state.boldType0FontRef);
|
|
10159
|
+
state.boldPageFontKeys.set(page, boldKey);
|
|
10160
|
+
return { fontKey: boldKey, activeSubset: state.boldSubset, usedDedicatedBold: true };
|
|
10161
|
+
}
|
|
9897
10162
|
const existing = state.pageFontKeys.get(page);
|
|
9898
|
-
if (existing)
|
|
10163
|
+
if (existing) {
|
|
10164
|
+
return { fontKey: existing, activeSubset: state.subset, usedDedicatedBold: false };
|
|
10165
|
+
}
|
|
9899
10166
|
const key = page.node.newFontDictionary(state.mode === "subset-ttf" ? "FSub" : "FCid", state.type0FontRef);
|
|
9900
10167
|
state.pageFontKeys.set(page, key);
|
|
9901
|
-
return key;
|
|
10168
|
+
return { fontKey: key, activeSubset: state.subset, usedDedicatedBold: false };
|
|
10169
|
+
}
|
|
10170
|
+
function isIdeographOrFullwidthCodePoint(cp) {
|
|
10171
|
+
return cp >= 11904 && cp <= 40959 || cp >= 44032 && cp <= 55215 || cp >= 63744 && cp <= 64255 || cp >= 65072 && cp <= 65135 || cp >= 65280 && cp <= 65519 || cp >= 126976;
|
|
10172
|
+
}
|
|
10173
|
+
function wrapMixedCjkAndLatinLines(rawText, maxWidthPt, measureFn) {
|
|
10174
|
+
const normalized = rawText.replace(/\r\n?/g, "\n");
|
|
10175
|
+
const limit = Math.max(1, maxWidthPt);
|
|
10176
|
+
const out = [];
|
|
10177
|
+
const tokenizeParagraph = (para) => {
|
|
10178
|
+
const tokens = [];
|
|
10179
|
+
let buf = "";
|
|
10180
|
+
let bufKind = null;
|
|
10181
|
+
for (const ch of para) {
|
|
10182
|
+
const cp = ch.codePointAt(0) ?? 32;
|
|
10183
|
+
if (ch === " " || ch === " ") {
|
|
10184
|
+
if (bufKind === "space") {
|
|
10185
|
+
buf += ch;
|
|
10186
|
+
} else {
|
|
10187
|
+
if (buf) tokens.push({ kind: bufKind, text: buf });
|
|
10188
|
+
buf = ch;
|
|
10189
|
+
bufKind = "space";
|
|
10190
|
+
}
|
|
10191
|
+
} else if (isIdeographOrFullwidthCodePoint(cp)) {
|
|
10192
|
+
if (buf) {
|
|
10193
|
+
tokens.push({ kind: bufKind, text: buf });
|
|
10194
|
+
buf = "";
|
|
10195
|
+
bufKind = null;
|
|
10196
|
+
}
|
|
10197
|
+
tokens.push({ kind: "cjk", text: ch });
|
|
10198
|
+
} else {
|
|
10199
|
+
if (bufKind === "word") {
|
|
10200
|
+
buf += ch;
|
|
10201
|
+
} else {
|
|
10202
|
+
if (buf) tokens.push({ kind: bufKind, text: buf });
|
|
10203
|
+
buf = ch;
|
|
10204
|
+
bufKind = "word";
|
|
10205
|
+
}
|
|
10206
|
+
}
|
|
10207
|
+
}
|
|
10208
|
+
if (buf && bufKind) {
|
|
10209
|
+
tokens.push({ kind: bufKind, text: buf });
|
|
10210
|
+
}
|
|
10211
|
+
return tokens;
|
|
10212
|
+
};
|
|
10213
|
+
for (const para of normalized.split("\n")) {
|
|
10214
|
+
if (!para) {
|
|
10215
|
+
out.push({ text: "", isLastInParagraph: true });
|
|
10216
|
+
continue;
|
|
10217
|
+
}
|
|
10218
|
+
const tokens = tokenizeParagraph(para);
|
|
10219
|
+
let current = "";
|
|
10220
|
+
for (const tok of tokens) {
|
|
10221
|
+
if (tok.kind === "space") {
|
|
10222
|
+
if (!current) continue;
|
|
10223
|
+
const candidate2 = current + tok.text;
|
|
10224
|
+
if (measureFn(candidate2) <= limit) {
|
|
10225
|
+
current = candidate2;
|
|
10226
|
+
} else {
|
|
10227
|
+
out.push({ text: current.replace(/[ \t]+$/g, ""), isLastInParagraph: false });
|
|
10228
|
+
current = "";
|
|
10229
|
+
}
|
|
10230
|
+
continue;
|
|
10231
|
+
}
|
|
10232
|
+
const candidate = current + tok.text;
|
|
10233
|
+
if (measureFn(candidate) <= limit) {
|
|
10234
|
+
current = candidate;
|
|
10235
|
+
continue;
|
|
10236
|
+
}
|
|
10237
|
+
if (current) {
|
|
10238
|
+
out.push({ text: current.replace(/[ \t]+$/g, ""), isLastInParagraph: false });
|
|
10239
|
+
current = "";
|
|
10240
|
+
}
|
|
10241
|
+
if (measureFn(tok.text) <= limit || Array.from(tok.text).length <= 1) {
|
|
10242
|
+
current = tok.text;
|
|
10243
|
+
} else {
|
|
10244
|
+
let charBuf = "";
|
|
10245
|
+
for (const ch of tok.text) {
|
|
10246
|
+
const nextBuf = charBuf + ch;
|
|
10247
|
+
if (measureFn(nextBuf) > limit && charBuf.length > 0) {
|
|
10248
|
+
out.push({ text: charBuf, isLastInParagraph: false });
|
|
10249
|
+
charBuf = ch;
|
|
10250
|
+
} else {
|
|
10251
|
+
charBuf = nextBuf;
|
|
10252
|
+
}
|
|
10253
|
+
}
|
|
10254
|
+
current = charBuf;
|
|
10255
|
+
}
|
|
10256
|
+
}
|
|
10257
|
+
out.push({ text: current.replace(/[ \t]+$/g, ""), isLastInParagraph: true });
|
|
10258
|
+
}
|
|
10259
|
+
return out;
|
|
9902
10260
|
}
|
|
9903
|
-
function measureVectorCjkLine(line, fontSize, state, characterSpacing = 0) {
|
|
10261
|
+
function measureVectorCjkLine(line, fontSize, state, characterSpacing = 0, overrideSubset) {
|
|
9904
10262
|
if (!line) return 0;
|
|
9905
10263
|
const glyphCount = Array.from(line).length;
|
|
9906
10264
|
const extraTc = glyphCount > 1 ? (glyphCount - 1) * characterSpacing : 0;
|
|
9907
|
-
|
|
9908
|
-
|
|
10265
|
+
const sub = overrideSubset ?? state.subset;
|
|
10266
|
+
if (state.mode === "subset-ttf" && sub) {
|
|
10267
|
+
const upem = sub.unitsPerEm || 1e3;
|
|
9909
10268
|
let totalUnits = 0;
|
|
9910
10269
|
for (const ch of line) {
|
|
9911
10270
|
const cp = ch.codePointAt(0) ?? 63;
|
|
9912
|
-
const gid =
|
|
9913
|
-
totalUnits +=
|
|
10271
|
+
const gid = sub.codePointToGid[cp] ?? 0;
|
|
10272
|
+
totalUnits += sub.gidAdvanceWidths[gid] ?? upem;
|
|
9914
10273
|
}
|
|
9915
10274
|
return totalUnits * fontSize / upem + extraTc;
|
|
9916
10275
|
}
|
|
@@ -9921,12 +10280,13 @@ function measureVectorCjkLine(line, fontSize, state, characterSpacing = 0) {
|
|
|
9921
10280
|
}
|
|
9922
10281
|
return width + extraTc;
|
|
9923
10282
|
}
|
|
9924
|
-
function encodeVectorCjkLineHex(line, state) {
|
|
9925
|
-
|
|
10283
|
+
function encodeVectorCjkLineHex(line, state, overrideSubset) {
|
|
10284
|
+
const sub = overrideSubset ?? state.subset;
|
|
10285
|
+
if (state.mode === "subset-ttf" && sub) {
|
|
9926
10286
|
let hex = "";
|
|
9927
10287
|
for (const ch of line) {
|
|
9928
10288
|
const cp = ch.codePointAt(0) ?? 63;
|
|
9929
|
-
const gid =
|
|
10289
|
+
const gid = sub.codePointToGid[cp] ?? 0;
|
|
9930
10290
|
hex += gid.toString(16).padStart(4, "0").toUpperCase();
|
|
9931
10291
|
}
|
|
9932
10292
|
return hex;
|
|
@@ -9934,38 +10294,21 @@ function encodeVectorCjkLineHex(line, state) {
|
|
|
9934
10294
|
return toUtf16BeHex(line, true);
|
|
9935
10295
|
}
|
|
9936
10296
|
function drawVectorCjkTextBox(page, pageHeight, text, left, top, width, height, style, state, noWrapSingleLine = false, colorType, overrideCharacterSpacing) {
|
|
9937
|
-
const
|
|
10297
|
+
const wantBold = style?.fontWeight === "bold";
|
|
10298
|
+
const { fontKey, activeSubset, usedDedicatedBold } = getOrRegisterPageCjkFontKey(page, state, wantBold);
|
|
9938
10299
|
const fontSize = style?.fontSize ?? 12;
|
|
9939
10300
|
const pad = style?.padding ?? 4;
|
|
9940
|
-
const maxWidth = Math.max(
|
|
10301
|
+
const maxWidth = Math.max(1, width - pad * 2);
|
|
9941
10302
|
const lineHeight = fontSize * (style?.lineHeight ?? 1.38);
|
|
9942
10303
|
const color = parseHexColor(style?.color) ?? { r: 0.12, g: 0.14, b: 0.16, a: 1 };
|
|
9943
10304
|
const charSpacing = overrideCharacterSpacing ?? style?.characterSpacing ?? 0;
|
|
9944
10305
|
const pdfY = pageHeight - top - height;
|
|
9945
|
-
const
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9949
|
-
|
|
9950
|
-
|
|
9951
|
-
for (const para of text.split("\n")) {
|
|
9952
|
-
if (!para) {
|
|
9953
|
-
lines.push({ text: "", isLastInParagraph: true });
|
|
9954
|
-
continue;
|
|
9955
|
-
}
|
|
9956
|
-
let current = "";
|
|
9957
|
-
for (const ch of para) {
|
|
9958
|
-
const candidate = current + ch;
|
|
9959
|
-
if (measureVectorCjkLine(candidate, fontSize, state, charSpacing) > maxWidth && current.length > 0) {
|
|
9960
|
-
lines.push({ text: current, isLastInParagraph: false });
|
|
9961
|
-
current = ch;
|
|
9962
|
-
} else {
|
|
9963
|
-
current = candidate;
|
|
9964
|
-
}
|
|
9965
|
-
}
|
|
9966
|
-
if (current) lines.push({ text: current, isLastInParagraph: true });
|
|
9967
|
-
}
|
|
9968
|
-
}
|
|
10306
|
+
const normalized = text.replace(/\r\n?/g, "\n");
|
|
10307
|
+
const lines = noWrapSingleLine ? normalized.split("\n").map((para) => ({ text: para, isLastInParagraph: true })) : wrapMixedCjkAndLatinLines(
|
|
10308
|
+
normalized,
|
|
10309
|
+
maxWidth,
|
|
10310
|
+
(s) => measureVectorCjkLine(s, fontSize, state, charSpacing, activeSubset)
|
|
10311
|
+
);
|
|
9969
10312
|
const totalH = lines.length * lineHeight;
|
|
9970
10313
|
let firstBaselineFromTop = pad + fontSize * 0.85;
|
|
9971
10314
|
if (style?.verticalAlign === "middle") {
|
|
@@ -9977,12 +10320,34 @@ function drawVectorCjkTextBox(page, pageHeight, text, left, top, width, height,
|
|
|
9977
10320
|
const cm = rgbToCmyk(color.r, color.g, color.b);
|
|
9978
10321
|
return (0, import_pdf_lib3.setFillingCmykColor)(cm.c, cm.m, cm.y, cm.k);
|
|
9979
10322
|
})() : (0, import_pdf_lib3.setFillingRgbColor)(color.r, color.g, color.b);
|
|
10323
|
+
const syntheticBoldOps = wantBold && !usedDedicatedBold ? [
|
|
10324
|
+
import_pdf_lib3.PDFOperator.of("Tr", [import_pdf_lib3.PDFNumber.of(2)]),
|
|
10325
|
+
(0, import_pdf_lib3.setLineWidth)(Math.max(0.25, fontSize * 0.032)),
|
|
10326
|
+
colorType === "cmyk" ? (() => {
|
|
10327
|
+
const cm = rgbToCmyk(color.r, color.g, color.b);
|
|
10328
|
+
return (0, import_pdf_lib3.setStrokingCmykColor)(cm.c, cm.m, cm.y, cm.k);
|
|
10329
|
+
})() : (0, import_pdf_lib3.setStrokingRgbColor)(color.r, color.g, color.b)
|
|
10330
|
+
] : [];
|
|
9980
10331
|
const decoCol = toPdfLibColor(color, colorType);
|
|
9981
10332
|
const decoThickness = Math.max(0.6, fontSize * 0.065);
|
|
10333
|
+
const applyClip = !noWrapSingleLine && width > 0 && height > 0;
|
|
10334
|
+
if (applyClip) {
|
|
10335
|
+
page.pushOperators(
|
|
10336
|
+
(0, import_pdf_lib3.pushGraphicsState)(),
|
|
10337
|
+
(0, import_pdf_lib3.rectangle)(left, pdfY, width, height),
|
|
10338
|
+
(0, import_pdf_lib3.clip)(),
|
|
10339
|
+
(0, import_pdf_lib3.endPath)()
|
|
10340
|
+
);
|
|
10341
|
+
}
|
|
9982
10342
|
for (let i = 0; i < lines.length; i++) {
|
|
9983
10343
|
const { text: line, isLastInParagraph } = lines[i];
|
|
9984
10344
|
if (!line) continue;
|
|
9985
|
-
const
|
|
10345
|
+
const drawY = pageHeight - top - (firstBaselineFromTop + i * lineHeight);
|
|
10346
|
+
if (!noWrapSingleLine) {
|
|
10347
|
+
if (i === 0 && height < fontSize * 0.55) break;
|
|
10348
|
+
if (i > 0 && drawY - fontSize * 0.14 < pdfY) break;
|
|
10349
|
+
}
|
|
10350
|
+
const lineW = measureVectorCjkLine(line, fontSize, state, charSpacing, activeSubset);
|
|
9986
10351
|
let drawX = left + pad;
|
|
9987
10352
|
let effectiveLineW = lineW;
|
|
9988
10353
|
let extraJustifyTc = 0;
|
|
@@ -9997,9 +10362,7 @@ function drawVectorCjkTextBox(page, pageHeight, text, left, top, width, height,
|
|
|
9997
10362
|
effectiveLineW = maxWidth;
|
|
9998
10363
|
}
|
|
9999
10364
|
}
|
|
10000
|
-
const
|
|
10001
|
-
if (drawY < pdfY - 2 && !noWrapSingleLine) break;
|
|
10002
|
-
const hexStr = encodeVectorCjkLineHex(line, state);
|
|
10365
|
+
const hexStr = encodeVectorCjkLineHex(line, state, activeSubset);
|
|
10003
10366
|
const totalTc = charSpacing + extraJustifyTc;
|
|
10004
10367
|
const posOp = style?.italic ? import_pdf_lib3.PDFOperator.of("Tm", [
|
|
10005
10368
|
import_pdf_lib3.PDFNumber.of(1),
|
|
@@ -10013,6 +10376,7 @@ function drawVectorCjkTextBox(page, pageHeight, text, left, top, width, height,
|
|
|
10013
10376
|
(0, import_pdf_lib3.pushGraphicsState)(),
|
|
10014
10377
|
(0, import_pdf_lib3.beginText)(),
|
|
10015
10378
|
fillOp,
|
|
10379
|
+
...syntheticBoldOps,
|
|
10016
10380
|
(0, import_pdf_lib3.setFontAndSize)(fontKey, fontSize),
|
|
10017
10381
|
...totalTc !== 0 ? [(0, import_pdf_lib3.setCharacterSpacing)(totalTc)] : [],
|
|
10018
10382
|
posOp,
|
|
@@ -10041,6 +10405,9 @@ function drawVectorCjkTextBox(page, pageHeight, text, left, top, width, height,
|
|
|
10041
10405
|
});
|
|
10042
10406
|
}
|
|
10043
10407
|
}
|
|
10408
|
+
if (applyClip) {
|
|
10409
|
+
page.pushOperators((0, import_pdf_lib3.popGraphicsState)());
|
|
10410
|
+
}
|
|
10044
10411
|
}
|
|
10045
10412
|
function renderTextToPngBytesInBrowser(text, widthPt, heightPt, style) {
|
|
10046
10413
|
if (typeof document === "undefined") return null;
|
|
@@ -10059,27 +10426,10 @@ function renderTextToPngBytesInBrowser(text, widthPt, heightPt, style) {
|
|
|
10059
10426
|
ctx.fillStyle = style?.color ?? "#1f2329";
|
|
10060
10427
|
ctx.textBaseline = "top";
|
|
10061
10428
|
const pad = style?.padding ?? 4;
|
|
10062
|
-
const maxWidth = Math.max(
|
|
10063
|
-
const lineHeight = fontSize * (style?.lineHeight ?? 1.
|
|
10064
|
-
const
|
|
10065
|
-
const lines =
|
|
10066
|
-
for (const para of paragraphs) {
|
|
10067
|
-
if (!para) {
|
|
10068
|
-
lines.push("");
|
|
10069
|
-
continue;
|
|
10070
|
-
}
|
|
10071
|
-
let current = "";
|
|
10072
|
-
for (const ch of para) {
|
|
10073
|
-
const test = current + ch;
|
|
10074
|
-
if (ctx.measureText(test).width > maxWidth && current.length > 0) {
|
|
10075
|
-
lines.push(current);
|
|
10076
|
-
current = ch;
|
|
10077
|
-
} else {
|
|
10078
|
-
current = test;
|
|
10079
|
-
}
|
|
10080
|
-
}
|
|
10081
|
-
if (current) lines.push(current);
|
|
10082
|
-
}
|
|
10429
|
+
const maxWidth = Math.max(1, widthPt - pad * 2);
|
|
10430
|
+
const lineHeight = fontSize * (style?.lineHeight ?? 1.38);
|
|
10431
|
+
const wrapped = wrapMixedCjkAndLatinLines(text, maxWidth, (s) => ctx.measureText(s).width);
|
|
10432
|
+
const lines = wrapped.map((w) => w.text);
|
|
10083
10433
|
const totalTextHeight = lines.length * lineHeight;
|
|
10084
10434
|
let startY = pad;
|
|
10085
10435
|
if (style?.verticalAlign === "middle") {
|
|
@@ -10089,15 +10439,17 @@ function renderTextToPngBytesInBrowser(text, widthPt, heightPt, style) {
|
|
|
10089
10439
|
}
|
|
10090
10440
|
for (let i = 0; i < lines.length; i++) {
|
|
10091
10441
|
const line = lines[i];
|
|
10442
|
+
if (!line) continue;
|
|
10443
|
+
const y = startY + i * lineHeight;
|
|
10444
|
+
if (i === 0 && heightPt < fontSize * 0.55) break;
|
|
10445
|
+
if (i > 0 && y + fontSize > heightPt + 1) break;
|
|
10092
10446
|
const lineWidth = ctx.measureText(line).width;
|
|
10093
10447
|
let x = pad;
|
|
10094
10448
|
if (style?.textAlign === "center") {
|
|
10095
|
-
x = (widthPt - lineWidth) / 2;
|
|
10449
|
+
x = Math.max(pad, (widthPt - lineWidth) / 2);
|
|
10096
10450
|
} else if (style?.textAlign === "right") {
|
|
10097
|
-
x = widthPt - pad - lineWidth;
|
|
10451
|
+
x = Math.max(pad, widthPt - pad - lineWidth);
|
|
10098
10452
|
}
|
|
10099
|
-
const y = startY + i * lineHeight;
|
|
10100
|
-
if (y + fontSize > heightPt + 2) break;
|
|
10101
10453
|
ctx.fillText(line, x, y);
|
|
10102
10454
|
if (style?.underline) {
|
|
10103
10455
|
ctx.beginPath();
|
|
@@ -10545,57 +10897,14 @@ async function drawTextBox(pdfDoc, page, pageHeight, text, left, top, width, hei
|
|
|
10545
10897
|
const pad = style?.padding ?? 4;
|
|
10546
10898
|
const color = parseHexColor(style?.color) ?? { r: 0.12, g: 0.14, b: 0.16, a: 1 };
|
|
10547
10899
|
const pdfCol = toPdfLibColor(color, colorType);
|
|
10548
|
-
const maxLineW = Math.max(
|
|
10549
|
-
const lineHeight = fontSize * (style?.lineHeight ?? 1.
|
|
10900
|
+
const maxLineW = Math.max(1, bgWidth - pad * 2);
|
|
10901
|
+
const lineHeight = fontSize * (style?.lineHeight ?? 1.38);
|
|
10902
|
+
const normalizedText = text.replace(/\r\n?/g, "\n");
|
|
10550
10903
|
const measureAscii = (s) => {
|
|
10551
10904
|
if (!s) return 0;
|
|
10552
10905
|
return font.widthOfTextAtSize(s, fontSize) + (s.length > 1 ? (s.length - 1) * charSpacing : 0);
|
|
10553
10906
|
};
|
|
10554
|
-
const wrappedLines =
|
|
10555
|
-
if (extraOpts?.noWrapSingleLine) {
|
|
10556
|
-
for (const para of text.split("\n")) {
|
|
10557
|
-
wrappedLines.push({ text: para, isLastInParagraph: true });
|
|
10558
|
-
}
|
|
10559
|
-
} else {
|
|
10560
|
-
for (const para of text.split("\n")) {
|
|
10561
|
-
if (!para) {
|
|
10562
|
-
wrappedLines.push({ text: "", isLastInParagraph: true });
|
|
10563
|
-
continue;
|
|
10564
|
-
}
|
|
10565
|
-
const tokens = para.split(/( +)/).filter((t) => t.length > 0);
|
|
10566
|
-
let current = "";
|
|
10567
|
-
for (const tok of tokens) {
|
|
10568
|
-
const candidate = current ? current + tok : tok.replace(/^ +/, "");
|
|
10569
|
-
if (!candidate) continue;
|
|
10570
|
-
if (measureAscii(candidate) <= maxLineW) {
|
|
10571
|
-
current = candidate;
|
|
10572
|
-
continue;
|
|
10573
|
-
}
|
|
10574
|
-
if (current) {
|
|
10575
|
-
wrappedLines.push({ text: current.trimEnd(), isLastInParagraph: false });
|
|
10576
|
-
current = "";
|
|
10577
|
-
}
|
|
10578
|
-
const trimmedTok = tok.replace(/^ +/, "");
|
|
10579
|
-
if (!trimmedTok) continue;
|
|
10580
|
-
if (measureAscii(trimmedTok) <= maxLineW) {
|
|
10581
|
-
current = trimmedTok;
|
|
10582
|
-
} else {
|
|
10583
|
-
let charBuf = "";
|
|
10584
|
-
for (const ch of trimmedTok) {
|
|
10585
|
-
const nextBuf = charBuf + ch;
|
|
10586
|
-
if (measureAscii(nextBuf) > maxLineW && charBuf.length > 0) {
|
|
10587
|
-
wrappedLines.push({ text: charBuf, isLastInParagraph: false });
|
|
10588
|
-
charBuf = ch;
|
|
10589
|
-
} else {
|
|
10590
|
-
charBuf = nextBuf;
|
|
10591
|
-
}
|
|
10592
|
-
}
|
|
10593
|
-
current = charBuf;
|
|
10594
|
-
}
|
|
10595
|
-
}
|
|
10596
|
-
wrappedLines.push({ text: current.trimEnd(), isLastInParagraph: true });
|
|
10597
|
-
}
|
|
10598
|
-
}
|
|
10907
|
+
const wrappedLines = extraOpts?.noWrapSingleLine ? normalizedText.split("\n").map((para) => ({ text: para, isLastInParagraph: true })) : wrapMixedCjkAndLatinLines(normalizedText, maxLineW, measureAscii);
|
|
10599
10908
|
let singleLineDrawY = pageHeight - top - pad - fontSize * 0.85;
|
|
10600
10909
|
if (style?.verticalAlign === "middle") {
|
|
10601
10910
|
singleLineDrawY = pdfY + (height - fontSize * 0.75) / 2;
|
|
@@ -10610,12 +10919,22 @@ async function drawTextBox(pdfDoc, page, pageHeight, text, left, top, width, hei
|
|
|
10610
10919
|
firstBaselineFromTop = Math.max(pad + fontSize * 0.78, height - pad - totalH + fontSize * 0.85);
|
|
10611
10920
|
}
|
|
10612
10921
|
const decoThickness = Math.max(0.6, fontSize * 0.065);
|
|
10922
|
+
const applyAsciiClip = !extraOpts?.noWrapSingleLine && bgWidth > 0 && height > 0;
|
|
10923
|
+
if (applyAsciiClip) {
|
|
10924
|
+
page.pushOperators(
|
|
10925
|
+
(0, import_pdf_lib3.pushGraphicsState)(),
|
|
10926
|
+
(0, import_pdf_lib3.rectangle)(left, pdfY, bgWidth, height),
|
|
10927
|
+
(0, import_pdf_lib3.clip)(),
|
|
10928
|
+
(0, import_pdf_lib3.endPath)()
|
|
10929
|
+
);
|
|
10930
|
+
}
|
|
10613
10931
|
for (let i = 0; i < wrappedLines.length; i++) {
|
|
10614
10932
|
const { text: lineText, isLastInParagraph } = wrappedLines[i];
|
|
10615
10933
|
if (!lineText) continue;
|
|
10616
10934
|
const baselineY = wrappedLines.length === 1 ? singleLineDrawY : pageHeight - top - (firstBaselineFromTop + i * lineHeight);
|
|
10617
|
-
if (
|
|
10618
|
-
break;
|
|
10935
|
+
if (!extraOpts?.noWrapSingleLine) {
|
|
10936
|
+
if (i === 0 && height < fontSize * 0.55) break;
|
|
10937
|
+
if (i > 0 && baselineY - fontSize * 0.14 < pdfY) break;
|
|
10619
10938
|
}
|
|
10620
10939
|
const rawLineW = measureAscii(lineText);
|
|
10621
10940
|
let drawX = left + pad;
|
|
@@ -10685,6 +11004,9 @@ async function drawTextBox(pdfDoc, page, pageHeight, text, left, top, width, hei
|
|
|
10685
11004
|
});
|
|
10686
11005
|
}
|
|
10687
11006
|
}
|
|
11007
|
+
if (applyAsciiClip) {
|
|
11008
|
+
page.pushOperators((0, import_pdf_lib3.popGraphicsState)());
|
|
11009
|
+
}
|
|
10688
11010
|
}
|
|
10689
11011
|
function parseNumericCellValue(rawValue) {
|
|
10690
11012
|
if (typeof rawValue === "number") {
|
|
@@ -10787,19 +11109,53 @@ function resolveDynamicTableRawRows(el, data) {
|
|
|
10787
11109
|
}
|
|
10788
11110
|
return el.rows ?? [];
|
|
10789
11111
|
}
|
|
10790
|
-
function
|
|
11112
|
+
function calculatePdfTableRowCapacity(el, pageHeight, marginsPt) {
|
|
11113
|
+
const showHead = el.showHead !== false;
|
|
11114
|
+
const repeatHeader = el.repeatHeader !== false;
|
|
11115
|
+
const headerH = showHead ? el.headerHeight ?? 26 : 0;
|
|
11116
|
+
const rowH = el.rowHeight ?? 24;
|
|
11117
|
+
const subtotalSlot = el.showPageSubtotal ? 1 : 0;
|
|
11118
|
+
const grandTotalSlot = el.showGrandTotal ? 1 : 0;
|
|
11119
|
+
const bottomGuard = Math.max(8, marginsPt?.bottom ?? 0);
|
|
11120
|
+
const maxPageSpan = Math.max(headerH + rowH, pageHeight - el.transform.top - bottomGuard);
|
|
11121
|
+
const availableFirstPageHeight = el.transform.height > 0 ? Math.min(el.transform.height, maxPageSpan) : maxPageSpan;
|
|
11122
|
+
const firstBodySlots = Math.max(
|
|
11123
|
+
1 + subtotalSlot + grandTotalSlot,
|
|
11124
|
+
Math.floor((availableFirstPageHeight - headerH) / rowH)
|
|
11125
|
+
);
|
|
11126
|
+
const firstPageRows = Math.max(1, firstBodySlots - subtotalSlot - grandTotalSlot);
|
|
11127
|
+
const contHeaderH = showHead && repeatHeader ? headerH : 0;
|
|
11128
|
+
const contBodySlots = Math.max(
|
|
11129
|
+
1 + subtotalSlot,
|
|
11130
|
+
Math.floor((availableFirstPageHeight - contHeaderH) / rowH)
|
|
11131
|
+
);
|
|
11132
|
+
const continuationPageRows = Math.max(1, contBodySlots - subtotalSlot);
|
|
11133
|
+
return {
|
|
11134
|
+
capacityRows: firstPageRows,
|
|
11135
|
+
firstPageRows,
|
|
11136
|
+
continuationPageRows,
|
|
11137
|
+
headerHeight: headerH,
|
|
11138
|
+
rowHeight: rowH,
|
|
11139
|
+
availableFirstPageHeight
|
|
11140
|
+
};
|
|
11141
|
+
}
|
|
11142
|
+
function paginatePdfTableRows(el, rawRows, pageHeight, paginationOpts) {
|
|
10791
11143
|
const showHead = el.showHead !== false;
|
|
11144
|
+
const repeatHeader = paginationOpts?.repeatHeader ?? el.repeatHeader ?? true;
|
|
11145
|
+
const tablePagination = paginationOpts?.tablePagination ?? el.pagination ?? "auto";
|
|
10792
11146
|
const headerH = showHead ? el.headerHeight ?? 26 : 0;
|
|
10793
11147
|
const rowH = el.rowHeight ?? 24;
|
|
10794
11148
|
const subtotalLabel = el.pageSubtotalLabel || "\u672C\u9875\u5C0F\u8BA1";
|
|
10795
11149
|
const grandTotalLabel = el.grandTotalLabel || "\u603B\u8BA1";
|
|
10796
11150
|
const subtotalSlot = el.showPageSubtotal ? 1 : 0;
|
|
10797
11151
|
const grandTotalSlot = el.showGrandTotal ? 1 : 0;
|
|
10798
|
-
const
|
|
11152
|
+
const marginTopGuard = Math.max(36, paginationOpts?.marginTopPt ?? 0);
|
|
11153
|
+
const bottomGuard = Math.max(8, paginationOpts?.marginBottomPt ?? 0);
|
|
11154
|
+
const remainingOnStartPage = pageHeight - el.transform.top - Math.max(4, paginationOpts?.marginBottomPt ?? 0);
|
|
10799
11155
|
const minRequiredForHeaderPlusOneRow = headerH + rowH * (1 + subtotalSlot);
|
|
10800
|
-
const shouldDeferOrphanHeader = showHead && el.avoidOrphanHeader !== false && rawRows.length > 0 && el.transform.top >
|
|
10801
|
-
const effectiveTop = shouldDeferOrphanHeader ?
|
|
10802
|
-
const maxPageSpan = Math.max(headerH + rowH, pageHeight - effectiveTop -
|
|
11156
|
+
const shouldDeferOrphanHeader = tablePagination !== "none" && showHead && el.avoidOrphanHeader !== false && rawRows.length > 0 && el.transform.top > marginTopGuard && (remainingOnStartPage < headerH + rowH || el.avoidOrphanHeader === true && remainingOnStartPage < minRequiredForHeaderPlusOneRow);
|
|
11157
|
+
const effectiveTop = shouldDeferOrphanHeader ? marginTopGuard : el.transform.top;
|
|
11158
|
+
const maxPageSpan = Math.max(headerH + rowH, pageHeight - effectiveTop - bottomGuard);
|
|
10803
11159
|
const availableHeight = !shouldDeferOrphanHeader && el.transform.height > 0 ? Math.min(el.transform.height, maxPageSpan) : maxPageSpan;
|
|
10804
11160
|
const totalBodySlots = Math.max(
|
|
10805
11161
|
1 + subtotalSlot + grandTotalSlot,
|
|
@@ -10807,23 +11163,46 @@ function paginatePdfTableRows(el, rawRows, pageHeight) {
|
|
|
10807
11163
|
);
|
|
10808
11164
|
const maxDataRegular = Math.max(1, totalBodySlots - subtotalSlot);
|
|
10809
11165
|
const maxDataFinal = Math.max(1, totalBodySlots - subtotalSlot - grandTotalSlot);
|
|
11166
|
+
const contHeaderH = showHead && repeatHeader ? headerH : 0;
|
|
11167
|
+
const contBodySlots = Math.max(
|
|
11168
|
+
totalBodySlots,
|
|
11169
|
+
Math.floor((availableHeight - contHeaderH) / rowH)
|
|
11170
|
+
);
|
|
11171
|
+
const maxContRegular = Math.max(1, contBodySlots - subtotalSlot);
|
|
11172
|
+
const maxContFinal = Math.max(1, contBodySlots - subtotalSlot - grandTotalSlot);
|
|
10810
11173
|
const slices = [];
|
|
10811
|
-
if (
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
11174
|
+
if (tablePagination === "none") {
|
|
11175
|
+
const cap = maxDataFinal;
|
|
11176
|
+
if (rawRows.length > cap) {
|
|
11177
|
+
paginationOpts?.onOverflow?.({
|
|
11178
|
+
capacityRows: cap,
|
|
11179
|
+
actualRows: rawRows.length,
|
|
11180
|
+
overflowRows: rawRows.length - cap
|
|
11181
|
+
});
|
|
11182
|
+
}
|
|
11183
|
+
slices.push({ startRowIndex: 0, rows: rawRows.slice(0, cap) });
|
|
10816
11184
|
} else {
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
11185
|
+
if (shouldDeferOrphanHeader) {
|
|
11186
|
+
slices.push({ startRowIndex: 0, rows: [], deferred: true });
|
|
11187
|
+
}
|
|
11188
|
+
if (rawRows.length === 0) {
|
|
11189
|
+
slices.push({ startRowIndex: 0, rows: [] });
|
|
11190
|
+
} else {
|
|
11191
|
+
let cursor = 0;
|
|
11192
|
+
let isFirstDataChunk = true;
|
|
11193
|
+
while (cursor < rawRows.length) {
|
|
11194
|
+
const remaining = rawRows.length - cursor;
|
|
11195
|
+
const activeFinalCap = isFirstDataChunk ? maxDataFinal : maxContFinal;
|
|
11196
|
+
const activeRegularCap = isFirstDataChunk ? maxDataRegular : maxContRegular;
|
|
11197
|
+
if (remaining <= activeFinalCap) {
|
|
11198
|
+
slices.push({ startRowIndex: cursor, rows: rawRows.slice(cursor) });
|
|
11199
|
+
break;
|
|
11200
|
+
}
|
|
11201
|
+
const takeCount = remaining <= activeRegularCap ? Math.max(1, Math.min(activeRegularCap, remaining - 1)) : activeRegularCap;
|
|
11202
|
+
slices.push({ startRowIndex: cursor, rows: rawRows.slice(cursor, cursor + takeCount) });
|
|
11203
|
+
cursor += takeCount;
|
|
11204
|
+
isFirstDataChunk = false;
|
|
10823
11205
|
}
|
|
10824
|
-
const takeCount = remaining <= maxDataRegular ? Math.max(1, Math.min(maxDataRegular, remaining - 1)) : maxDataRegular;
|
|
10825
|
-
slices.push({ startRowIndex: cursor, rows: rawRows.slice(cursor, cursor + takeCount) });
|
|
10826
|
-
cursor += takeCount;
|
|
10827
11206
|
}
|
|
10828
11207
|
}
|
|
10829
11208
|
const grandTotalRow = el.showGrandTotal ? computePdfTableSummaryRow(rawRows, el.columns, grandTotalLabel) : void 0;
|
|
@@ -10863,7 +11242,40 @@ function resolveBorderDashArray(borderStyle, thickness) {
|
|
|
10863
11242
|
}
|
|
10864
11243
|
return void 0;
|
|
10865
11244
|
}
|
|
10866
|
-
|
|
11245
|
+
function computeShrunkCellFontSize(text, width, height, baseStyle, minFontSizePt, cjkState) {
|
|
11246
|
+
const maxFs = baseStyle.fontSize ?? 9.5;
|
|
11247
|
+
const minFs = Math.max(4, Math.min(maxFs, minFontSizePt));
|
|
11248
|
+
if (!text || maxFs <= minFs) return maxFs;
|
|
11249
|
+
const pad = baseStyle.padding ?? 5;
|
|
11250
|
+
const innerW = Math.max(1, width - pad * 2);
|
|
11251
|
+
const innerH = Math.max(1, height - pad * 2);
|
|
11252
|
+
const lhMul = baseStyle.lineHeight ?? 1.38;
|
|
11253
|
+
const charSp = baseStyle.characterSpacing ?? 0;
|
|
11254
|
+
let candidate = maxFs;
|
|
11255
|
+
while (candidate > minFs) {
|
|
11256
|
+
const measureFn = (s) => {
|
|
11257
|
+
if (cjkState) {
|
|
11258
|
+
return measureVectorCjkLine(s, candidate, cjkState, charSp);
|
|
11259
|
+
}
|
|
11260
|
+
let w = 0;
|
|
11261
|
+
for (const ch of s) {
|
|
11262
|
+
const cp = ch.codePointAt(0) ?? 32;
|
|
11263
|
+
w += cp > 127 ? candidate : candidate * 0.56;
|
|
11264
|
+
}
|
|
11265
|
+
const len = Array.from(s).length;
|
|
11266
|
+
return w + (len > 1 ? (len - 1) * charSp : 0);
|
|
11267
|
+
};
|
|
11268
|
+
const wrapped = wrapMixedCjkAndLatinLines(text, innerW, measureFn);
|
|
11269
|
+
const totalH = wrapped.length * candidate * lhMul;
|
|
11270
|
+
const anyWider = wrapped.some((ln) => ln.text.length > 0 && measureFn(ln.text) > innerW + 0.5);
|
|
11271
|
+
if (totalH <= innerH + 1.5 && !anyWider) {
|
|
11272
|
+
return Math.round(candidate * 100) / 100;
|
|
11273
|
+
}
|
|
11274
|
+
candidate = Math.max(minFs, Math.round((candidate - 0.5) * 100) / 100);
|
|
11275
|
+
}
|
|
11276
|
+
return minFs;
|
|
11277
|
+
}
|
|
11278
|
+
async function drawTableCellWithBorders(pdfDoc, page, pageHeight, text, left, top, width, height, style, borderOpts, cjkState, colorType, autoFitOpts) {
|
|
10867
11279
|
const pdfY = pageHeight - top - height;
|
|
10868
11280
|
const bg = parseHexColor(style.backgroundColor);
|
|
10869
11281
|
if (bg && bg.a > 0) {
|
|
@@ -10877,6 +11289,7 @@ async function drawTableCellWithBorders(pdfDoc, page, pageHeight, text, left, to
|
|
|
10877
11289
|
borderWidth: 0
|
|
10878
11290
|
});
|
|
10879
11291
|
}
|
|
11292
|
+
const effectiveFontSize = autoFitOpts?.enabled ? computeShrunkCellFontSize(text, width, height, style, autoFitOpts.minFontSize ?? 6, cjkState) : style.fontSize;
|
|
10880
11293
|
await drawTextBox(
|
|
10881
11294
|
pdfDoc,
|
|
10882
11295
|
page,
|
|
@@ -10888,6 +11301,7 @@ async function drawTableCellWithBorders(pdfDoc, page, pageHeight, text, left, to
|
|
|
10888
11301
|
height,
|
|
10889
11302
|
{
|
|
10890
11303
|
...style,
|
|
11304
|
+
fontSize: effectiveFontSize,
|
|
10891
11305
|
backgroundColor: void 0,
|
|
10892
11306
|
borderWidth: 0,
|
|
10893
11307
|
borderColor: void 0
|
|
@@ -10952,11 +11366,12 @@ async function drawTableCellWithBorders(pdfDoc, page, pageHeight, text, left, to
|
|
|
10952
11366
|
});
|
|
10953
11367
|
}
|
|
10954
11368
|
}
|
|
10955
|
-
async function drawTableChunk(pdfDoc, page, pageHeight, el, chunk, cjkState, colorType) {
|
|
11369
|
+
async function drawTableChunk(pdfDoc, page, pageHeight, el, chunk, cjkState, colorType, tableRenderOpts) {
|
|
10956
11370
|
if (chunk.deferredOrphanHeader) return;
|
|
10957
11371
|
const { left, top, width } = el.transform;
|
|
10958
|
-
const
|
|
10959
|
-
const
|
|
11372
|
+
const repeatHeader = tableRenderOpts?.repeatHeader ?? el.repeatHeader ?? true;
|
|
11373
|
+
const showHeadOnThisChunk = el.showHead !== false && (chunk.chunkIndex === 0 || repeatHeader);
|
|
11374
|
+
const headerH = showHeadOnThisChunk ? el.headerHeight ?? 26 : 0;
|
|
10960
11375
|
const rowH = el.rowHeight ?? 24;
|
|
10961
11376
|
const colCount = el.columns.length;
|
|
10962
11377
|
const totalRatio = el.columns.reduce((s, c) => s + (c.widthRatio || 1), 0) || 1;
|
|
@@ -10970,9 +11385,10 @@ async function drawTableChunk(pdfDoc, page, pageHeight, el, chunk, cjkState, col
|
|
|
10970
11385
|
}
|
|
10971
11386
|
}
|
|
10972
11387
|
const stripeBg = el.zebraStripeColor ?? el.stripedColor;
|
|
11388
|
+
const zebraParity = tableRenderOpts?.zebraParity ?? el.zebraParity ?? "continuous";
|
|
10973
11389
|
const defaultBorderW = el.borderWidth ?? 0.75;
|
|
10974
11390
|
const defaultBorderCol = el.borderColor ?? "#cbd5e1";
|
|
10975
|
-
if (
|
|
11391
|
+
if (showHeadOnThisChunk && headerH > 0) {
|
|
10976
11392
|
for (let c = 0; c < colCount; c++) {
|
|
10977
11393
|
const col = el.columns[c];
|
|
10978
11394
|
const cw = colWidths[c];
|
|
@@ -11058,8 +11474,8 @@ async function drawTableChunk(pdfDoc, page, pageHeight, el, chunk, cjkState, col
|
|
|
11058
11474
|
for (let r = 0; r < visibleBodyRows; r++) {
|
|
11059
11475
|
const rowY = top + headerH + r * rowH;
|
|
11060
11476
|
const rowCells = chunk.formattedRows[r];
|
|
11061
|
-
const isZebra = r % 2 === 1;
|
|
11062
11477
|
const globalR = chunk.startRowIndex + r;
|
|
11478
|
+
const isZebra = (zebraParity === "chunk" ? r : globalR) % 2 === 1;
|
|
11063
11479
|
for (let c = 0; c < colCount; c++) {
|
|
11064
11480
|
const localKey = `${r}:${c}`;
|
|
11065
11481
|
if (coveredCells.has(localKey)) continue;
|
|
@@ -11078,6 +11494,9 @@ async function drawTableChunk(pdfDoc, page, pageHeight, el, chunk, cjkState, col
|
|
|
11078
11494
|
const vAlign = cellStyle?.verticalAlign ?? metaVertAligns[globalCellKey] ?? metaVertAligns[localKey] ?? col.verticalAlign ?? el.bodyStyle?.verticalAlign ?? "middle";
|
|
11079
11495
|
const hAlign = cellStyle?.textAlign ?? col.align ?? el.bodyStyle?.textAlign ?? "left";
|
|
11080
11496
|
const cellText = mergeInfo && mergeInfo.sourceGlobalRow < chunk.startRowIndex ? "" : rowCells[c] ?? "";
|
|
11497
|
+
const resolvedCellBg = cellStyle?.backgroundColor ?? (isZebra && stripeBg ? stripeBg : el.bodyStyle?.backgroundColor ?? "#ffffff");
|
|
11498
|
+
const autoFitEnabled = Boolean(col.autoFitFontSize ?? el.autoFitFontSize);
|
|
11499
|
+
const autoFitMinFs = col.minFontSize ?? el.minFontSize ?? 6;
|
|
11081
11500
|
await drawTableCellWithBorders(
|
|
11082
11501
|
pdfDoc,
|
|
11083
11502
|
page,
|
|
@@ -11089,10 +11508,10 @@ async function drawTableChunk(pdfDoc, page, pageHeight, el, chunk, cjkState, col
|
|
|
11089
11508
|
mergedH,
|
|
11090
11509
|
{
|
|
11091
11510
|
fontSize: 9.5,
|
|
11092
|
-
backgroundColor: isZebra && stripeBg ? stripeBg : "#ffffff",
|
|
11093
11511
|
padding: 5,
|
|
11094
11512
|
...el.bodyStyle,
|
|
11095
11513
|
...cellStyle,
|
|
11514
|
+
backgroundColor: resolvedCellBg,
|
|
11096
11515
|
textAlign: hAlign,
|
|
11097
11516
|
verticalAlign: vAlign
|
|
11098
11517
|
},
|
|
@@ -11103,7 +11522,8 @@ async function drawTableChunk(pdfDoc, page, pageHeight, el, chunk, cjkState, col
|
|
|
11103
11522
|
borderStyle: cellStyle?.borderStyle ?? el.borderStyle
|
|
11104
11523
|
},
|
|
11105
11524
|
cjkState,
|
|
11106
|
-
colorType
|
|
11525
|
+
colorType,
|
|
11526
|
+
autoFitEnabled ? { enabled: true, minFontSize: autoFitMinFs } : void 0
|
|
11107
11527
|
);
|
|
11108
11528
|
}
|
|
11109
11529
|
currentRowSlot += 1;
|
|
@@ -11372,18 +11792,39 @@ async function drawRichOrColumnTextBox(pdfDoc, page, pageHeight, spans, left, to
|
|
|
11372
11792
|
const col = parseHexColor(seg.colorHex) ?? { r: 0.12, g: 0.14, b: 0.16, a: 1 };
|
|
11373
11793
|
const pdfCol = toPdfLibColor(col, colorType);
|
|
11374
11794
|
if (hasNonAscii(seg.text) && cjkState || cjkState?.mode === "subset-ttf") {
|
|
11375
|
-
const fontKey = getOrRegisterPageCjkFontKey(
|
|
11376
|
-
|
|
11795
|
+
const { fontKey, activeSubset, usedDedicatedBold } = getOrRegisterPageCjkFontKey(
|
|
11796
|
+
page,
|
|
11797
|
+
cjkState,
|
|
11798
|
+
Boolean(seg.bold)
|
|
11799
|
+
);
|
|
11800
|
+
const hexStr = encodeVectorCjkLineHex(seg.text, cjkState, activeSubset);
|
|
11377
11801
|
const fillOp = colorType === "cmyk" ? (() => {
|
|
11378
11802
|
const cm = rgbToCmyk(col.r, col.g, col.b);
|
|
11379
11803
|
return (0, import_pdf_lib3.setFillingCmykColor)(cm.c, cm.m, cm.y, cm.k);
|
|
11380
11804
|
})() : (0, import_pdf_lib3.setFillingRgbColor)(col.r, col.g, col.b);
|
|
11805
|
+
const boldOps = seg.bold && !usedDedicatedBold ? [
|
|
11806
|
+
import_pdf_lib3.PDFOperator.of("Tr", [import_pdf_lib3.PDFNumber.of(2)]),
|
|
11807
|
+
(0, import_pdf_lib3.setLineWidth)(Math.max(0.25, seg.fontSize * 0.032)),
|
|
11808
|
+
colorType === "cmyk" ? (() => {
|
|
11809
|
+
const cm = rgbToCmyk(col.r, col.g, col.b);
|
|
11810
|
+
return (0, import_pdf_lib3.setStrokingCmykColor)(cm.c, cm.m, cm.y, cm.k);
|
|
11811
|
+
})() : (0, import_pdf_lib3.setStrokingRgbColor)(col.r, col.g, col.b)
|
|
11812
|
+
] : [];
|
|
11813
|
+
const posOp = seg.italic ? import_pdf_lib3.PDFOperator.of("Tm", [
|
|
11814
|
+
import_pdf_lib3.PDFNumber.of(1),
|
|
11815
|
+
import_pdf_lib3.PDFNumber.of(0),
|
|
11816
|
+
import_pdf_lib3.PDFNumber.of(0.2126),
|
|
11817
|
+
import_pdf_lib3.PDFNumber.of(1),
|
|
11818
|
+
import_pdf_lib3.PDFNumber.of(segX),
|
|
11819
|
+
import_pdf_lib3.PDFNumber.of(baselineY)
|
|
11820
|
+
]) : (0, import_pdf_lib3.moveText)(segX, baselineY);
|
|
11381
11821
|
page.pushOperators(
|
|
11382
11822
|
(0, import_pdf_lib3.pushGraphicsState)(),
|
|
11383
11823
|
(0, import_pdf_lib3.beginText)(),
|
|
11384
11824
|
fillOp,
|
|
11825
|
+
...boldOps,
|
|
11385
11826
|
(0, import_pdf_lib3.setFontAndSize)(fontKey, seg.fontSize),
|
|
11386
|
-
|
|
11827
|
+
posOp,
|
|
11387
11828
|
(0, import_pdf_lib3.showText)(import_pdf_lib3.PDFHexString.of(hexStr)),
|
|
11388
11829
|
(0, import_pdf_lib3.endText)(),
|
|
11389
11830
|
(0, import_pdf_lib3.popGraphicsState)()
|
|
@@ -11881,7 +12322,7 @@ async function drawInvisibleSearchableOcrSpans(pdfDoc, pdfPage, pageHeight, span
|
|
|
11881
12322
|
cjkTextMode: "cid-vector"
|
|
11882
12323
|
});
|
|
11883
12324
|
}
|
|
11884
|
-
const fontKey = getOrRegisterPageCjkFontKey(pdfPage, localCjkState);
|
|
12325
|
+
const { fontKey } = getOrRegisterPageCjkFontKey(pdfPage, localCjkState);
|
|
11885
12326
|
const hexStr = encodeVectorCjkLineHex(txt, localCjkState);
|
|
11886
12327
|
pdfPage.pushOperators(
|
|
11887
12328
|
(0, import_pdf_lib3.pushGraphicsState)(),
|
|
@@ -11968,6 +12409,7 @@ async function exportPdfBytes(snapshot, runtimeData, options) {
|
|
|
11968
12409
|
options?.accessibilityTagged ?? snapshot.accessibilityTagged ?? snapshot.metadata?.accessibilityTagged
|
|
11969
12410
|
);
|
|
11970
12411
|
const optimizeSize = Boolean(options?.optimizeSize);
|
|
12412
|
+
const preResolvedFonts = await resolveRenderFontsForExport(snapshot, options);
|
|
11971
12413
|
const pdfDoc = await import_pdf_lib3.PDFDocument.create();
|
|
11972
12414
|
if (snapshot.metadata?.sanitized) {
|
|
11973
12415
|
pdfDoc.setTitle("");
|
|
@@ -11976,8 +12418,19 @@ async function exportPdfBytes(snapshot, runtimeData, options) {
|
|
|
11976
12418
|
pdfDoc.setKeywords([]);
|
|
11977
12419
|
pdfDoc.setCreator("");
|
|
11978
12420
|
pdfDoc.setProducer("");
|
|
12421
|
+
} else {
|
|
12422
|
+
pdfDoc.setProducer("Univer PDF Engine (@yudaocode/univer-pdfs)");
|
|
12423
|
+
pdfDoc.setCreator("Univer PDF Engine (@yudaocode/univer-pdfs)");
|
|
11979
12424
|
}
|
|
11980
|
-
const
|
|
12425
|
+
const fixedDateRaw = options?.render?.creationDate;
|
|
12426
|
+
if (fixedDateRaw !== void 0) {
|
|
12427
|
+
const fixedDate = fixedDateRaw instanceof Date ? fixedDateRaw : new Date(fixedDateRaw);
|
|
12428
|
+
if (!Number.isNaN(fixedDate.getTime())) {
|
|
12429
|
+
pdfDoc.setCreationDate(fixedDate);
|
|
12430
|
+
pdfDoc.setModificationDate(fixedDate);
|
|
12431
|
+
}
|
|
12432
|
+
}
|
|
12433
|
+
const cjkState = initVectorCjkEmbedState(pdfDoc, snapshot, effectiveData, options, preResolvedFonts);
|
|
11981
12434
|
const ocgLayerMap = attachOptionalContentLayers(pdfDoc, snapshot.layers ?? []);
|
|
11982
12435
|
const taggedStructItems = [];
|
|
11983
12436
|
const usedAcroFieldNames = /* @__PURE__ */ new Set();
|
|
@@ -12178,6 +12631,7 @@ async function exportPdfBytes(snapshot, runtimeData, options) {
|
|
|
12178
12631
|
const tableChunksByElementId = {};
|
|
12179
12632
|
const listChunksByElementId = {};
|
|
12180
12633
|
let maxChunksOnPage = 1;
|
|
12634
|
+
let primaryPaginatedTable = null;
|
|
12181
12635
|
const visibleElements = [];
|
|
12182
12636
|
let hasExpandText = false;
|
|
12183
12637
|
for (const elementId of order) {
|
|
@@ -12189,11 +12643,34 @@ async function exportPdfBytes(snapshot, runtimeData, options) {
|
|
|
12189
12643
|
}
|
|
12190
12644
|
if (el.type === "table" /* TABLE */) {
|
|
12191
12645
|
const rawRows = resolveDynamicTableRawRows(el, effectiveData);
|
|
12192
|
-
const chunks = paginatePdfTableRows(el, rawRows, estSize.height
|
|
12646
|
+
const chunks = paginatePdfTableRows(el, rawRows, estSize.height, {
|
|
12647
|
+
marginTopPt,
|
|
12648
|
+
marginBottomPt,
|
|
12649
|
+
tablePagination: options?.render?.tablePagination ?? el.pagination,
|
|
12650
|
+
repeatHeader: options?.render?.repeatHeader ?? el.repeatHeader,
|
|
12651
|
+
onOverflow: ({ capacityRows, actualRows, overflowRows }) => {
|
|
12652
|
+
options?.render?.onWarning?.({
|
|
12653
|
+
code: "TABLE_OVERFLOW",
|
|
12654
|
+
pageId,
|
|
12655
|
+
elementId,
|
|
12656
|
+
message: `\u8868\u683C ${elementId} \u6570\u636E\u884C\u6570\uFF08${actualRows}\uFF09\u8D85\u51FA\u5355\u9875\u53EF\u5BB9\u7EB3\u884C\u6570\uFF08${capacityRows}\uFF09\uFF0C\u5DF2\u622A\u65AD\u8D85\u51FA ${overflowRows} \u884C`,
|
|
12657
|
+
details: {
|
|
12658
|
+
pageId,
|
|
12659
|
+
elementId,
|
|
12660
|
+
capacityRows,
|
|
12661
|
+
actualRows,
|
|
12662
|
+
overflowRows
|
|
12663
|
+
}
|
|
12664
|
+
});
|
|
12665
|
+
}
|
|
12666
|
+
});
|
|
12193
12667
|
tableChunksByElementId[elementId] = chunks;
|
|
12194
12668
|
if (chunks.length > maxChunksOnPage) {
|
|
12195
12669
|
maxChunksOnPage = chunks.length;
|
|
12196
12670
|
}
|
|
12671
|
+
if (chunks.length > 1 && !primaryPaginatedTable) {
|
|
12672
|
+
primaryPaginatedTable = el;
|
|
12673
|
+
}
|
|
12197
12674
|
}
|
|
12198
12675
|
if (el.type === "list" /* LIST */ && el.overflow !== "clip") {
|
|
12199
12676
|
const preResolvedItems = (el.items ?? []).map(
|
|
@@ -12230,13 +12707,82 @@ async function exportPdfBytes(snapshot, runtimeData, options) {
|
|
|
12230
12707
|
maxChunksOnPage = dynamicSplitRanges.length;
|
|
12231
12708
|
}
|
|
12232
12709
|
}
|
|
12710
|
+
let tableFlowPlan;
|
|
12711
|
+
if (primaryPaginatedTable && !hasExpandText) {
|
|
12712
|
+
const tChunks = tableChunksByElementId[primaryPaginatedTable.id] ?? [];
|
|
12713
|
+
if (tChunks.length > 1) {
|
|
12714
|
+
const origTop = primaryPaginatedTable.transform.top;
|
|
12715
|
+
const origBot = origTop + primaryPaginatedTable.transform.height;
|
|
12716
|
+
const aboveOnceIds = /* @__PURE__ */ new Set();
|
|
12717
|
+
const trailingEls = [];
|
|
12718
|
+
let hasRepeatingAbove = false;
|
|
12719
|
+
for (const other of visibleElements) {
|
|
12720
|
+
if (other.id === primaryPaginatedTable.id) continue;
|
|
12721
|
+
if (other.type === "table" /* TABLE */ || other.type === "list" /* LIST */) continue;
|
|
12722
|
+
const isPageTokenBanner = other.type === "text" /* TEXT */ && /\{\{\s*(?:page|totalPages)\s*\}\}/.test(other.content || "");
|
|
12723
|
+
if (isPageTokenBanner) {
|
|
12724
|
+
if (other.transform.top < origTop) {
|
|
12725
|
+
hasRepeatingAbove = true;
|
|
12726
|
+
}
|
|
12727
|
+
continue;
|
|
12728
|
+
}
|
|
12729
|
+
if (other.transform.top < origTop) {
|
|
12730
|
+
aboveOnceIds.add(other.id);
|
|
12731
|
+
} else {
|
|
12732
|
+
trailingEls.push(other);
|
|
12733
|
+
}
|
|
12734
|
+
}
|
|
12735
|
+
const continuationTableTop = hasRepeatingAbove ? origTop : Math.max(24, marginTopPt || 36);
|
|
12736
|
+
const lastTableChunkIdx = tChunks.length - 1;
|
|
12737
|
+
const lastChunk = tChunks[lastTableChunkIdx];
|
|
12738
|
+
const effRepeatHdr = options?.render?.repeatHeader ?? primaryPaginatedTable.repeatHeader ?? true;
|
|
12739
|
+
const lastShowHead = primaryPaginatedTable.showHead !== false && (lastTableChunkIdx === 0 || effRepeatHdr);
|
|
12740
|
+
const lastHdrH = lastShowHead ? primaryPaginatedTable.headerHeight ?? 26 : 0;
|
|
12741
|
+
const lastSlots = lastChunk.formattedRows.length + (lastChunk.subtotalRow ? 1 : 0) + (lastChunk.grandTotalRow ? 1 : 0);
|
|
12742
|
+
const lastTableStart = lastTableChunkIdx === 0 ? origTop : continuationTableTop;
|
|
12743
|
+
const lastTableBottom = lastTableStart + lastHdrH + lastSlots * (primaryPaginatedTable.rowHeight ?? 24);
|
|
12744
|
+
const trailingIds = /* @__PURE__ */ new Set();
|
|
12745
|
+
const topOverrides = {};
|
|
12746
|
+
let trailingTargetChunk = lastTableChunkIdx;
|
|
12747
|
+
if (trailingEls.length > 0) {
|
|
12748
|
+
const gapFor = (o) => o.transform.top >= origBot ? o.transform.top - origBot : Math.max(12, o.transform.top - origTop);
|
|
12749
|
+
const bottomLimit = estSize.height - Math.max(8, marginBottomPt);
|
|
12750
|
+
const fitsOnLastTablePage = trailingEls.every(
|
|
12751
|
+
(o) => lastTableBottom + gapFor(o) + o.transform.height <= bottomLimit
|
|
12752
|
+
);
|
|
12753
|
+
if (fitsOnLastTablePage) {
|
|
12754
|
+
for (const o of trailingEls) {
|
|
12755
|
+
trailingIds.add(o.id);
|
|
12756
|
+
topOverrides[o.id] = lastTableBottom + gapFor(o);
|
|
12757
|
+
}
|
|
12758
|
+
} else {
|
|
12759
|
+
trailingTargetChunk = maxChunksOnPage;
|
|
12760
|
+
maxChunksOnPage += 1;
|
|
12761
|
+
const minTop = Math.min(...trailingEls.map((o) => o.transform.top));
|
|
12762
|
+
const baseStart = Math.max(24, marginTopPt || 36);
|
|
12763
|
+
for (const o of trailingEls) {
|
|
12764
|
+
trailingIds.add(o.id);
|
|
12765
|
+
topOverrides[o.id] = baseStart + (o.transform.top - minTop);
|
|
12766
|
+
}
|
|
12767
|
+
}
|
|
12768
|
+
}
|
|
12769
|
+
tableFlowPlan = {
|
|
12770
|
+
aboveOnceIds,
|
|
12771
|
+
trailingIds,
|
|
12772
|
+
trailingTargetChunk,
|
|
12773
|
+
topOverrides,
|
|
12774
|
+
continuationTableTop
|
|
12775
|
+
};
|
|
12776
|
+
}
|
|
12777
|
+
}
|
|
12233
12778
|
for (let cIdx = 0; cIdx < maxChunksOnPage; cIdx++) {
|
|
12234
12779
|
physicalPlan.push({
|
|
12235
12780
|
pageId,
|
|
12236
12781
|
chunkIndex: cIdx,
|
|
12237
12782
|
tableChunksByElementId,
|
|
12238
12783
|
listChunksByElementId,
|
|
12239
|
-
dynamicSplitRanges
|
|
12784
|
+
dynamicSplitRanges,
|
|
12785
|
+
tableFlowPlan
|
|
12240
12786
|
});
|
|
12241
12787
|
}
|
|
12242
12788
|
}
|
|
@@ -12365,6 +12911,20 @@ async function exportPdfBytes(snapshot, runtimeData, options) {
|
|
|
12365
12911
|
}
|
|
12366
12912
|
}
|
|
12367
12913
|
for (const { elementId, el, isStaticSchema } of renderQueue) {
|
|
12914
|
+
if (!isStaticSchema && planItem.tableFlowPlan && el.type !== "table" /* TABLE */ && el.type !== "list" /* LIST */) {
|
|
12915
|
+
if (planItem.tableFlowPlan.aboveOnceIds.has(elementId) && chunkIndex !== 0) {
|
|
12916
|
+
continue;
|
|
12917
|
+
}
|
|
12918
|
+
if (planItem.tableFlowPlan.trailingIds.has(elementId) && chunkIndex !== planItem.tableFlowPlan.trailingTargetChunk) {
|
|
12919
|
+
continue;
|
|
12920
|
+
}
|
|
12921
|
+
}
|
|
12922
|
+
if (!isStaticSchema && el.type === "table" /* TABLE */ && tableChunksByElementId[elementId]) {
|
|
12923
|
+
const tChunk = tableChunksByElementId[elementId][chunkIndex];
|
|
12924
|
+
if (!tChunk || tChunk.deferredOrphanHeader) {
|
|
12925
|
+
continue;
|
|
12926
|
+
}
|
|
12927
|
+
}
|
|
12368
12928
|
if (!isStaticSchema && planItem.dynamicSplitRanges && planItem.dynamicSplitRanges.length > 1 && el.type !== "table" /* TABLE */ && el.type !== "list" /* LIST */ && (!activeDynamicRange || !activeDynamicRange.elementIds.includes(elementId))) {
|
|
12369
12929
|
continue;
|
|
12370
12930
|
}
|
|
@@ -12417,7 +12977,7 @@ async function exportPdfBytes(snapshot, runtimeData, options) {
|
|
|
12417
12977
|
try {
|
|
12418
12978
|
const elColorType = options?.colorType ?? el.colorType ?? snapshot.metadata?.colorType;
|
|
12419
12979
|
const placement = !isStaticSchema ? activeDynamicRange?.placements.find((p) => p.id === elementId) : void 0;
|
|
12420
|
-
let top = el.transform.top + offsetYPt;
|
|
12980
|
+
let top = (!isStaticSchema && planItem.tableFlowPlan && planItem.tableFlowPlan.topOverrides[elementId] !== void 0 && chunkIndex === planItem.tableFlowPlan.trailingTargetChunk ? planItem.tableFlowPlan.topOverrides[elementId] : el.transform.top) + offsetYPt;
|
|
12421
12981
|
let height = el.transform.height;
|
|
12422
12982
|
const left = el.transform.left + offsetXPt;
|
|
12423
12983
|
const width = el.transform.width;
|
|
@@ -13606,10 +14166,15 @@ async function exportPdfBytes(snapshot, runtimeData, options) {
|
|
|
13606
14166
|
elColorType
|
|
13607
14167
|
);
|
|
13608
14168
|
} else if (el.type === "table" /* TABLE */) {
|
|
13609
|
-
const chunks = tableChunksByElementId[elementId] ?? paginatePdfTableRows(el, resolveDynamicTableRawRows(el, effectiveData), pageHeight
|
|
14169
|
+
const chunks = tableChunksByElementId[elementId] ?? paginatePdfTableRows(el, resolveDynamicTableRawRows(el, effectiveData), pageHeight, {
|
|
14170
|
+
marginTopPt,
|
|
14171
|
+
marginBottomPt,
|
|
14172
|
+
tablePagination: options?.render?.tablePagination ?? el.pagination,
|
|
14173
|
+
repeatHeader: options?.render?.repeatHeader ?? el.repeatHeader
|
|
14174
|
+
});
|
|
13610
14175
|
const activeChunk = chunks[chunkIndex];
|
|
13611
14176
|
if (activeChunk && !activeChunk.deferredOrphanHeader) {
|
|
13612
|
-
const tableTop = chunkIndex > 0 && chunks[0]?.deferredOrphanHeader ? Math.max(24, marginTopPt || 36) + offsetYPt : top;
|
|
14177
|
+
const tableTop = chunkIndex > 0 && planItem.tableFlowPlan ? planItem.tableFlowPlan.continuationTableTop + offsetYPt : chunkIndex > 0 && chunks[0]?.deferredOrphanHeader ? Math.max(24, marginTopPt || 36) + offsetYPt : top;
|
|
13613
14178
|
const shiftedTableEl = {
|
|
13614
14179
|
...el,
|
|
13615
14180
|
transform: { ...el.transform, left, top: tableTop }
|
|
@@ -13621,7 +14186,11 @@ async function exportPdfBytes(snapshot, runtimeData, options) {
|
|
|
13621
14186
|
shiftedTableEl,
|
|
13622
14187
|
activeChunk,
|
|
13623
14188
|
cjkState,
|
|
13624
|
-
elColorType
|
|
14189
|
+
elColorType,
|
|
14190
|
+
{
|
|
14191
|
+
repeatHeader: options?.render?.repeatHeader,
|
|
14192
|
+
zebraParity: options?.render?.zebraParity
|
|
14193
|
+
}
|
|
13625
14194
|
);
|
|
13626
14195
|
}
|
|
13627
14196
|
} else if (el.type === "annotation" /* ANNOTATION */) {
|
|
@@ -13875,7 +14444,7 @@ async function exportPdfBytes(snapshot, runtimeData, options) {
|
|
|
13875
14444
|
});
|
|
13876
14445
|
}
|
|
13877
14446
|
} else if (cjkState) {
|
|
13878
|
-
const fontKey = getOrRegisterPageCjkFontKey(pdfPage, cjkState);
|
|
14447
|
+
const { fontKey } = getOrRegisterPageCjkFontKey(pdfPage, cjkState);
|
|
13879
14448
|
const hexWm = encodeVectorCjkLineHex(watermarkText, cjkState);
|
|
13880
14449
|
for (let wy = 90; wy < pageHeight - 40; wy += isTiled ? 185 : pageHeight) {
|
|
13881
14450
|
for (let wx = 45; wx < pageWidth2 - 50; wx += isTiled ? 225 : pageWidth2) {
|
|
@@ -14783,6 +15352,111 @@ function collectUsedCodePointsFromPdfUnit(unitData, data) {
|
|
|
14783
15352
|
});
|
|
14784
15353
|
return Array.from(codePoints).sort((a, b) => a - b);
|
|
14785
15354
|
}
|
|
15355
|
+
function collectMissingGlyphsFromPdfUnit(unitData, hasGlyph, data, formatTableCell) {
|
|
15356
|
+
const effectiveData = data ?? unitData.metadata?.sampleData;
|
|
15357
|
+
const results = [];
|
|
15358
|
+
const checkStrings = (pageId, elementId, strings) => {
|
|
15359
|
+
const missingSet = /* @__PURE__ */ new Set();
|
|
15360
|
+
for (const s of strings) {
|
|
15361
|
+
if (!s) continue;
|
|
15362
|
+
for (const ch of s) {
|
|
15363
|
+
const cp = ch.codePointAt(0);
|
|
15364
|
+
if (cp === void 0 || cp < 32 || cp === 127) continue;
|
|
15365
|
+
if (!hasGlyph(cp)) {
|
|
15366
|
+
missingSet.add(cp);
|
|
15367
|
+
}
|
|
15368
|
+
}
|
|
15369
|
+
}
|
|
15370
|
+
if (missingSet.size > 0) {
|
|
15371
|
+
const sorted = Array.from(missingSet).sort((a, b) => a - b);
|
|
15372
|
+
results.push({
|
|
15373
|
+
...pageId ? { pageId } : {},
|
|
15374
|
+
elementId,
|
|
15375
|
+
chars: sorted.map((cp) => String.fromCodePoint(cp)),
|
|
15376
|
+
codePoints: sorted.map((cp) => `U+${cp.toString(16).toUpperCase().padStart(4, "0")}`)
|
|
15377
|
+
});
|
|
15378
|
+
}
|
|
15379
|
+
};
|
|
15380
|
+
if (unitData.metadata?.watermarkText && unitData.metadata?.watermarkConfig?.enabled !== false) {
|
|
15381
|
+
checkStrings(void 0, "__watermark__", [String(unitData.metadata.watermarkText)]);
|
|
15382
|
+
}
|
|
15383
|
+
const totalPages = unitData.document.pageOrder.length;
|
|
15384
|
+
const startPageOffset = Math.max(1, Number(unitData.metadata?.startPageNumber ?? 1) || 1);
|
|
15385
|
+
unitData.document.pageOrder.forEach((pageId, pIdx) => {
|
|
15386
|
+
const pageCtx = { pageNumber: startPageOffset + pIdx, totalPages: startPageOffset + totalPages - 1 };
|
|
15387
|
+
const map = unitData.editState.elementsByPage[pageId] ?? {};
|
|
15388
|
+
const order = unitData.editState.elementOrderByPage[pageId] ?? Object.keys(map);
|
|
15389
|
+
for (const id of order) {
|
|
15390
|
+
const el = map[id];
|
|
15391
|
+
if (!el || el.hidden) continue;
|
|
15392
|
+
if (el.type === "text" /* TEXT */) {
|
|
15393
|
+
const texts = [
|
|
15394
|
+
resolveTemplateString(el.content, el.fieldKey || el.bindingField, effectiveData, pageCtx)
|
|
15395
|
+
];
|
|
15396
|
+
if (el.richSpans?.length) {
|
|
15397
|
+
for (const span of el.richSpans) {
|
|
15398
|
+
texts.push(resolveTemplateString(span.text, void 0, effectiveData, pageCtx));
|
|
15399
|
+
}
|
|
15400
|
+
}
|
|
15401
|
+
checkStrings(pageId, id, texts);
|
|
15402
|
+
} else if (el.type === "list" /* LIST */) {
|
|
15403
|
+
checkStrings(
|
|
15404
|
+
pageId,
|
|
15405
|
+
id,
|
|
15406
|
+
el.items.map((item) => resolveTemplateString(item, void 0, effectiveData, pageCtx))
|
|
15407
|
+
);
|
|
15408
|
+
} else if (el.type === "stamp" /* STAMP */) {
|
|
15409
|
+
checkStrings(pageId, id, [el.primaryText, el.secondaryText]);
|
|
15410
|
+
} else if (el.type === "table" /* TABLE */) {
|
|
15411
|
+
const texts = [];
|
|
15412
|
+
if (el.showHead !== false) {
|
|
15413
|
+
for (const col of el.columns) {
|
|
15414
|
+
texts.push(col.header);
|
|
15415
|
+
}
|
|
15416
|
+
}
|
|
15417
|
+
if (el.showPageSubtotal) texts.push(el.pageSubtotalLabel || "\u672C\u9875\u5C0F\u8BA1");
|
|
15418
|
+
if (el.showGrandTotal) texts.push(el.grandTotalLabel || "\u603B\u8BA1");
|
|
15419
|
+
const rawRows = [];
|
|
15420
|
+
if (effectiveData && el.bindingField) {
|
|
15421
|
+
const bound = getByPathLocal(effectiveData, el.bindingField);
|
|
15422
|
+
if (Array.isArray(bound)) {
|
|
15423
|
+
for (const rowObj of bound) {
|
|
15424
|
+
if (Array.isArray(rowObj)) {
|
|
15425
|
+
rawRows.push(rowObj);
|
|
15426
|
+
} else if (rowObj && typeof rowObj === "object") {
|
|
15427
|
+
rawRows.push(el.columns.map((col) => rowObj[col.field]));
|
|
15428
|
+
}
|
|
15429
|
+
}
|
|
15430
|
+
}
|
|
15431
|
+
}
|
|
15432
|
+
const effectiveRows = rawRows.length > 0 ? rawRows : el.rows ?? [];
|
|
15433
|
+
for (const row of effectiveRows) {
|
|
15434
|
+
el.columns.forEach((col, cIdx) => {
|
|
15435
|
+
const rawVal = row[cIdx];
|
|
15436
|
+
texts.push(formatTableCell ? formatTableCell(rawVal, col) : String(rawVal ?? ""));
|
|
15437
|
+
});
|
|
15438
|
+
}
|
|
15439
|
+
checkStrings(pageId, id, texts);
|
|
15440
|
+
} else if (el.type === "checkbox" /* CHECKBOX */) {
|
|
15441
|
+
checkStrings(pageId, id, [el.label]);
|
|
15442
|
+
} else if (el.type === "radioGroup" /* RADIO_GROUP */) {
|
|
15443
|
+
checkStrings(pageId, id, [...el.options, el.value]);
|
|
15444
|
+
} else if (el.type === "select" /* SELECT */) {
|
|
15445
|
+
checkStrings(pageId, id, [...el.options, el.value, el.placeholder]);
|
|
15446
|
+
} else if (el.type === "dateTime" /* DATE_TIME */) {
|
|
15447
|
+
const key = el.formFieldName || el.fieldKey || el.bindingField;
|
|
15448
|
+
const bound = key ? getByPathLocal(effectiveData, key) : void 0;
|
|
15449
|
+
const rawVal = bound !== void 0 && bound !== null ? String(bound) : el.value ?? "";
|
|
15450
|
+
checkStrings(pageId, id, [formatPdfDateTimeValue(rawVal, el.format, el.dateKind, el.locale)]);
|
|
15451
|
+
} else if (el.type === "redaction" /* REDACTION */) {
|
|
15452
|
+
checkStrings(pageId, id, [el.overlayLabel]);
|
|
15453
|
+
} else if (el.type === "annotation" /* ANNOTATION */) {
|
|
15454
|
+
checkStrings(pageId, id, [el.author, el.comment]);
|
|
15455
|
+
}
|
|
15456
|
+
}
|
|
15457
|
+
});
|
|
15458
|
+
return results;
|
|
15459
|
+
}
|
|
14786
15460
|
function readTag(bytes, offset) {
|
|
14787
15461
|
return String.fromCharCode(
|
|
14788
15462
|
bytes[offset],
|
|
@@ -14916,6 +15590,9 @@ function parseTrueTypeInternal(ttfBytes) {
|
|
|
14916
15590
|
}
|
|
14917
15591
|
}
|
|
14918
15592
|
const head = tableSlices.get("head");
|
|
15593
|
+
if (head.byteLength < 54) {
|
|
15594
|
+
throw new Error("[UniverPdfs] Invalid TrueType font: truncated head table.");
|
|
15595
|
+
}
|
|
14919
15596
|
const headView = new DataView(head.buffer, head.byteOffset, head.byteLength);
|
|
14920
15597
|
const unitsPerEm = headView.getUint16(18, false) || 1e3;
|
|
14921
15598
|
const xMin = headView.getInt16(36, false);
|
|
@@ -14924,9 +15601,18 @@ function parseTrueTypeInternal(ttfBytes) {
|
|
|
14924
15601
|
const yMax = headView.getInt16(42, false);
|
|
14925
15602
|
const indexToLocFormat = headView.getInt16(50, false) === 1 ? 1 : 0;
|
|
14926
15603
|
const maxp = tableSlices.get("maxp");
|
|
15604
|
+
if (maxp.byteLength < 6) {
|
|
15605
|
+
throw new Error("[UniverPdfs] Invalid TrueType font: truncated maxp table.");
|
|
15606
|
+
}
|
|
14927
15607
|
const maxpView = new DataView(maxp.buffer, maxp.byteOffset, maxp.byteLength);
|
|
14928
15608
|
const numGlyphs = maxpView.getUint16(4, false);
|
|
15609
|
+
if (numGlyphs <= 0) {
|
|
15610
|
+
throw new Error("[UniverPdfs] Invalid TrueType font: numGlyphs is 0.");
|
|
15611
|
+
}
|
|
14929
15612
|
const hhea = tableSlices.get("hhea");
|
|
15613
|
+
if (hhea.byteLength < 36) {
|
|
15614
|
+
throw new Error("[UniverPdfs] Invalid TrueType font: truncated hhea table.");
|
|
15615
|
+
}
|
|
14930
15616
|
const hheaView = new DataView(hhea.buffer, hhea.byteOffset, hhea.byteLength);
|
|
14931
15617
|
const ascent = hheaView.getInt16(4, false);
|
|
14932
15618
|
const descent = hheaView.getInt16(6, false);
|
|
@@ -14967,6 +15653,9 @@ function parseTrueTypeInternal(ttfBytes) {
|
|
|
14967
15653
|
}
|
|
14968
15654
|
}
|
|
14969
15655
|
const cmapMap = parseCmapTable(tableSlices.get("cmap"));
|
|
15656
|
+
if (cmapMap.size === 0) {
|
|
15657
|
+
throw new Error("[UniverPdfs] Invalid TrueType font: empty or unreadable cmap table.");
|
|
15658
|
+
}
|
|
14970
15659
|
return {
|
|
14971
15660
|
inspection: {
|
|
14972
15661
|
sfntVersion,
|
|
@@ -15274,7 +15963,7 @@ function subsetTrueTypeFont(ttfBytes, codePoints) {
|
|
|
15274
15963
|
const cmapPairs = [];
|
|
15275
15964
|
for (const cp of uniqueCps) {
|
|
15276
15965
|
const oldGid = cmapMap.get(cp);
|
|
15277
|
-
if (oldGid !== void 0 && oldGid > 0) {
|
|
15966
|
+
if (oldGid !== void 0 && oldGid > 0 && oldGid < inspection.numGlyphs) {
|
|
15278
15967
|
const newGid = enqueueOldGid(oldGid);
|
|
15279
15968
|
codePointToGid[cp] = newGid;
|
|
15280
15969
|
cmapPairs.push({ cp, gid: newGid });
|
|
@@ -15418,7 +16107,7 @@ function buildCompositeTestGlyph(compGidA, compGidB) {
|
|
|
15418
16107
|
view.setInt16(24, 80, false);
|
|
15419
16108
|
return buf;
|
|
15420
16109
|
}
|
|
15421
|
-
var DEFAULT_FIXTURE_CJK_TEXT = "\u987A\u4E30\u7535\u5B50\u9762\u5355\u4E09\u8054\u91C7\u8D2D\u51FA\u5E93\u5957\u6253\u6A21\u677F\u542B\u8FFD\u6EAF\u7801\u660E\u7EC6\u8868\u4E0E\u7B7E\u6536\u7EA2\u7AE0\u828B\u9053\u4F01\u4E1A\u7EA7\u62A5\u8868\u8BA2\u5355\u7F16\u53F7\u5BA2\u6237\u540D\u79F0\u6536\u8D27\u5730\u5740\u5546\u54C1\u89C4\u683C\u6570\u91CF\u5355\u4EF7\u91D1\u989D\u5408\u8BA1\u5DF2\u6838\u9A8C\u4FDD\u4EF7\u8FD0\u8F93\u6B21\u65E5\u8FBE\u9646\u8FD0\u4E13\u7968\u666E\u7968\u4E0A\u6D77\u6D66\u4E1C\u5F20\u6C5F\u9AD8\u79D1\u6280\u56ED\u533A\u5317\u4EAC\u6DF1\u5733\u676D\u5DDE\u4E2D\u6587\u77E2\u91CF\u53EF\u68C0\u7D22\u5B57\u4F53\u5B50\u96C6\u5316\u6D4B\u8BD5\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D\u5341\u767E\u5343\u4E07\u96F6\u5143\u89D2\u5206\u5E74\u6708\u65E5\u65F6\u5206\u79D2\u9875\u5171\u7B2C\u5185\u90E8\u8D44\u6599\u590D\u5370\u65E0\u6548\u8D22\u52A1\u4E13\u7528\u7AE0\u4ED3\u5E93\u7B7E\u7AE0\u2605";
|
|
16110
|
+
var DEFAULT_FIXTURE_CJK_TEXT = "\u987A\u4E30\u7535\u5B50\u9762\u5355\u4E09\u8054\u91C7\u8D2D\u51FA\u5E93\u5957\u6253\u6A21\u677F\u542B\u8FFD\u6EAF\u7801\u660E\u7EC6\u8868\u4E0E\u7B7E\u6536\u7EA2\u7AE0\u828B\u9053\u4F01\u4E1A\u7EA7\u62A5\u8868\u8BA2\u5355\u7F16\u53F7\u5BA2\u6237\u540D\u79F0\u6536\u8D27\u5730\u5740\u5546\u54C1\u89C4\u683C\u6570\u91CF\u5355\u4EF7\u91D1\u989D\u5408\u8BA1\u5DF2\u6838\u9A8C\u4FDD\u4EF7\u8FD0\u8F93\u6B21\u65E5\u8FBE\u9646\u8FD0\u4E13\u7968\u666E\u7968\u4E0A\u6D77\u6D66\u4E1C\u5F20\u6C5F\u9AD8\u79D1\u6280\u56ED\u533A\u5317\u4EAC\u6DF1\u5733\u676D\u5DDE\u4E2D\u6587\u77E2\u91CF\u53EF\u68C0\u7D22\u5B57\u4F53\u5B50\u96C6\u5316\u6D4B\u8BD5\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D\u5341\u767E\u5343\u4E07\u96F6\u5143\u89D2\u5206\u5E74\u6708\u65E5\u65F6\u5206\u79D2\u9875\u5171\u7B2C\u5185\u90E8\u8D44\u6599\u590D\u5370\u65E0\u6548\u8D22\u52A1\u4E13\u7528\u7AE0\u4ED3\u5E93\u7B7E\u7AE0\u9879\u76EE\u6458\u8981\u5BA1\u6279\u4EBA\u65E5\u671F\u8BF4\u660E\u72B6\u6001\u901A\u8FC7\u5F85\u5BA1\u6BD4\u4F8B\u589E\u957F\u7387\u5B8C\u6210\u5EA6\u6708\u5EA6\u5B63\u5EA6\u5E74\u5EA6\u5DE5\u4E1A\u4F20\u611F\u5668\u6A21\u5757\u63A7\u5236\u5668\u7CBE\u5BC6\u7EC4\u4EF6\u534E\u4E1C\u534E\u5357\u534E\u5317\u7ECF\u8425\u7B80\u62A5\u6838\u5FC3\u6B63\u5E38\u884C\u51FA\u88C1\u5207\u5916\u6EA2\u90BB\u683C\u5F20\u5DE5\u636E\u6001\u5165\u8DE8\u8868\u5934\u6591\u9A6C\u7EB9\u8FDE\u7EED\u6027\u8BC1\u5E8F\u5DE6\u5BF9\u9F50\u9876\u90E8\u5E95\u53F3\u7F29\u5C0F\u5B57\u81EA\u9002\u5E94\u591A\u6BB5\u6DF7\u6392\u957F\u6587\u672C\u793A\u4F8B\u5168\u89D2\u6807\u70B9\u5907\u6CE8\u751F\u50FB\u56FE\u6807\u7F3A\u8BCA\u65AD\u5DEE\u9519\u4EA4\u4ED8\u56FA\u9AD8\u5C06\u5728\u4E25\u7EDD\u5411\u4E0B\u65B9\u5143\u7D20\u4F4D\u8FB9\u4E4B\u5C45\u5782\u76F4\u7387\u5F53\u7D27\u51D1\u52A8\u81F3\u4F4E\u4FDD\u7559\u6536\u7F16\u5907\u54C1\u5957\u9996\u4FB5\u5165\u4EC5\u672B\u5C3E\u73B0\u91CD\u53E0\u680F\u51C6\u7248\u5730\u5B9A\u5BB9\u500D\u540E\xD7\xA5\uFFE5\uFF0C\u3002\uFF1A\uFF1B\uFF01\uFF1F\uFF08\uFF09\u3010\u3011\u300A\u300B\uFF05\u2014\xB7\u201C\u201D\u2018\u2019\uFF5C\u2605";
|
|
15422
16111
|
function buildMinimalTestTrueTypeFont(extraCodePoints) {
|
|
15423
16112
|
const cpSet = /* @__PURE__ */ new Set();
|
|
15424
16113
|
for (let ascii = 32; ascii <= 126; ascii++) {
|
|
@@ -20924,6 +21613,509 @@ async function convertMarkdownToPdfBytes(markdown, options) {
|
|
|
20924
21613
|
});
|
|
20925
21614
|
}
|
|
20926
21615
|
|
|
21616
|
+
// src/exporter/pdf-fidelity-samples.ts
|
|
21617
|
+
var import_core10 = require("@univerjs/core");
|
|
21618
|
+
function buildA4Snapshot(id, name, elements, margins = [40, 40, 40, 40]) {
|
|
21619
|
+
const base = createDefaultPdfUnitData({ id, name });
|
|
21620
|
+
const pageId = "page-1";
|
|
21621
|
+
const map = {};
|
|
21622
|
+
const order = [];
|
|
21623
|
+
for (const el of elements) {
|
|
21624
|
+
map[el.id] = el;
|
|
21625
|
+
order.push(el.id);
|
|
21626
|
+
}
|
|
21627
|
+
return {
|
|
21628
|
+
...base,
|
|
21629
|
+
id,
|
|
21630
|
+
name,
|
|
21631
|
+
document: {
|
|
21632
|
+
pageSize: { ...PDF_PAGE_PRESETS.A4 },
|
|
21633
|
+
margins,
|
|
21634
|
+
pages: {
|
|
21635
|
+
[pageId]: {
|
|
21636
|
+
id: pageId,
|
|
21637
|
+
title: "Page 1",
|
|
21638
|
+
pageSize: { ...PDF_PAGE_PRESETS.A4 },
|
|
21639
|
+
backgroundColor: "#ffffff"
|
|
21640
|
+
}
|
|
21641
|
+
},
|
|
21642
|
+
pageOrder: [pageId]
|
|
21643
|
+
},
|
|
21644
|
+
editState: {
|
|
21645
|
+
...base.editState,
|
|
21646
|
+
elementsByPage: { [pageId]: map },
|
|
21647
|
+
elementOrderByPage: { [pageId]: order }
|
|
21648
|
+
}
|
|
21649
|
+
};
|
|
21650
|
+
}
|
|
21651
|
+
function createPdfBrowserFidelitySamples() {
|
|
21652
|
+
const s1Elements = [
|
|
21653
|
+
{
|
|
21654
|
+
id: "s1-banner",
|
|
21655
|
+
type: "shape" /* SHAPE */,
|
|
21656
|
+
shapeType: "rect",
|
|
21657
|
+
fillColor: "#1e293b",
|
|
21658
|
+
strokeWidth: 0,
|
|
21659
|
+
transform: { left: 40, top: 40, width: 515.28, height: 42 }
|
|
21660
|
+
},
|
|
21661
|
+
{
|
|
21662
|
+
id: "s1-title",
|
|
21663
|
+
type: "text" /* TEXT */,
|
|
21664
|
+
content: "Monthly Report \xB7 \u6708\u5EA6\u7ECF\u8425\u7B80\u62A5\uFF082026\uFF09",
|
|
21665
|
+
transform: { left: 52, top: 47, width: 490, height: 28 },
|
|
21666
|
+
style: {
|
|
21667
|
+
fontSize: 15,
|
|
21668
|
+
fontWeight: "bold",
|
|
21669
|
+
color: "#ffffff",
|
|
21670
|
+
verticalAlign: "middle"
|
|
21671
|
+
}
|
|
21672
|
+
},
|
|
21673
|
+
{
|
|
21674
|
+
id: "s1-subtitle",
|
|
21675
|
+
type: "text" /* TEXT */,
|
|
21676
|
+
content: "Vector Subset Font & ToUnicode Verification Sample",
|
|
21677
|
+
transform: { left: 40, top: 92, width: 515.28, height: 22 },
|
|
21678
|
+
style: { fontSize: 10.5, italic: true, color: "#475569" }
|
|
21679
|
+
},
|
|
21680
|
+
{
|
|
21681
|
+
id: "s1-lbl-period",
|
|
21682
|
+
type: "text" /* TEXT */,
|
|
21683
|
+
content: "Report Period:",
|
|
21684
|
+
transform: { left: 40, top: 130, width: 130, height: 26 },
|
|
21685
|
+
style: { fontSize: 11, fontWeight: "bold", color: "#334155", verticalAlign: "middle" }
|
|
21686
|
+
},
|
|
21687
|
+
{
|
|
21688
|
+
id: "s1-val-period",
|
|
21689
|
+
type: "text" /* TEXT */,
|
|
21690
|
+
content: "\u4E00\u6708\uFF082026Q1\uFF09",
|
|
21691
|
+
transform: { left: 178, top: 130, width: 377.28, height: 26 },
|
|
21692
|
+
style: {
|
|
21693
|
+
fontSize: 11,
|
|
21694
|
+
color: "#0f172a",
|
|
21695
|
+
backgroundColor: "#f8fafc",
|
|
21696
|
+
borderColor: "#cbd5e1",
|
|
21697
|
+
borderWidth: 1,
|
|
21698
|
+
padding: 5,
|
|
21699
|
+
verticalAlign: "middle"
|
|
21700
|
+
}
|
|
21701
|
+
},
|
|
21702
|
+
{
|
|
21703
|
+
id: "s1-lbl-region",
|
|
21704
|
+
type: "text" /* TEXT */,
|
|
21705
|
+
content: "Service Region:",
|
|
21706
|
+
transform: { left: 40, top: 168, width: 130, height: 26 },
|
|
21707
|
+
style: { fontSize: 11, fontWeight: "bold", color: "#334155", verticalAlign: "middle" }
|
|
21708
|
+
},
|
|
21709
|
+
{
|
|
21710
|
+
id: "s1-val-region",
|
|
21711
|
+
type: "text" /* TEXT */,
|
|
21712
|
+
content: "\u534E\u4E1C\xB7\u4E0A\u6D77\u6D66\u4E1C\u5F20\u6C5F\u9AD8\u79D1\u6280\u56ED\u533A",
|
|
21713
|
+
transform: { left: 178, top: 168, width: 377.28, height: 26 },
|
|
21714
|
+
style: {
|
|
21715
|
+
fontSize: 11,
|
|
21716
|
+
color: "#0f172a",
|
|
21717
|
+
backgroundColor: "#f8fafc",
|
|
21718
|
+
borderColor: "#cbd5e1",
|
|
21719
|
+
borderWidth: 1,
|
|
21720
|
+
padding: 5,
|
|
21721
|
+
verticalAlign: "middle"
|
|
21722
|
+
}
|
|
21723
|
+
},
|
|
21724
|
+
{
|
|
21725
|
+
id: "s1-lbl-status",
|
|
21726
|
+
type: "text" /* TEXT */,
|
|
21727
|
+
content: "Audit Status:",
|
|
21728
|
+
transform: { left: 40, top: 206, width: 130, height: 26 },
|
|
21729
|
+
style: { fontSize: 11, fontWeight: "bold", color: "#334155", verticalAlign: "middle" }
|
|
21730
|
+
},
|
|
21731
|
+
{
|
|
21732
|
+
id: "s1-val-status",
|
|
21733
|
+
type: "text" /* TEXT */,
|
|
21734
|
+
content: "\u5DF2\u6838\u9A8C\uFF1A\u4E13\u7968\u901A\u8FC7\uFF01\u3010\u6279\u6B21 A-108\u3011",
|
|
21735
|
+
transform: { left: 178, top: 206, width: 377.28, height: 26 },
|
|
21736
|
+
style: {
|
|
21737
|
+
fontSize: 11,
|
|
21738
|
+
fontWeight: "bold",
|
|
21739
|
+
color: "#0f766e",
|
|
21740
|
+
backgroundColor: "#f0fdfa",
|
|
21741
|
+
borderColor: "#99f6e4",
|
|
21742
|
+
borderWidth: 1,
|
|
21743
|
+
padding: 5,
|
|
21744
|
+
verticalAlign: "middle"
|
|
21745
|
+
}
|
|
21746
|
+
},
|
|
21747
|
+
{
|
|
21748
|
+
id: "s1-lbl-summary",
|
|
21749
|
+
type: "text" /* TEXT */,
|
|
21750
|
+
content: "Summary Note:",
|
|
21751
|
+
transform: { left: 40, top: 244, width: 130, height: 26 },
|
|
21752
|
+
style: { fontSize: 11, fontWeight: "bold", color: "#334155", verticalAlign: "middle" }
|
|
21753
|
+
},
|
|
21754
|
+
{
|
|
21755
|
+
id: "s1-val-summary",
|
|
21756
|
+
type: "text" /* TEXT */,
|
|
21757
|
+
content: "\u6838\u5FC3\u6A21\u5757 Controller-V2 \u5B8C\u6210\u5EA6 98.5\uFF05\uFF1B\u6B21\u65E5\u8FBE\u6B63\u5E38\uFF0C\u201C\u96F6\u5DEE\u9519\u201D\u4EA4\u4ED8\u3002",
|
|
21758
|
+
transform: { left: 178, top: 244, width: 377.28, height: 26 },
|
|
21759
|
+
style: {
|
|
21760
|
+
fontSize: 11,
|
|
21761
|
+
color: "#0f172a",
|
|
21762
|
+
backgroundColor: "#f8fafc",
|
|
21763
|
+
borderColor: "#cbd5e1",
|
|
21764
|
+
borderWidth: 1,
|
|
21765
|
+
padding: 5,
|
|
21766
|
+
verticalAlign: "middle"
|
|
21767
|
+
}
|
|
21768
|
+
}
|
|
21769
|
+
];
|
|
21770
|
+
const s1ShortCjk = buildA4Snapshot("s1-cjk-short", "S1 \u4E2D\u6587\u77ED\u6587\u672C\u4E0E\u4E2D\u897F\u6DF7\u6392", s1Elements);
|
|
21771
|
+
const s2LongTextBox = buildA4Snapshot("s2-cjk-long-textbox", "S2 \u4E2D\u6587\u957F\u6587\u672C\u6846\u5BF9\u9F50\u4E0E\u88C1\u5207", [
|
|
21772
|
+
{
|
|
21773
|
+
id: "s2-title",
|
|
21774
|
+
type: "text" /* TEXT */,
|
|
21775
|
+
content: "S2 \u591A\u6BB5\u6DF7\u6392\u957F\u6587\u672C\u6846\uFF08\u5DE6/\u4E2D/\u53F3 \xD7 \u4E0A/\u4E2D/\u4E0B\u5BF9\u9F50\u3001\u8D85\u957F\u897F\u6587\u65AD\u884C\u4E0E\u6EA2\u51FA\u88C1\u5207\uFF09",
|
|
21776
|
+
transform: { left: 40, top: 40, width: 515.28, height: 28 },
|
|
21777
|
+
style: { fontSize: 13, fontWeight: "bold", color: "#0f172a", verticalAlign: "middle" }
|
|
21778
|
+
},
|
|
21779
|
+
{
|
|
21780
|
+
id: "s2-left-top-clip",
|
|
21781
|
+
type: "text" /* TEXT */,
|
|
21782
|
+
content: "\u5DE6\u5BF9\u9F50\xB7\u9876\u90E8\u793A\u4F8B\uFF1A\u4E0A\u6D77\u6D66\u4E1C\u5F20\u6C5F\u9AD8\u79D1\u6280\u56ED\u533A\u5DE5\u4E1A\u4F20\u611F\u5668\u6A21\u5757\u5DF2\u5B8C\u6210\u5E74\u5EA6\u6838\u9A8C\u3002\nEnglish words wrap cleanly while SupercalifragilisticexpialidociousControllerModule2026 breaks by character.\n\u7B2C\u4E09\u6BB5\uFF1A\u8D85\u51FA\u56FA\u5B9A\u9AD8\u5EA6\u7684\u7B2C\u56DB\u884C\u4E0E\u7B2C\u4E94\u884C\u5C06\u5728\u6846\u5185\u4E25\u683C\u88C1\u5207\uFF0C\u7EDD\u4E0D\u5411\u4E0B\u65B9\u5143\u7D20\u6EA2\u51FA\u3002\n\u7B2C\u56DB\u6BB5\uFF1A\u672C\u884C\u4F4D\u4E8E\u6846\u5E95\u88C1\u5207\u8FB9\u754C\u4E4B\u5916\u3002",
|
|
21783
|
+
overflow: "clip",
|
|
21784
|
+
transform: { left: 40, top: 82, width: 515.28, height: 74 },
|
|
21785
|
+
style: {
|
|
21786
|
+
fontSize: 10.5,
|
|
21787
|
+
lineHeight: 1.45,
|
|
21788
|
+
textAlign: "left",
|
|
21789
|
+
verticalAlign: "top",
|
|
21790
|
+
color: "#0f172a",
|
|
21791
|
+
backgroundColor: "#f8fafc",
|
|
21792
|
+
borderColor: "#94a3b8",
|
|
21793
|
+
borderWidth: 1,
|
|
21794
|
+
padding: 6
|
|
21795
|
+
}
|
|
21796
|
+
},
|
|
21797
|
+
{
|
|
21798
|
+
id: "s2-center-middle",
|
|
21799
|
+
type: "text" /* TEXT */,
|
|
21800
|
+
content: "\u5C45\u4E2D\xB7\u5782\u76F4\u5C45\u4E2D\u793A\u4F8B\uFF08Center / Middle\uFF09\n\u534E\u4E1C\u534E\u5357\u534E\u5317\u4E09\u533A\u5408\u8BA1\u901A\u8FC7\u7387 99.2\uFF05\uFF0C\u5355\u636E\u72B6\u6001\u6B63\u5E38\u3002",
|
|
21801
|
+
transform: { left: 40, top: 174, width: 250, height: 86 },
|
|
21802
|
+
style: {
|
|
21803
|
+
fontSize: 10.5,
|
|
21804
|
+
lineHeight: 1.45,
|
|
21805
|
+
textAlign: "center",
|
|
21806
|
+
verticalAlign: "middle",
|
|
21807
|
+
color: "#1e293b",
|
|
21808
|
+
backgroundColor: "#eff6ff",
|
|
21809
|
+
borderColor: "#93c5fd",
|
|
21810
|
+
borderWidth: 1,
|
|
21811
|
+
padding: 6
|
|
21812
|
+
}
|
|
21813
|
+
},
|
|
21814
|
+
{
|
|
21815
|
+
id: "s2-right-bottom",
|
|
21816
|
+
type: "text" /* TEXT */,
|
|
21817
|
+
content: "\u53F3\u5BF9\u9F50\xB7\u5E95\u90E8\u793A\u4F8B\uFF08Right / Bottom\uFF09\n\u8D22\u52A1\u4E13\u7528\u7AE0 \uFF5C \u4ED3\u5E93\u7B7E\u7AE0\n2026-01-31",
|
|
21818
|
+
transform: { left: 305.28, top: 174, width: 250, height: 86 },
|
|
21819
|
+
style: {
|
|
21820
|
+
fontSize: 10.5,
|
|
21821
|
+
lineHeight: 1.4,
|
|
21822
|
+
textAlign: "right",
|
|
21823
|
+
verticalAlign: "bottom",
|
|
21824
|
+
color: "#0f766e",
|
|
21825
|
+
backgroundColor: "#f0fdfa",
|
|
21826
|
+
borderColor: "#5eead4",
|
|
21827
|
+
borderWidth: 1,
|
|
21828
|
+
padding: 6
|
|
21829
|
+
}
|
|
21830
|
+
},
|
|
21831
|
+
{
|
|
21832
|
+
id: "s2-autofit-shrink",
|
|
21833
|
+
type: "text" /* TEXT */,
|
|
21834
|
+
content: "\u7F29\u5C0F\u5B57\u53F7\u81EA\u9002\u5E94\u793A\u4F8B\uFF08autoFitFontSize\uFF09\uFF1A\u5F53\u957F\u6587\u672C\u8D85\u51FA\u7D27\u51D1\u9AD8\u5EA6\u65F6\u81EA\u52A8\u7F29\u5C0F\u5B57\u53F7\u81F3\u4E0D\u4F4E\u4E8E\u6700\u5C0F\u5B57\u53F7\uFF0C\u5B8C\u6574\u4FDD\u7559\u534E\u4E1C\u5F20\u6C5F\u56ED\u533A\u7CBE\u5BC6\u63A7\u5236\u5668\u7EC4\u4EF6\u9A8C\u6536\u8BF4\u660E\u4E0E Batch-2026-Q1 \u7F16\u53F7\u3002",
|
|
21835
|
+
overflow: "shrink",
|
|
21836
|
+
autoFitFontSize: true,
|
|
21837
|
+
minFontSize: 7,
|
|
21838
|
+
transform: { left: 40, top: 278, width: 515.28, height: 42 },
|
|
21839
|
+
style: {
|
|
21840
|
+
fontSize: 12,
|
|
21841
|
+
lineHeight: 1.35,
|
|
21842
|
+
textAlign: "left",
|
|
21843
|
+
verticalAlign: "middle",
|
|
21844
|
+
color: "#334155",
|
|
21845
|
+
backgroundColor: "#fefce8",
|
|
21846
|
+
borderColor: "#fde047",
|
|
21847
|
+
borderWidth: 1,
|
|
21848
|
+
padding: 5
|
|
21849
|
+
}
|
|
21850
|
+
}
|
|
21851
|
+
]);
|
|
21852
|
+
const s3SinglePageTable = buildA4Snapshot("s3-single-page-table", "S3 \u5355\u9875\u4E94\u5217\u6BD4\u4F8B\u4E0E\u683C\u5F0F\u8868\u683C", [
|
|
21853
|
+
{
|
|
21854
|
+
id: "s3-title",
|
|
21855
|
+
type: "text" /* TEXT */,
|
|
21856
|
+
content: "S3 \u91C7\u8D2D\u51FA\u5E93\u6838\u9A8C\u5355\u9875\u660E\u7EC6\u8868\uFF08\u5217\u5BBD\u6BD4\u4F8B 1:2:1:1:1 \xB7 \u6570\u503C/\u8D27\u5E01/\u767E\u5206\u6BD4\uFF09",
|
|
21857
|
+
transform: { left: 40, top: 40, width: 515.28, height: 28 },
|
|
21858
|
+
style: { fontSize: 13.5, fontWeight: "bold", color: "#0f172a", verticalAlign: "middle" }
|
|
21859
|
+
},
|
|
21860
|
+
{
|
|
21861
|
+
id: "s3-table",
|
|
21862
|
+
type: "table" /* TABLE */,
|
|
21863
|
+
transform: { left: 40, top: 82, width: 515.28, height: 196 },
|
|
21864
|
+
headerHeight: 28,
|
|
21865
|
+
rowHeight: 24,
|
|
21866
|
+
borderColor: "#cbd5e1",
|
|
21867
|
+
borderWidth: 0.8,
|
|
21868
|
+
zebraStripeColor: "#f1f5f9",
|
|
21869
|
+
headerStyle: {
|
|
21870
|
+
fontSize: 10,
|
|
21871
|
+
fontWeight: "bold",
|
|
21872
|
+
color: "#ffffff",
|
|
21873
|
+
backgroundColor: "#1e293b",
|
|
21874
|
+
padding: 5
|
|
21875
|
+
},
|
|
21876
|
+
bodyStyle: {
|
|
21877
|
+
fontSize: 9.5,
|
|
21878
|
+
color: "#0f172a",
|
|
21879
|
+
padding: 5
|
|
21880
|
+
},
|
|
21881
|
+
columns: [
|
|
21882
|
+
{ id: "c1", header: "\u5E8F\u53F7", field: "seq", widthRatio: 1, align: "center", format: "text" },
|
|
21883
|
+
{ id: "c2", header: "\u5546\u54C1\u89C4\u683C\u8BF4\u660E", field: "spec", widthRatio: 2, align: "left", format: "text" },
|
|
21884
|
+
{ id: "c3", header: "\u6570\u91CF", field: "qty", widthRatio: 1, align: "right", format: "number", decimals: 0 },
|
|
21885
|
+
{
|
|
21886
|
+
id: "c4",
|
|
21887
|
+
header: "\u5355\u4EF7",
|
|
21888
|
+
field: "price",
|
|
21889
|
+
widthRatio: 1,
|
|
21890
|
+
align: "right",
|
|
21891
|
+
format: "currency",
|
|
21892
|
+
currencySymbol: "\xA5",
|
|
21893
|
+
decimals: 2
|
|
21894
|
+
},
|
|
21895
|
+
{ id: "c5", header: "\u5B8C\u6210\u5EA6", field: "rate", widthRatio: 1, align: "right", format: "percent", decimals: 1 }
|
|
21896
|
+
],
|
|
21897
|
+
rows: [
|
|
21898
|
+
["A-01", "\u5DE5\u4E1A\u4F20\u611F\u5668\u6A21\u5757\uFF08\u534E\u4E1C\u6807\u51C6\u7248\uFF09", "1200", "358.5", "0.985"],
|
|
21899
|
+
["A-02", "\u7CBE\u5BC6\u63A7\u5236\u5668\u7EC4\u4EF6 Controller-V2", "450", "1280", "1"],
|
|
21900
|
+
["A-03", "\u5F20\u6C5F\u56ED\u533A\u6B21\u65E5\u8FBE\u4FDD\u4EF7\u8FD0\u8F93\u5305", "3200", "45.25", "0.962"],
|
|
21901
|
+
["A-04", "\u534E\u5357\u6DF1\u5733\u9646\u8FD0\u4E13\u7968\u6838\u9A8C\u6279\u6B21", "860", "512.8", "0.894"],
|
|
21902
|
+
["A-05", "\u534E\u5317\u5317\u4EAC\u4ED3\u5E93\u7B7E\u7AE0\u8FFD\u6EAF\u7801\u5957\u88C5", "1540", "96", "0.998"],
|
|
21903
|
+
["A-06", "\u5E74\u5EA6\u5408\u8BA1\u5907\u54C1\u6A21\u5757\uFF08\u5185\u90E8\u8D44\u6599\uFF09", "300", "2150.4", "0.95"]
|
|
21904
|
+
]
|
|
21905
|
+
}
|
|
21906
|
+
]);
|
|
21907
|
+
const overflowRows = [
|
|
21908
|
+
[
|
|
21909
|
+
"\u4E0A\u6D77\u6D66\u4E1C\u5F20\u6C5F\u9AD8\u79D1\u6280\u56ED\u533A\u5DE5\u4E1A\u4F20\u611F\u5668\u7CBE\u5BC6\u63A7\u5236\u5668\u7EC4\u4EF6\u6838\u9A8C\u901A\u8FC7\u660E\u7EC6\u8D85\u51FA\u88C1\u5207\u4E0D\u5916\u6EA2",
|
|
21910
|
+
"SupercalifragilisticexpialidociousControllerModule2026OverflowCheck",
|
|
21911
|
+
"\u7B2C\u4E00\u884C\uFF1A\u5DF2\u6838\u9A8C\n\u7B2C\u4E8C\u884C\uFF1A\u5F85\u5BA1\u8BF4\u660E\n\u7B2C\u4E09\u884C\uFF1A\u8D85\u51FA\u88C1\u5207\u4E0D\u5916\u6EA2",
|
|
21912
|
+
"\u6B63\u5E38\u90BB\u683C A1"
|
|
21913
|
+
],
|
|
21914
|
+
[
|
|
21915
|
+
"\u5317\u4EAC\u6DF1\u5733\u676D\u5DDE\u4E09\u5730\u4ED3\u5E93\u7B7E\u7AE0\u4E0E\u987A\u4E30\u7535\u5B50\u9762\u5355\u4E09\u8054\u91C7\u8D2D\u51FA\u5E93\u5957\u6253\u6A21\u677F\u957F\u6587\u672C\u6838\u9A8C",
|
|
21916
|
+
"ElectroencephalographicallyCalibratedSensorBatch99887766",
|
|
21917
|
+
"\u9996\u884C\u6B63\u5E38\u663E\u793A\n\u6B21\u884C\u8D85\u51FA\u56FA\u5B9A\u884C\u9AD8\u88C1\u5207",
|
|
21918
|
+
"\u6B63\u5E38\u90BB\u683C A2"
|
|
21919
|
+
]
|
|
21920
|
+
];
|
|
21921
|
+
const s4CellOverflow = buildA4Snapshot("s4-cell-overflow", "S4 \u7A84\u5217\u5355\u5143\u683C\u65AD\u884C\u88C1\u5207\u4E0E\u81EA\u9002\u5E94\u5B57\u53F7", [
|
|
21922
|
+
{
|
|
21923
|
+
id: "s4-title-clip",
|
|
21924
|
+
type: "text" /* TEXT */,
|
|
21925
|
+
content: "S4-A \u9ED8\u8BA4\u56FA\u5B9A\u884C\u9AD8\uFF0824pt\uFF09\u7A84\u5217\u6EA2\u51FA\u4E25\u683C\u88C1\u5207\uFF08T4 \u65AD\u884C + T5 \u5355\u5143\u683C\u5185\u88C1\u5207\uFF0C\u4E0D\u4FB5\u5165\u90BB\u683C\uFF09",
|
|
21926
|
+
transform: { left: 40, top: 40, width: 515.28, height: 24 },
|
|
21927
|
+
style: { fontSize: 11.5, fontWeight: "bold", color: "#0f172a", verticalAlign: "middle" }
|
|
21928
|
+
},
|
|
21929
|
+
{
|
|
21930
|
+
id: "s4-table-clip",
|
|
21931
|
+
type: "table" /* TABLE */,
|
|
21932
|
+
transform: { left: 40, top: 72, width: 515.28, height: 84 },
|
|
21933
|
+
headerHeight: 26,
|
|
21934
|
+
rowHeight: 24,
|
|
21935
|
+
borderColor: "#94a3b8",
|
|
21936
|
+
borderWidth: 0.8,
|
|
21937
|
+
zebraStripeColor: "#f8fafc",
|
|
21938
|
+
headerStyle: {
|
|
21939
|
+
fontSize: 9.5,
|
|
21940
|
+
fontWeight: "bold",
|
|
21941
|
+
color: "#ffffff",
|
|
21942
|
+
backgroundColor: "#334155",
|
|
21943
|
+
padding: 4
|
|
21944
|
+
},
|
|
21945
|
+
bodyStyle: {
|
|
21946
|
+
fontSize: 9.5,
|
|
21947
|
+
color: "#0f172a",
|
|
21948
|
+
padding: 4
|
|
21949
|
+
},
|
|
21950
|
+
columns: [
|
|
21951
|
+
{ id: "o1", header: "\u7A84\u5217\u957F\u4E2D\u6587", field: "cjk", widthRatio: 1, align: "left" },
|
|
21952
|
+
{ id: "o2", header: "\u7A84\u5217\u8D85\u957F\u897F\u6587", field: "latin", widthRatio: 1, align: "left" },
|
|
21953
|
+
{ id: "o3", header: "\u7A84\u5217\u591A\u884C\u6587\u672C", field: "multi", widthRatio: 1, align: "left" },
|
|
21954
|
+
{ id: "o4", header: "\u5BF9\u7167\u90BB\u683C", field: "neighbor", widthRatio: 1, align: "center" }
|
|
21955
|
+
],
|
|
21956
|
+
rows: overflowRows
|
|
21957
|
+
},
|
|
21958
|
+
{
|
|
21959
|
+
id: "s4-title-autofit",
|
|
21960
|
+
type: "text" /* TEXT */,
|
|
21961
|
+
content: "S4-B \u5F00\u542F\u8868\u683C\u5355\u5143\u683C\u7F29\u5C0F\u5B57\u53F7\uFF08T6 autoFitFontSize: true, minFontSize: 6.5\uFF09",
|
|
21962
|
+
transform: { left: 40, top: 180, width: 515.28, height: 24 },
|
|
21963
|
+
style: { fontSize: 11.5, fontWeight: "bold", color: "#0f766e", verticalAlign: "middle" }
|
|
21964
|
+
},
|
|
21965
|
+
{
|
|
21966
|
+
id: "s4-table-autofit",
|
|
21967
|
+
type: "table" /* TABLE */,
|
|
21968
|
+
transform: { left: 40, top: 212, width: 515.28, height: 84 },
|
|
21969
|
+
headerHeight: 26,
|
|
21970
|
+
rowHeight: 24,
|
|
21971
|
+
autoFitFontSize: true,
|
|
21972
|
+
minFontSize: 6.5,
|
|
21973
|
+
borderColor: "#94a3b8",
|
|
21974
|
+
borderWidth: 0.8,
|
|
21975
|
+
zebraStripeColor: "#f0fdfa",
|
|
21976
|
+
headerStyle: {
|
|
21977
|
+
fontSize: 9.5,
|
|
21978
|
+
fontWeight: "bold",
|
|
21979
|
+
color: "#ffffff",
|
|
21980
|
+
backgroundColor: "#0f766e",
|
|
21981
|
+
padding: 4
|
|
21982
|
+
},
|
|
21983
|
+
bodyStyle: {
|
|
21984
|
+
fontSize: 9.5,
|
|
21985
|
+
color: "#0f172a",
|
|
21986
|
+
padding: 4
|
|
21987
|
+
},
|
|
21988
|
+
columns: [
|
|
21989
|
+
{ id: "a1", header: "\u7A84\u5217\u957F\u4E2D\u6587", field: "cjk", widthRatio: 1, align: "left" },
|
|
21990
|
+
{ id: "a2", header: "\u7A84\u5217\u8D85\u957F\u897F\u6587", field: "latin", widthRatio: 1, align: "left" },
|
|
21991
|
+
{ id: "a3", header: "\u7A84\u5217\u591A\u884C\u6587\u672C", field: "multi", widthRatio: 1, align: "left" },
|
|
21992
|
+
{ id: "a4", header: "\u5BF9\u7167\u90BB\u683C", field: "neighbor", widthRatio: 1, align: "center" }
|
|
21993
|
+
],
|
|
21994
|
+
rows: overflowRows
|
|
21995
|
+
}
|
|
21996
|
+
]);
|
|
21997
|
+
const s5Rows = Array.from({ length: 35 }, (_, idx) => {
|
|
21998
|
+
const seq = String(idx + 1).padStart(2, "0");
|
|
21999
|
+
const region = idx % 3 === 0 ? "\u534E\u4E1C\u4E0A\u6D77\u56ED\u533A" : idx % 3 === 1 ? "\u534E\u5357\u6DF1\u5733\u56ED\u533A" : "\u534E\u5317\u5317\u4EAC\u56ED\u533A";
|
|
22000
|
+
const item = idx % 2 === 0 ? "\u5DE5\u4E1A\u4F20\u611F\u5668\u6A21\u5757" : "\u7CBE\u5BC6\u63A7\u5236\u5668\u7EC4\u4EF6";
|
|
22001
|
+
const qty = String((idx + 1) * 10);
|
|
22002
|
+
const amount = ((idx + 1) * 125.5).toFixed(2);
|
|
22003
|
+
return [`R-${seq}`, `${region}\xB7${item}`, qty, amount, idx % 2 === 0 ? "\u5DF2\u6838\u9A8C" : "\u901A\u8FC7"];
|
|
22004
|
+
});
|
|
22005
|
+
const s5MultiPageTable = buildA4Snapshot("s5-multipage-table", "S5 \u591A\u9875\u8868\u683C\u4E0E\u4E0A\u4E0B\u5143\u7D20\u6D41\u8F6C", [
|
|
22006
|
+
{
|
|
22007
|
+
id: "s5-above-title",
|
|
22008
|
+
type: "text" /* TEXT */,
|
|
22009
|
+
content: "S5 \u591A\u9875\u51FA\u5165\u5E93\u6838\u9A8C\u660E\u7EC6\u8868\uFF08\u5355\u9875\u5BB9\u91CF 14 \u884C \xD7 2.5 \u500D = 35 \u884C\uFF09",
|
|
22010
|
+
transform: { left: 40, top: 42, width: 515.28, height: 26 },
|
|
22011
|
+
style: { fontSize: 13.5, fontWeight: "bold", color: "#0f172a", verticalAlign: "middle" }
|
|
22012
|
+
},
|
|
22013
|
+
{
|
|
22014
|
+
id: "s5-above-meta",
|
|
22015
|
+
type: "text" /* TEXT */,
|
|
22016
|
+
content: "\u5355\u636E\u72B6\u6001\uFF1A\u5DF2\u6838\u9A8C \uFF5C \u56ED\u533A\uFF1A\u534E\u4E1C\u5F20\u6C5F\u9AD8\u79D1\u6280\u56ED\u533A \uFF5C \u65E5\u671F\uFF1A2026-01-31",
|
|
22017
|
+
transform: { left: 40, top: 72, width: 515.28, height: 22 },
|
|
22018
|
+
style: {
|
|
22019
|
+
fontSize: 10,
|
|
22020
|
+
color: "#334155",
|
|
22021
|
+
backgroundColor: "#f8fafc",
|
|
22022
|
+
borderColor: "#cbd5e1",
|
|
22023
|
+
borderWidth: 0.8,
|
|
22024
|
+
padding: 4,
|
|
22025
|
+
verticalAlign: "middle"
|
|
22026
|
+
}
|
|
22027
|
+
},
|
|
22028
|
+
{
|
|
22029
|
+
id: "s5-table",
|
|
22030
|
+
type: "table" /* TABLE */,
|
|
22031
|
+
transform: { left: 40, top: 106, width: 515.28, height: 362 },
|
|
22032
|
+
headerHeight: 26,
|
|
22033
|
+
rowHeight: 24,
|
|
22034
|
+
repeatHeader: true,
|
|
22035
|
+
zebraParity: "continuous",
|
|
22036
|
+
zebraStripeColor: "#f1f5f9",
|
|
22037
|
+
borderColor: "#cbd5e1",
|
|
22038
|
+
borderWidth: 0.8,
|
|
22039
|
+
headerStyle: {
|
|
22040
|
+
fontSize: 10,
|
|
22041
|
+
fontWeight: "bold",
|
|
22042
|
+
color: "#ffffff",
|
|
22043
|
+
backgroundColor: "#1e293b",
|
|
22044
|
+
padding: 5
|
|
22045
|
+
},
|
|
22046
|
+
bodyStyle: {
|
|
22047
|
+
fontSize: 9.5,
|
|
22048
|
+
color: "#0f172a",
|
|
22049
|
+
padding: 5
|
|
22050
|
+
},
|
|
22051
|
+
columns: [
|
|
22052
|
+
{ id: "m1", header: "\u8BA2\u5355\u7F16\u53F7", field: "no", widthRatio: 1, align: "center", format: "text" },
|
|
22053
|
+
{ id: "m2", header: "\u5546\u54C1\u89C4\u683C", field: "spec", widthRatio: 2, align: "left", format: "text" },
|
|
22054
|
+
{ id: "m3", header: "\u6570\u91CF", field: "qty", widthRatio: 1, align: "right", format: "number", decimals: 0 },
|
|
22055
|
+
{
|
|
22056
|
+
id: "m4",
|
|
22057
|
+
header: "\u91D1\u989D",
|
|
22058
|
+
field: "amt",
|
|
22059
|
+
widthRatio: 1,
|
|
22060
|
+
align: "right",
|
|
22061
|
+
format: "currency",
|
|
22062
|
+
currencySymbol: "\xA5",
|
|
22063
|
+
decimals: 2
|
|
22064
|
+
},
|
|
22065
|
+
{ id: "m5", header: "\u72B6\u6001", field: "status", widthRatio: 1, align: "center", format: "text" }
|
|
22066
|
+
],
|
|
22067
|
+
rows: s5Rows
|
|
22068
|
+
},
|
|
22069
|
+
{
|
|
22070
|
+
id: "s5-below-footer",
|
|
22071
|
+
type: "text" /* TEXT */,
|
|
22072
|
+
content: "\u8868\u540E\u7B7E\u6536\u680F\uFF1A\u5BA1\u6279\u4EBA \u5F20\u5DE5 \uFF5C \u8D22\u52A1\u4E13\u7528\u7AE0 \uFF5C \u4ED3\u5E93\u7B7E\u7AE0\uFF08\u4EC5\u5728\u672B\u9875\u8868\u5C3E\u51FA\u73B0\uFF0C\u4E0D\u4E0E\u8868\u683C\u91CD\u53E0\uFF09",
|
|
22073
|
+
transform: { left: 40, top: 486, width: 515.28, height: 32 },
|
|
22074
|
+
style: {
|
|
22075
|
+
fontSize: 10.5,
|
|
22076
|
+
fontWeight: "bold",
|
|
22077
|
+
color: "#0f766e",
|
|
22078
|
+
backgroundColor: "#f0fdfa",
|
|
22079
|
+
borderColor: "#5eead4",
|
|
22080
|
+
borderWidth: 1,
|
|
22081
|
+
padding: 6,
|
|
22082
|
+
verticalAlign: "middle"
|
|
22083
|
+
}
|
|
22084
|
+
}
|
|
22085
|
+
]);
|
|
22086
|
+
const s6MissingGlyphs = import_core10.Tools.deepClone(s1ShortCjk);
|
|
22087
|
+
s6MissingGlyphs.id = "s6-missing-glyphs";
|
|
22088
|
+
s6MissingGlyphs.name = "S6 \u7F3A\u5B57\u4E0E\u5B57\u4F53\u5F02\u5E38\u8BCA\u65AD";
|
|
22089
|
+
s6MissingGlyphs.editState.elementsByPage["page-1"]["s6-missing-note"] = {
|
|
22090
|
+
id: "s6-missing-note",
|
|
22091
|
+
type: "text" /* TEXT */,
|
|
22092
|
+
content: "\u7F3A\u5B57\u8BCA\u65AD\u5907\u6CE8\uFF1A\u751F\u50FB\u5B57\u9F98\u4E0E\u56FE\u6807\u{1F680}\u6838\u9A8C",
|
|
22093
|
+
transform: { left: 40, top: 286, width: 515.28, height: 28 },
|
|
22094
|
+
style: {
|
|
22095
|
+
fontSize: 11,
|
|
22096
|
+
color: "#b91c1c",
|
|
22097
|
+
backgroundColor: "#fef2f2",
|
|
22098
|
+
borderColor: "#fecaca",
|
|
22099
|
+
borderWidth: 1,
|
|
22100
|
+
padding: 5,
|
|
22101
|
+
verticalAlign: "middle"
|
|
22102
|
+
}
|
|
22103
|
+
};
|
|
22104
|
+
s6MissingGlyphs.editState.elementOrderByPage["page-1"].push("s6-missing-note");
|
|
22105
|
+
const s7DefaultNoFont = import_core10.Tools.deepClone(s1ShortCjk);
|
|
22106
|
+
s7DefaultNoFont.id = "s7-default-no-font";
|
|
22107
|
+
s7DefaultNoFont.name = "S7 \u9ED8\u8BA4\u672A\u4F20\u5B57\u4F53\u5149\u6805\u517C\u5BB9\u6A21\u5F0F";
|
|
22108
|
+
return {
|
|
22109
|
+
s1ShortCjk,
|
|
22110
|
+
s2LongTextBox,
|
|
22111
|
+
s3SinglePageTable,
|
|
22112
|
+
s4CellOverflow,
|
|
22113
|
+
s5MultiPageTable,
|
|
22114
|
+
s6MissingGlyphs,
|
|
22115
|
+
s7DefaultNoFont
|
|
22116
|
+
};
|
|
22117
|
+
}
|
|
22118
|
+
|
|
20927
22119
|
// src/jsx/types.ts
|
|
20928
22120
|
var PDF_JSX_ELEMENT_SYMBOL = /* @__PURE__ */ Symbol.for("univer.pdfs.jsx.element");
|
|
20929
22121
|
var PDF_JSX_FRAGMENT_SYMBOL = /* @__PURE__ */ Symbol.for("univer.pdfs.jsx.fragment");
|
|
@@ -22170,10 +23362,10 @@ async function exportJsxToPdfBytes(root, runtimeData, options) {
|
|
|
22170
23362
|
}
|
|
22171
23363
|
|
|
22172
23364
|
// src/plugin.ts
|
|
22173
|
-
var
|
|
23365
|
+
var import_core12 = require("@univerjs/core");
|
|
22174
23366
|
|
|
22175
23367
|
// src/services/pdf-io.service.ts
|
|
22176
|
-
var
|
|
23368
|
+
var import_core11 = require("@univerjs/core");
|
|
22177
23369
|
var import_rxjs3 = require("rxjs");
|
|
22178
23370
|
function uint8ToBase64(bytes) {
|
|
22179
23371
|
let binary = "";
|
|
@@ -22227,7 +23419,7 @@ function createHttpSilentPrintAdapter(config) {
|
|
|
22227
23419
|
payload = null;
|
|
22228
23420
|
}
|
|
22229
23421
|
return {
|
|
22230
|
-
jobId: String(payload?.jobId || payload?.id || `print-${(0,
|
|
23422
|
+
jobId: String(payload?.jobId || payload?.id || `print-${(0, import_core11.generateRandomId)(8)}`),
|
|
22231
23423
|
driver: String(payload?.driver || driver),
|
|
22232
23424
|
byteLength: pdfBytes.byteLength,
|
|
22233
23425
|
printedAt: Number(payload?.printedAt || Date.now())
|
|
@@ -22283,7 +23475,7 @@ function computePdfPayloadDigest(input) {
|
|
|
22283
23475
|
const d2 = (h2 >>> 0).toString(16).padStart(8, "0");
|
|
22284
23476
|
return `fnv64:${d1}${d2}:${approxBytes}:${len}`;
|
|
22285
23477
|
}
|
|
22286
|
-
var IPdfIoService = (0,
|
|
23478
|
+
var IPdfIoService = (0, import_core11.createIdentifier)("yudao.univer-pdfs.io.service");
|
|
22287
23479
|
async function normalizeBinaryToUint8Array(output) {
|
|
22288
23480
|
if (output instanceof Uint8Array) {
|
|
22289
23481
|
return output;
|
|
@@ -22469,23 +23661,23 @@ function normalizePdfImportWarnings(raw) {
|
|
|
22469
23661
|
return normalized;
|
|
22470
23662
|
}
|
|
22471
23663
|
function buildOverlayImportCandidateSnapshot(baseSnapshot, outcome) {
|
|
22472
|
-
const prevSnapshot =
|
|
23664
|
+
const prevSnapshot = import_core11.Tools.deepClone(baseSnapshot);
|
|
22473
23665
|
const existingOrder = prevSnapshot.document?.pageOrder ?? [];
|
|
22474
23666
|
const pageSizes = outcome.pageSizes ?? [];
|
|
22475
23667
|
const totalPages = Math.max(1, pageSizes.length || outcome.sourceDocumentRef.pageCount || 1);
|
|
22476
23668
|
const nextPages = {};
|
|
22477
23669
|
const nextPageOrder = [];
|
|
22478
|
-
const nextElementsByPage =
|
|
22479
|
-
const nextElementOrderByPage =
|
|
23670
|
+
const nextElementsByPage = import_core11.Tools.deepClone(prevSnapshot.editState?.elementsByPage ?? {});
|
|
23671
|
+
const nextElementOrderByPage = import_core11.Tools.deepClone(prevSnapshot.editState?.elementOrderByPage ?? {});
|
|
22480
23672
|
for (let i = 0; i < totalPages; i++) {
|
|
22481
|
-
const pid = existingOrder[i] || `page-${(0,
|
|
23673
|
+
const pid = existingOrder[i] || `page-${(0, import_core11.generateRandomId)(6)}`;
|
|
22482
23674
|
nextPageOrder.push(pid);
|
|
22483
23675
|
const resolvedSize = pageSizes[i] ?? pageSizes[0] ?? prevSnapshot.document.pageSize;
|
|
22484
23676
|
nextPages[pid] = {
|
|
22485
23677
|
id: pid,
|
|
22486
23678
|
title: `Page ${i + 1}`,
|
|
22487
23679
|
sourcePageNumber: i + 1,
|
|
22488
|
-
pageSize:
|
|
23680
|
+
pageSize: import_core11.Tools.deepClone(resolvedSize),
|
|
22489
23681
|
backgroundColor: "#ffffff"
|
|
22490
23682
|
};
|
|
22491
23683
|
if (!nextElementsByPage[pid]) nextElementsByPage[pid] = {};
|
|
@@ -22493,10 +23685,10 @@ function buildOverlayImportCandidateSnapshot(baseSnapshot, outcome) {
|
|
|
22493
23685
|
}
|
|
22494
23686
|
return {
|
|
22495
23687
|
...prevSnapshot,
|
|
22496
|
-
sourceDocumentRef:
|
|
23688
|
+
sourceDocumentRef: import_core11.Tools.deepClone(outcome.sourceDocumentRef),
|
|
22497
23689
|
document: {
|
|
22498
23690
|
...prevSnapshot.document,
|
|
22499
|
-
pageSize:
|
|
23691
|
+
pageSize: import_core11.Tools.deepClone(pageSizes[0] ?? prevSnapshot.document.pageSize),
|
|
22500
23692
|
pages: nextPages,
|
|
22501
23693
|
pageOrder: nextPageOrder
|
|
22502
23694
|
},
|
|
@@ -22517,8 +23709,8 @@ function normalizeAdapterImportResult(raw) {
|
|
|
22517
23709
|
return {
|
|
22518
23710
|
outcome: {
|
|
22519
23711
|
mode: "overlay",
|
|
22520
|
-
sourceDocumentRef:
|
|
22521
|
-
pageSizes:
|
|
23712
|
+
sourceDocumentRef: import_core11.Tools.deepClone(record.sourceDocumentRef),
|
|
23713
|
+
pageSizes: import_core11.Tools.deepClone(record.pageSizes ?? []),
|
|
22522
23714
|
...warnings.length > 0 ? { warnings } : {}
|
|
22523
23715
|
},
|
|
22524
23716
|
warnings
|
|
@@ -22526,7 +23718,7 @@ function normalizeAdapterImportResult(raw) {
|
|
|
22526
23718
|
}
|
|
22527
23719
|
if (record.mode === "snapshot") {
|
|
22528
23720
|
const warnings = normalizePdfImportWarnings(record.warnings);
|
|
22529
|
-
const clonedSnapshot =
|
|
23721
|
+
const clonedSnapshot = import_core11.Tools.deepClone(record.snapshot);
|
|
22530
23722
|
return {
|
|
22531
23723
|
outcome: {
|
|
22532
23724
|
mode: "snapshot",
|
|
@@ -22538,7 +23730,7 @@ function normalizeAdapterImportResult(raw) {
|
|
|
22538
23730
|
}
|
|
22539
23731
|
if (record.snapshot && typeof record.snapshot === "object") {
|
|
22540
23732
|
const warnings = normalizePdfImportWarnings(record.warnings);
|
|
22541
|
-
const clonedSnapshot =
|
|
23733
|
+
const clonedSnapshot = import_core11.Tools.deepClone(record.snapshot);
|
|
22542
23734
|
return {
|
|
22543
23735
|
outcome: {
|
|
22544
23736
|
mode: "snapshot",
|
|
@@ -22550,7 +23742,7 @@ function normalizeAdapterImportResult(raw) {
|
|
|
22550
23742
|
}
|
|
22551
23743
|
if ("schema" in record || "document" in record) {
|
|
22552
23744
|
const warnings = normalizePdfImportWarnings(record.warnings);
|
|
22553
|
-
const clonedSnapshot =
|
|
23745
|
+
const clonedSnapshot = import_core11.Tools.deepClone(record);
|
|
22554
23746
|
delete clonedSnapshot.warnings;
|
|
22555
23747
|
return {
|
|
22556
23748
|
outcome: {
|
|
@@ -22738,7 +23930,7 @@ async function importPdfSource(source, options) {
|
|
|
22738
23930
|
mode: "overlay",
|
|
22739
23931
|
bytes,
|
|
22740
23932
|
sourceDocumentRef: {
|
|
22741
|
-
id: `src-${(0,
|
|
23933
|
+
id: `src-${(0, import_core11.generateRandomId)(6)}`,
|
|
22742
23934
|
fileName,
|
|
22743
23935
|
mimeType: "application/pdf",
|
|
22744
23936
|
dataUri,
|
|
@@ -22791,7 +23983,7 @@ async function fallbackReadFileAsOutcome(file, baseSnapshot, password) {
|
|
|
22791
23983
|
...imported.warnings?.length ? { warnings: imported.warnings } : {}
|
|
22792
23984
|
};
|
|
22793
23985
|
}
|
|
22794
|
-
var PdfIoService = class extends
|
|
23986
|
+
var PdfIoService = class extends import_core11.Disposable {
|
|
22795
23987
|
constructor(_univerInstanceService) {
|
|
22796
23988
|
super();
|
|
22797
23989
|
this._univerInstanceService = _univerInstanceService;
|
|
@@ -22980,7 +24172,7 @@ var PdfIoService = class extends import_core10.Disposable {
|
|
|
22980
24172
|
}
|
|
22981
24173
|
_resolveBaseSnapshotForImport(context) {
|
|
22982
24174
|
if (context?.snapshot) {
|
|
22983
|
-
const cloned =
|
|
24175
|
+
const cloned = import_core11.Tools.deepClone(context.snapshot);
|
|
22984
24176
|
return {
|
|
22985
24177
|
unitId: context.unitId || cloned.id,
|
|
22986
24178
|
baseSnapshot: cloned
|
|
@@ -22989,9 +24181,9 @@ var PdfIoService = class extends import_core10.Disposable {
|
|
|
22989
24181
|
if (this._univerInstanceService) {
|
|
22990
24182
|
const unit = context?.unitId ? this._univerInstanceService.getUnit(
|
|
22991
24183
|
context.unitId,
|
|
22992
|
-
|
|
24184
|
+
import_core11.UniverInstanceType.UNIVER_PDF
|
|
22993
24185
|
) : this._univerInstanceService.getCurrentUnitOfType(
|
|
22994
|
-
|
|
24186
|
+
import_core11.UniverInstanceType.UNIVER_PDF
|
|
22995
24187
|
);
|
|
22996
24188
|
if (unit) {
|
|
22997
24189
|
return {
|
|
@@ -23037,7 +24229,7 @@ var PdfIoService = class extends import_core10.Disposable {
|
|
|
23037
24229
|
try {
|
|
23038
24230
|
rawResult = await adapter.importPdf(file, {
|
|
23039
24231
|
unitId,
|
|
23040
|
-
snapshot:
|
|
24232
|
+
snapshot: import_core11.Tools.deepClone(baseSnapshot),
|
|
23041
24233
|
defaultImport
|
|
23042
24234
|
});
|
|
23043
24235
|
} catch (err) {
|
|
@@ -23057,7 +24249,7 @@ var PdfIoService = class extends import_core10.Disposable {
|
|
|
23057
24249
|
}
|
|
23058
24250
|
}
|
|
23059
24251
|
const { outcome, warnings } = normalizeAdapterImportResult(rawResult);
|
|
23060
|
-
const candidateSnapshot = outcome.mode === "snapshot" ?
|
|
24252
|
+
const candidateSnapshot = outcome.mode === "snapshot" ? import_core11.Tools.deepClone(outcome.snapshot) : buildOverlayImportCandidateSnapshot(baseSnapshot, outcome);
|
|
23061
24253
|
return {
|
|
23062
24254
|
snapshot: candidateSnapshot,
|
|
23063
24255
|
outcome,
|
|
@@ -23075,7 +24267,7 @@ var PdfIoService = class extends import_core10.Disposable {
|
|
|
23075
24267
|
cancel: false
|
|
23076
24268
|
};
|
|
23077
24269
|
if (this.runBeforeExportHooks(beforeEvent)) {
|
|
23078
|
-
throw new
|
|
24270
|
+
throw new import_core11.CanceledError();
|
|
23079
24271
|
}
|
|
23080
24272
|
const defaultExport = () => exportPdfBytes(params.snapshot, params.data, params.options);
|
|
23081
24273
|
const adapter = this._adapter$.getValue();
|
|
@@ -23137,7 +24329,7 @@ var PdfIoService = class extends import_core10.Disposable {
|
|
|
23137
24329
|
options: params.options,
|
|
23138
24330
|
cancel: false
|
|
23139
24331
|
})) {
|
|
23140
|
-
throw new
|
|
24332
|
+
throw new import_core11.CanceledError();
|
|
23141
24333
|
}
|
|
23142
24334
|
const adapter = this._adapter$.getValue();
|
|
23143
24335
|
if (!adapter.onSilentPrint) {
|
|
@@ -23180,12 +24372,12 @@ var PdfIoService = class extends import_core10.Disposable {
|
|
|
23180
24372
|
}
|
|
23181
24373
|
};
|
|
23182
24374
|
PdfIoService = __decorateClass([
|
|
23183
|
-
__decorateParam(0, (0,
|
|
24375
|
+
__decorateParam(0, (0, import_core11.Optional)(import_core11.IUniverInstanceService))
|
|
23184
24376
|
], PdfIoService);
|
|
23185
24377
|
|
|
23186
24378
|
// src/plugin.ts
|
|
23187
24379
|
var UNIVER_PDFS_PLUGIN_NAME = "UNIVER_PDFS_PLUGIN";
|
|
23188
|
-
var UniverPdfsPlugin = class extends
|
|
24380
|
+
var UniverPdfsPlugin = class extends import_core12.Plugin {
|
|
23189
24381
|
constructor(_config = {}, _injector, _univerInstanceService, _commandService) {
|
|
23190
24382
|
super();
|
|
23191
24383
|
this._config = _config;
|
|
@@ -23201,9 +24393,9 @@ var UniverPdfsPlugin = class extends import_core11.Plugin {
|
|
|
23201
24393
|
}
|
|
23202
24394
|
onStarting() {
|
|
23203
24395
|
this.disposeWithMe(
|
|
23204
|
-
this._univerInstanceService.registerCtorForType(
|
|
24396
|
+
this._univerInstanceService.registerCtorForType(import_core12.UniverInstanceType.UNIVER_PDF, PdfUnitModel)
|
|
23205
24397
|
);
|
|
23206
|
-
const focusSub = this._univerInstanceService.getCurrentTypeOfUnit$(
|
|
24398
|
+
const focusSub = this._univerInstanceService.getCurrentTypeOfUnit$(import_core12.UniverInstanceType.UNIVER_PDF).subscribe((unit) => {
|
|
23207
24399
|
if (unit && this._univerInstanceService.getFocusedUnit()?.getUnitId() !== unit.getUnitId()) {
|
|
23208
24400
|
this._univerInstanceService.focusUnit(unit.getUnitId());
|
|
23209
24401
|
}
|
|
@@ -23279,9 +24471,9 @@ var UniverPdfsPlugin = class extends import_core11.Plugin {
|
|
|
23279
24471
|
}
|
|
23280
24472
|
};
|
|
23281
24473
|
UniverPdfsPlugin = __decorateClass([
|
|
23282
|
-
__decorateParam(1, (0,
|
|
23283
|
-
__decorateParam(2,
|
|
23284
|
-
__decorateParam(3,
|
|
24474
|
+
__decorateParam(1, (0, import_core12.Inject)(import_core12.Injector)),
|
|
24475
|
+
__decorateParam(2, import_core12.IUniverInstanceService),
|
|
24476
|
+
__decorateParam(3, import_core12.ICommandService)
|
|
23285
24477
|
], UniverPdfsPlugin);
|
|
23286
24478
|
// Annotate the CommonJS export names for ESM import in node:
|
|
23287
24479
|
0 && (module.exports = {
|
|
@@ -23331,6 +24523,7 @@ UniverPdfsPlugin = __decorateClass([
|
|
|
23331
24523
|
PdfIoTargetError,
|
|
23332
24524
|
PdfListKind,
|
|
23333
24525
|
PdfListPresetId,
|
|
24526
|
+
PdfRenderError,
|
|
23334
24527
|
PdfSelectionService,
|
|
23335
24528
|
PdfTableBorderStyle,
|
|
23336
24529
|
PdfTableCellVerticalAlign,
|
|
@@ -23382,8 +24575,11 @@ UniverPdfsPlugin = __decorateClass([
|
|
|
23382
24575
|
buildMinimalTestTrueTypeFont,
|
|
23383
24576
|
buildOverlayImportCandidateSnapshot,
|
|
23384
24577
|
buildPdfTemplateFromOcrFields,
|
|
24578
|
+
calculatePdfTableRowCapacity,
|
|
23385
24579
|
canonicalJsonStringify,
|
|
24580
|
+
clearPdfFontUrlCache,
|
|
23386
24581
|
cmykToRgb,
|
|
24582
|
+
collectMissingGlyphsFromPdfUnit,
|
|
23387
24583
|
collectPdfInputContractHints,
|
|
23388
24584
|
collectUsedCodePointsFromPdfUnit,
|
|
23389
24585
|
comparePdfBytes,
|
|
@@ -23413,6 +24609,7 @@ UniverPdfsPlugin = __decorateClass([
|
|
|
23413
24609
|
createDefaultElement,
|
|
23414
24610
|
createDefaultPdfUnitData,
|
|
23415
24611
|
createHttpSilentPrintAdapter,
|
|
24612
|
+
createPdfBrowserFidelitySamples,
|
|
23416
24613
|
createPdfJsxNode,
|
|
23417
24614
|
detectCJKCharacters,
|
|
23418
24615
|
detectCJKInPdfInputs,
|
|
@@ -23560,6 +24757,7 @@ UniverPdfsPlugin = __decorateClass([
|
|
|
23560
24757
|
verifyPdfAuditSeal,
|
|
23561
24758
|
verifyPdfUnitSignature,
|
|
23562
24759
|
visitTemplateVariables,
|
|
24760
|
+
wrapMixedCjkAndLatinLines,
|
|
23563
24761
|
wrapPdfTextLines
|
|
23564
24762
|
});
|
|
23565
24763
|
//# sourceMappingURL=index.js.map
|