@evotecit/officeimo 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -10
- package/bundles/officeimo-canopyx.js +813 -358
- package/bundles/officeimo-canopyx.mjs +700 -246
- package/bundles/officeimo-csv.js +29 -19
- package/bundles/officeimo-csv.mjs +17 -7
- package/bundles/officeimo-datatables.js +806 -360
- package/bundles/officeimo-datatables.mjs +694 -249
- package/bundles/officeimo-execution.js +35 -25
- package/bundles/officeimo-execution.mjs +17 -7
- package/bundles/officeimo-pdf.js +734 -289
- package/bundles/officeimo-pdf.mjs +685 -241
- package/bundles/officeimo-xlsx.js +88 -77
- package/bundles/officeimo-xlsx.mjs +22 -11
- package/bundles/officeimo.js +790 -344
- package/bundles/officeimo.mjs +680 -235
- package/dist/core/index.d.ts +2 -0
- package/dist/core/iteration.js +2 -2
- package/dist/core/sinks.js +2 -1
- package/dist/integrations/canopyx/source.js +13 -7
- package/dist/integrations/datatables/snapshot.js +3 -3
- package/dist/internal/rows.js +13 -4
- package/dist/pdf/document-grouped.js +72 -22
- package/dist/pdf/font-resources.js +2 -1
- package/dist/pdf/inline-text.js +50 -9
- package/dist/pdf/objects.js +188 -11
- package/dist/pdf/pages.js +25 -26
- package/dist/pdf/paragraph-layout.d.ts +2 -0
- package/dist/pdf/paragraph-layout.js +9 -4
- package/dist/pdf/session.js +1 -1
- package/dist/pdf/settings.d.ts +2 -0
- package/dist/pdf/settings.js +27 -2
- package/dist/pdf/structure.js +80 -28
- package/dist/pdf/table-band-flow.js +26 -11
- package/dist/pdf/table-band-plan.js +1 -3
- package/dist/pdf/table-layout.d.ts +4 -0
- package/dist/pdf/table-layout.js +22 -10
- package/dist/pdf/table-structure.js +28 -12
- package/dist/pdf/text.js +5 -0
- package/dist/pdf/types.d.ts +4 -2
- package/dist/pdf/xref.d.ts +1 -0
- package/dist/pdf/xref.js +30 -0
- package/dist/xlsx/values.js +3 -2
- package/dist/zip/entry.js +1 -1
- package/dist/zip/index.js +1 -1
- package/package.json +1 -1
|
@@ -38,7 +38,7 @@ return _exports;
|
|
|
38
38
|
const _m4 = (() => {
|
|
39
39
|
function checkAbort(signal) {
|
|
40
40
|
if (signal?.aborted)
|
|
41
|
-
throw signal.reason
|
|
41
|
+
throw signal.reason;
|
|
42
42
|
}
|
|
43
43
|
/** Race a pending producer or sink operation without leaving abort listeners behind. */
|
|
44
44
|
function withAbort(promise, signal) {
|
|
@@ -46,7 +46,7 @@ function withAbort(promise, signal) {
|
|
|
46
46
|
return Promise.resolve(promise);
|
|
47
47
|
return new Promise((resolve, reject) => {
|
|
48
48
|
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
49
|
-
const abort = () => { cleanup(); reject(signal.reason
|
|
49
|
+
const abort = () => { cleanup(); reject(signal.reason); };
|
|
50
50
|
signal.addEventListener("abort", abort, { once: true });
|
|
51
51
|
Promise.resolve(promise).then(value => { cleanup(); resolve(value); }, error => { cleanup(); reject(error); });
|
|
52
52
|
if (signal.aborted)
|
|
@@ -199,8 +199,9 @@ async function withDestination(destination, operation) {
|
|
|
199
199
|
// Native streams can belong to another browser realm; constructor identity is not portable.
|
|
200
200
|
if (destination && typeof destination.getWriter === "function") {
|
|
201
201
|
const writer = destination.getWriter();
|
|
202
|
+
// Native streams may retain accepted chunks after write resolves.
|
|
202
203
|
try {
|
|
203
|
-
return await operation({ write: bytes => writer.write(bytes) });
|
|
204
|
+
return await operation({ write: bytes => writer.write(new Uint8Array(bytes)) });
|
|
204
205
|
}
|
|
205
206
|
finally {
|
|
206
207
|
writer.releaseLock();
|
|
@@ -498,11 +499,18 @@ function createRowProjector(columns, worksheet, signal, validate = assertExportV
|
|
|
498
499
|
const getters = columns.some(column => column.value);
|
|
499
500
|
return (row, rowIndex = 0) => {
|
|
500
501
|
if (Array.isArray(row) && !getters) {
|
|
501
|
-
|
|
502
|
+
const length = row.length;
|
|
503
|
+
if (length > columns.length)
|
|
502
504
|
throw new RangeError("Row has more values than declared columns.");
|
|
503
|
-
|
|
505
|
+
// Resolve each positional value once, just like key/value projections. Returning the
|
|
506
|
+
// source array would let an accessor change a value after the portable-value check.
|
|
507
|
+
const values = new Array(length);
|
|
508
|
+
for (let index = 0; index < length; index++) {
|
|
509
|
+
const value = row[index];
|
|
504
510
|
validate(value);
|
|
505
|
-
|
|
511
|
+
values[index] = value;
|
|
512
|
+
}
|
|
513
|
+
return values;
|
|
506
514
|
}
|
|
507
515
|
if (!row || typeof row !== "object" || isDate(row))
|
|
508
516
|
throw new TypeError("A row must be an array or object.");
|
|
@@ -531,7 +539,7 @@ function createRowProjector(columns, worksheet, signal, validate = assertExportV
|
|
|
531
539
|
};
|
|
532
540
|
}
|
|
533
541
|
/** @internal Shared metadata fields for full columns and adapter-owned partial overrides. */
|
|
534
|
-
const columnOptionFields = ["header", "key", "value", "width", "type", "format", "wrapText", "alignment", "groups", "style", "valueFormatter"];
|
|
542
|
+
const columnOptionFields = ["header", "key", "value", "width", "type", "format", "wrapText", "alignment", "rowHeader", "groups", "style", "valueFormatter"];
|
|
535
543
|
function copyColumns(columns, workbookStyles = false) {
|
|
536
544
|
if (!Array.isArray(columns))
|
|
537
545
|
throw new TypeError("Declare the columns in export order.");
|
|
@@ -547,6 +555,8 @@ function copyColumns(columns, workbookStyles = false) {
|
|
|
547
555
|
throw new TypeError("Each column needs a string header and an optional string key.");
|
|
548
556
|
if (captured.value !== undefined && typeof captured.value !== "function")
|
|
549
557
|
throw new TypeError("Column value getters must be functions.");
|
|
558
|
+
if (captured.rowHeader !== undefined && typeof captured.rowHeader !== "boolean")
|
|
559
|
+
throw new TypeError("Column rowHeader must be boolean.");
|
|
550
560
|
if (captured.groups !== undefined) {
|
|
551
561
|
if (!Array.isArray(captured.groups))
|
|
552
562
|
throw new TypeError("Column groups must be an array of strings.");
|
|
@@ -1237,10 +1247,34 @@ function captureWideTable(input) {
|
|
|
1237
1247
|
if (repeatColumns !== undefined && !Array.isArray(repeatColumns))
|
|
1238
1248
|
throw new TypeError("repeatColumns must be an array.");
|
|
1239
1249
|
const repeats = repeatColumns === undefined ? [] : [...repeatColumns];
|
|
1240
|
-
if (repeats.some(
|
|
1241
|
-
throw new RangeError("repeatColumns must contain
|
|
1250
|
+
if (repeats.some(value => typeof value === "number" ? !Number.isSafeInteger(value) || value < 0 : typeof value !== "string" || !value.length))
|
|
1251
|
+
throw new RangeError("repeatColumns must contain nonnegative indices or nonempty stable keys.");
|
|
1252
|
+
if (repeats.every(value => typeof value === "number") && repeats.some((value, index) => index > 0 && value <= repeats[index - 1]))
|
|
1253
|
+
throw new RangeError("Numeric repeatColumns must contain sorted unique nonnegative indices.");
|
|
1242
1254
|
return Object.freeze({ mode, ...(minimumColumnWidth === undefined ? {} : { minimumColumnWidth }), repeatColumns: Object.freeze(repeats) });
|
|
1243
1255
|
}
|
|
1256
|
+
/** Resolve identities against this table's captured selection, without consulting a grid or opening its rows. */
|
|
1257
|
+
function repeatedColumns(policy, columns) {
|
|
1258
|
+
if (typeof policy !== "object")
|
|
1259
|
+
return Object.freeze([]);
|
|
1260
|
+
const selected = new Set();
|
|
1261
|
+
for (const selector of policy.repeatColumns ?? []) {
|
|
1262
|
+
let position;
|
|
1263
|
+
if (typeof selector === "number")
|
|
1264
|
+
position = selector;
|
|
1265
|
+
else {
|
|
1266
|
+
position = columns.findIndex(column => column.key === selector);
|
|
1267
|
+
if (position < 0 || columns.some((column, index) => index !== position && column.key === selector))
|
|
1268
|
+
throw new TypeError("repeatColumns requires an unambiguous selected column key: " + selector);
|
|
1269
|
+
}
|
|
1270
|
+
if (position >= columns.length)
|
|
1271
|
+
throw new RangeError("repeatColumns index exceeds the declared columns.");
|
|
1272
|
+
if (selected.has(position))
|
|
1273
|
+
throw new TypeError("repeatColumns selects the same column more than once.");
|
|
1274
|
+
selected.add(position);
|
|
1275
|
+
}
|
|
1276
|
+
return Object.freeze([...selected].sort((left, right) => left - right));
|
|
1277
|
+
}
|
|
1244
1278
|
function settings(input, document = false) {
|
|
1245
1279
|
const configuration = { ...capturePdfOptions(input) };
|
|
1246
1280
|
configuration.booleanText = captureBooleanText(configuration.booleanText);
|
|
@@ -1342,6 +1376,7 @@ function settings(input, document = false) {
|
|
|
1342
1376
|
}
|
|
1343
1377
|
const maxImageWorkingBytes = options.limits?.maxImageWorkingBytes;
|
|
1344
1378
|
return { options: { ...options, paragraphStyles }, paragraphStyles, page, margins, fontSize, padding,
|
|
1379
|
+
repeatedColumns: document ? Object.freeze([]) : repeatedColumns(options.wideTable, columns),
|
|
1345
1380
|
limits: { ...limits, ...(maxImageWorkingBytes === undefined ? {} : { maxImageWorkingBytes }) }, budget };
|
|
1346
1381
|
}
|
|
1347
1382
|
const _exports = Object.freeze({ positive: _m20.positive, color: _m20.color, presentation: _m20.presentation, pdfOptionFields: pdfOptionFields, pdfLimitFields: pdfLimitFields, capturePdfOptions: capturePdfOptions, capturePdfLimits: capturePdfLimits, captureWideTable: captureWideTable, settings: settings });
|
|
@@ -1620,7 +1655,7 @@ class EntryWriter {
|
|
|
1620
1655
|
closed = false;
|
|
1621
1656
|
cleaned = false;
|
|
1622
1657
|
lifetime = new AbortController();
|
|
1623
|
-
abort = () => { this.fail(this.signal?.reason
|
|
1658
|
+
abort = () => { this.fail(this.signal?.reason); };
|
|
1624
1659
|
constructor(compression, sink, signal) {
|
|
1625
1660
|
this.sink = sink;
|
|
1626
1661
|
this.signal = signal;
|
|
@@ -1784,7 +1819,7 @@ class ZipWriter {
|
|
|
1784
1819
|
/** Pending header/directory writes and source reads must also stop on explicit discard. */
|
|
1785
1820
|
async acceptance(operation) {
|
|
1786
1821
|
const signal = this.options.signal;
|
|
1787
|
-
const abort = () => this.lifetime.abort(signal?.reason
|
|
1822
|
+
const abort = () => this.lifetime.abort(signal?.reason);
|
|
1788
1823
|
signal?.addEventListener("abort", abort, { once: true });
|
|
1789
1824
|
try {
|
|
1790
1825
|
checkAbort(signal);
|
|
@@ -2736,12 +2771,13 @@ function sheetName(requested, names, policy, register = true) {
|
|
|
2736
2771
|
throw new TypeError("Sheet name must be a string.");
|
|
2737
2772
|
// Validate and deduplicate the decoded literal value, before ST_Xstring attribute encoding.
|
|
2738
2773
|
// A requested _xHHHH_ token is literal text; the serializer protects its leading underscore.
|
|
2739
|
-
let base = cleanXml(requested, policy).replace(/[\[\]:*?/\\]/g, "_").
|
|
2774
|
+
let base = cleanXml(requested, policy).replace(/[\[\]:*?/\\]/g, "_").replace(/^[\s']+|[\s']+$/g, "");
|
|
2775
|
+
// Clipping can expose an internal apostrophe or the reserved History name.
|
|
2776
|
+
base = clipName(base, 31).replace(/[\s']+$/g, "");
|
|
2740
2777
|
if (!base)
|
|
2741
2778
|
base = "Sheet";
|
|
2742
2779
|
if (base.toLowerCase() === "history")
|
|
2743
2780
|
base += "_";
|
|
2744
|
-
base = clipName(base, 31);
|
|
2745
2781
|
let name = base, suffix = 2;
|
|
2746
2782
|
while (names.has(name.toLowerCase())) {
|
|
2747
2783
|
const tail = " (" + suffix++ + ")";
|
|
@@ -5816,11 +5852,69 @@ const _exports = Object.freeze({ saveBlob: _m1.saveBlob, ExportCell: _m5.ExportC
|
|
|
5816
5852
|
return _exports;
|
|
5817
5853
|
})();
|
|
5818
5854
|
|
|
5855
|
+
const _m61 = (() => {
|
|
5856
|
+
/** @internal One type byte, an eight-byte offset/container number and a two-byte generation/index. */
|
|
5857
|
+
const pdfXrefEntryBytes = 11;
|
|
5858
|
+
function unsigned(bytes, offset, value, width) {
|
|
5859
|
+
if (!Number.isSafeInteger(value) || value < 0 || value >= 2 ** (width * 8))
|
|
5860
|
+
throw new RangeError("Invalid PDF cross-reference field.");
|
|
5861
|
+
// Bitwise shifts truncate to 32 bits. Arithmetic preserves every supported byte offset.
|
|
5862
|
+
for (let index = width - 1; index >= 0; index--) {
|
|
5863
|
+
bytes[offset + index] = value % 256;
|
|
5864
|
+
value = Math.floor(value / 256);
|
|
5865
|
+
}
|
|
5866
|
+
}
|
|
5867
|
+
/** @internal Stream a complete single-section xref, including its own ordinary-object entry.
|
|
5868
|
+
* A defined member index means that the location is an object-stream number rather than a byte offset. */
|
|
5869
|
+
function* pdfXrefChunks(locations, indices) {
|
|
5870
|
+
if (locations.length !== indices.length)
|
|
5871
|
+
throw new Error("PDF cross-reference locations must align.");
|
|
5872
|
+
const perChunk = Math.floor(32768 / pdfXrefEntryBytes);
|
|
5873
|
+
for (let first = 0; first < locations.length; first += perChunk) {
|
|
5874
|
+
const count = Math.min(perChunk, locations.length - first), bytes = new Uint8Array(count * pdfXrefEntryBytes);
|
|
5875
|
+
for (let index = 0; index < count; index++) {
|
|
5876
|
+
const id = first + index, position = index * pdfXrefEntryBytes, location = locations[id], member = indices.at(id);
|
|
5877
|
+
if (location === undefined)
|
|
5878
|
+
throw new Error("PDF contains unwritten objects.");
|
|
5879
|
+
bytes[position] = id === 0 ? 0 : member === undefined ? 1 : 2;
|
|
5880
|
+
unsigned(bytes, position + 1, location, 8);
|
|
5881
|
+
unsigned(bytes, position + 9, id === 0 ? 65535 : member ?? 0, 2);
|
|
5882
|
+
}
|
|
5883
|
+
yield bytes;
|
|
5884
|
+
}
|
|
5885
|
+
}
|
|
5886
|
+
const _exports = Object.freeze({ pdfXrefEntryBytes: pdfXrefEntryBytes, pdfXrefChunks: pdfXrefChunks });
|
|
5887
|
+
return _exports;
|
|
5888
|
+
})();
|
|
5889
|
+
|
|
5819
5890
|
const _m60 = (() => {
|
|
5820
5891
|
const { checkAbort, withAbort, pause, taskYieldDue } = _m4;
|
|
5821
5892
|
|
|
5822
5893
|
const { OfficeIMOError } = _m2;
|
|
5823
5894
|
|
|
5895
|
+
const { pdfXrefChunks, pdfXrefEntryBytes } = _m61;
|
|
5896
|
+
|
|
5897
|
+
const compactObjectCount = 256, compactObjectBytes = 32768;
|
|
5898
|
+
const compactIndexChunkEntries = 4096;
|
|
5899
|
+
/** Lazy Uint16 chunks store compact membership; untouched zero slots denote ordinary objects. */
|
|
5900
|
+
class PdfCompactIndices {
|
|
5901
|
+
count;
|
|
5902
|
+
chunks = [];
|
|
5903
|
+
constructor(count) {
|
|
5904
|
+
this.count = count;
|
|
5905
|
+
}
|
|
5906
|
+
get length() { return this.count; }
|
|
5907
|
+
reserve() { this.count++; }
|
|
5908
|
+
set(id, member) {
|
|
5909
|
+
const chunk = this.chunks[Math.floor(id / compactIndexChunkEntries)] ??= new Uint16Array(compactIndexChunkEntries);
|
|
5910
|
+
// The current batch cap permits indices 0..255; adding one preserves index 255 as 256.
|
|
5911
|
+
chunk[id % compactIndexChunkEntries] = member + 1;
|
|
5912
|
+
}
|
|
5913
|
+
at(id) {
|
|
5914
|
+
const encoded = this.chunks[Math.floor(id / compactIndexChunkEntries)]?.[id % compactIndexChunkEntries] ?? 0;
|
|
5915
|
+
return encoded ? encoded - 1 : undefined;
|
|
5916
|
+
}
|
|
5917
|
+
}
|
|
5824
5918
|
function pdfNumber(value) {
|
|
5825
5919
|
if (!Number.isFinite(value) || Math.abs(value) > 1e9)
|
|
5826
5920
|
throw new RangeError("PDF coordinates and metrics must be finite and bounded.");
|
|
@@ -5837,25 +5931,33 @@ function unicodeHex(text) {
|
|
|
5837
5931
|
}
|
|
5838
5932
|
return hex;
|
|
5839
5933
|
}
|
|
5840
|
-
/** @internal Forward-only PDF objects.
|
|
5934
|
+
/** @internal Forward-only PDF objects. Completed objects retain only their xref location. */
|
|
5841
5935
|
class PdfObjects {
|
|
5842
5936
|
sink;
|
|
5843
5937
|
signal;
|
|
5844
5938
|
maxBytes;
|
|
5939
|
+
compressObjects;
|
|
5845
5940
|
offsets = [0];
|
|
5941
|
+
// A defined index changes the corresponding full-width offset into an object-stream number.
|
|
5942
|
+
// Membership chunks are allocated only when a compact member needs their ID range.
|
|
5943
|
+
compactIndices;
|
|
5944
|
+
compactBatch;
|
|
5945
|
+
compactArena;
|
|
5946
|
+
compactUnavailable = false;
|
|
5846
5947
|
encoder = new TextEncoder();
|
|
5847
5948
|
buffer = new Uint8Array(32768);
|
|
5848
5949
|
buffered = 0;
|
|
5849
5950
|
bytes = 0;
|
|
5850
|
-
constructor(sink, signal, maxBytes = Number.MAX_SAFE_INTEGER) {
|
|
5951
|
+
constructor(sink, signal, maxBytes = Number.MAX_SAFE_INTEGER, compressObjects = false) {
|
|
5851
5952
|
this.sink = sink;
|
|
5852
5953
|
this.signal = signal;
|
|
5853
5954
|
this.maxBytes = maxBytes;
|
|
5955
|
+
this.compressObjects = compressObjects;
|
|
5854
5956
|
}
|
|
5855
|
-
reserve() { this.offsets.push(undefined); return this.offsets.length - 1; }
|
|
5957
|
+
reserve() { this.offsets.push(undefined); this.compactIndices?.reserve(); return this.offsets.length - 1; }
|
|
5856
5958
|
async raw(bytes) {
|
|
5857
5959
|
checkAbort(this.signal);
|
|
5858
|
-
if (this.bytes + bytes.length > this.maxBytes)
|
|
5960
|
+
if (!Number.isSafeInteger(this.bytes + bytes.length) || this.bytes + bytes.length > this.maxBytes)
|
|
5859
5961
|
throw new OfficeIMOError("RESOURCE_LIMIT", "maxOutputBytes exceeded.");
|
|
5860
5962
|
this.bytes += bytes.length;
|
|
5861
5963
|
for (let offset = 0; offset < bytes.length;) {
|
|
@@ -5864,21 +5966,139 @@ class PdfObjects {
|
|
|
5864
5966
|
offset += n;
|
|
5865
5967
|
this.buffered += n;
|
|
5866
5968
|
if (this.buffered === this.buffer.length)
|
|
5867
|
-
await this.
|
|
5969
|
+
await this.flushBytes();
|
|
5868
5970
|
}
|
|
5869
5971
|
}
|
|
5870
5972
|
async text(text) { await this.raw(this.encoder.encode(text)); }
|
|
5871
5973
|
async flush() {
|
|
5974
|
+
await this.flushCompact();
|
|
5975
|
+
await this.flushBytes();
|
|
5976
|
+
}
|
|
5977
|
+
/** Publish completed page bytes without forcing a partial structure container to end. */
|
|
5978
|
+
async flushBytes() {
|
|
5872
5979
|
if (this.buffered) {
|
|
5873
5980
|
const bytes = this.buffer.subarray(0, this.buffered);
|
|
5874
5981
|
await withAbort(Promise.resolve(this.sink.write(bytes)), this.signal);
|
|
5875
|
-
this
|
|
5982
|
+
// The sink borrows this view until acceptance; failed or cancelled writes must not reuse it.
|
|
5876
5983
|
this.buffered = 0;
|
|
5877
5984
|
}
|
|
5878
5985
|
if (taskYieldDue())
|
|
5879
5986
|
await pause();
|
|
5880
5987
|
checkAbort(this.signal);
|
|
5881
5988
|
}
|
|
5989
|
+
/** @internal Append only when an existing compact batch can accept a member without async work. */
|
|
5990
|
+
tryCompactObject(id, body) {
|
|
5991
|
+
checkAbort(this.signal);
|
|
5992
|
+
this.validateObject(id);
|
|
5993
|
+
const batch = this.compactBatch;
|
|
5994
|
+
if (!batch || !this.compressObjects || this.compactUnavailable || typeof CompressionStream !== "function" ||
|
|
5995
|
+
body.length > compactObjectBytes || batch.ids.length + 1 >= compactObjectCount)
|
|
5996
|
+
return false;
|
|
5997
|
+
const indexBytes = String(id).length + String(batch.bodyBytes).length + 2;
|
|
5998
|
+
const written = this.encodeCompactBody(body, batch.bodyBytes, compactObjectBytes - batch.indexBytes - indexBytes - batch.bodyBytes - 2);
|
|
5999
|
+
if (written === undefined)
|
|
6000
|
+
return false;
|
|
6001
|
+
this.storeCompactBody(batch, id, written);
|
|
6002
|
+
return true;
|
|
6003
|
+
}
|
|
6004
|
+
/** Small logical structure values share one bounded object-stream container. Other callers keep
|
|
6005
|
+
* ordinary objects; unavailable deflate preserves the classic representation before packing starts. */
|
|
6006
|
+
async compactObject(id, body) {
|
|
6007
|
+
checkAbort(this.signal);
|
|
6008
|
+
this.validateObject(id);
|
|
6009
|
+
if (!this.compressObjects || this.compactUnavailable || body.length > compactObjectBytes)
|
|
6010
|
+
return this.object(id, body);
|
|
6011
|
+
if (typeof CompressionStream !== "function") {
|
|
6012
|
+
if (this.compactIndices)
|
|
6013
|
+
throw new Error("PDF object compression became unavailable.");
|
|
6014
|
+
this.compactUnavailable = true;
|
|
6015
|
+
return this.object(id, body);
|
|
6016
|
+
}
|
|
6017
|
+
const firstIndexBytes = String(id).length + 4;
|
|
6018
|
+
let batch = this.compactBatch;
|
|
6019
|
+
const indexBytes = String(id).length + String(batch?.bodyBytes ?? 0).length + 2;
|
|
6020
|
+
let written = batch && batch.ids.length < compactObjectCount ? this.encodeCompactBody(body, batch.bodyBytes, compactObjectBytes - batch.indexBytes - indexBytes - batch.bodyBytes - 2) : undefined;
|
|
6021
|
+
if (batch && written === undefined) {
|
|
6022
|
+
// Partial encodings only touch the uncommitted suffix. Flush the committed prefix and retry
|
|
6023
|
+
// the whole string so a multibyte scalar is never split between containers.
|
|
6024
|
+
await this.flushCompact();
|
|
6025
|
+
batch = undefined;
|
|
6026
|
+
checkAbort(this.signal);
|
|
6027
|
+
}
|
|
6028
|
+
if (!batch) {
|
|
6029
|
+
written = this.encodeCompactBody(body, 0, compactObjectBytes - firstIndexBytes - 1);
|
|
6030
|
+
if (written === undefined)
|
|
6031
|
+
return this.object(id, body);
|
|
6032
|
+
let compressor;
|
|
6033
|
+
// Probe before selecting the compact representation. Later batches need no idle native
|
|
6034
|
+
// codec while they accumulate, including while ordinary page streams are compressed.
|
|
6035
|
+
if (!this.compactIndices) {
|
|
6036
|
+
try {
|
|
6037
|
+
compressor = new CompressionStream("deflate");
|
|
6038
|
+
}
|
|
6039
|
+
catch {
|
|
6040
|
+
this.compactUnavailable = true;
|
|
6041
|
+
return this.object(id, body);
|
|
6042
|
+
}
|
|
6043
|
+
}
|
|
6044
|
+
batch = { id: this.reserve(), compressor, ids: [], bodyOffsets: [], bodyBytes: 0, indexBytes: 1 };
|
|
6045
|
+
this.compactIndices ??= new PdfCompactIndices(this.offsets.length);
|
|
6046
|
+
this.compactBatch = batch;
|
|
6047
|
+
}
|
|
6048
|
+
this.storeCompactBody(batch, id, written);
|
|
6049
|
+
if (batch.ids.length === compactObjectCount)
|
|
6050
|
+
await this.flushCompact();
|
|
6051
|
+
}
|
|
6052
|
+
storeCompactBody(batch, id, written) {
|
|
6053
|
+
this.offsets[id] = batch.id;
|
|
6054
|
+
this.compactIndices.set(id, batch.ids.length);
|
|
6055
|
+
batch.indexBytes += String(id).length + String(batch.bodyBytes).length + 2;
|
|
6056
|
+
batch.ids.push(id);
|
|
6057
|
+
batch.bodyOffsets.push(batch.bodyBytes);
|
|
6058
|
+
this.compactArena[batch.bodyBytes + written] = 10;
|
|
6059
|
+
batch.bodyBytes += written + 1;
|
|
6060
|
+
}
|
|
6061
|
+
/** An incomplete encoding leaves only scratch bytes beyond the committed batch prefix. */
|
|
6062
|
+
encodeCompactBody(body, offset, available) {
|
|
6063
|
+
if (available < 0)
|
|
6064
|
+
return undefined;
|
|
6065
|
+
const destination = (this.compactArena ??= new Uint8Array(compactObjectBytes)).subarray(offset, offset + available);
|
|
6066
|
+
if (typeof this.encoder.encodeInto === "function") {
|
|
6067
|
+
const result = this.encoder.encodeInto(body, destination);
|
|
6068
|
+
return result.read === body.length ? result.written : undefined;
|
|
6069
|
+
}
|
|
6070
|
+
// Preserve TextEncoder implementations that only expose encode().
|
|
6071
|
+
const bytes = this.encoder.encode(body);
|
|
6072
|
+
if (bytes.length > available)
|
|
6073
|
+
return undefined;
|
|
6074
|
+
destination.set(bytes);
|
|
6075
|
+
return bytes.length;
|
|
6076
|
+
}
|
|
6077
|
+
async flushCompact() {
|
|
6078
|
+
const batch = this.compactBatch;
|
|
6079
|
+
if (!batch)
|
|
6080
|
+
return;
|
|
6081
|
+
this.compactBatch = undefined;
|
|
6082
|
+
let index = "";
|
|
6083
|
+
for (let member = 0; member < batch.ids.length; member++)
|
|
6084
|
+
index += batch.ids[member] + " " + batch.bodyOffsets[member] + " ";
|
|
6085
|
+
const header = this.encoder.encode(index + "\n"), count = batch.ids.length;
|
|
6086
|
+
// Keep the index separate from the arena. Reuse waits for the compressed read or all raw
|
|
6087
|
+
// writes below, so later members cannot overwrite a borrowed batch body.
|
|
6088
|
+
const body = this.compactArena.subarray(0, batch.bodyBytes);
|
|
6089
|
+
batch.ids.length = 0;
|
|
6090
|
+
batch.bodyOffsets.length = 0;
|
|
6091
|
+
if (batch.compressor) {
|
|
6092
|
+
await this.compressedStream(batch.id, body, "/Type /ObjStm /N " + count + " /First " + header.length, batch.compressor, header);
|
|
6093
|
+
}
|
|
6094
|
+
else {
|
|
6095
|
+
this.start(batch.id);
|
|
6096
|
+
await this.text(batch.id + " 0 obj\n<< /Length " + (header.length + body.length) + " /Type /ObjStm /N " + count + " /First " + header.length + " >>\nstream\n");
|
|
6097
|
+
await this.raw(header);
|
|
6098
|
+
await this.raw(body);
|
|
6099
|
+
await this.text("\nendstream\nendobj\n");
|
|
6100
|
+
}
|
|
6101
|
+
}
|
|
5882
6102
|
async object(id, body) {
|
|
5883
6103
|
this.start(id);
|
|
5884
6104
|
if (typeof body === "string") {
|
|
@@ -5902,9 +6122,12 @@ class PdfObjects {
|
|
|
5902
6122
|
}
|
|
5903
6123
|
await this.text(chunk + "\nendobj\n");
|
|
5904
6124
|
}
|
|
5905
|
-
|
|
5906
|
-
if (!Number.
|
|
6125
|
+
validateObject(id) {
|
|
6126
|
+
if (!Number.isSafeInteger(id) || id <= 0 || id >= this.offsets.length || this.offsets[id] !== undefined)
|
|
5907
6127
|
throw new Error("Invalid PDF object state.");
|
|
6128
|
+
}
|
|
6129
|
+
start(id) {
|
|
6130
|
+
this.validateObject(id);
|
|
5908
6131
|
this.offsets[id] = this.bytes;
|
|
5909
6132
|
}
|
|
5910
6133
|
async stream(id, source, dictionary = "", compression = true, owned = false) {
|
|
@@ -5925,7 +6148,15 @@ class PdfObjects {
|
|
|
5925
6148
|
}
|
|
5926
6149
|
// Verified internal producers can transfer immutable ownership; other byte sources retain the defensive snapshot.
|
|
5927
6150
|
const sourceBytes = typeof source === "string" || owned ? bytes : new Uint8Array(bytes);
|
|
5928
|
-
|
|
6151
|
+
await this.compressedStream(id, sourceBytes, dictionary, compressor);
|
|
6152
|
+
}
|
|
6153
|
+
async compressedStream(id, sourceBytes, dictionary, compressor, prefix) {
|
|
6154
|
+
const input = new ReadableStream({ start(controller) {
|
|
6155
|
+
if (prefix)
|
|
6156
|
+
controller.enqueue(prefix);
|
|
6157
|
+
controller.enqueue(sourceBytes);
|
|
6158
|
+
controller.close();
|
|
6159
|
+
} });
|
|
5929
6160
|
const reader = input.pipeThrough(compressor).getReader(), lengthId = this.reserve();
|
|
5930
6161
|
let length = 0, complete = false;
|
|
5931
6162
|
try {
|
|
@@ -5950,10 +6181,14 @@ class PdfObjects {
|
|
|
5950
6181
|
}
|
|
5951
6182
|
}
|
|
5952
6183
|
async finish(root, info) {
|
|
5953
|
-
|
|
5954
|
-
|
|
6184
|
+
await this.flushCompact();
|
|
6185
|
+
for (let id = 1; id < this.offsets.length; id++)
|
|
6186
|
+
if (this.offsets[id] === undefined)
|
|
6187
|
+
throw new Error("PDF contains unwritten objects.");
|
|
5955
6188
|
if (this.bytes > 9999999999)
|
|
5956
6189
|
throw new OfficeIMOError("RESOURCE_LIMIT", "PDF exceeds classic cross-reference offset capacity.");
|
|
6190
|
+
if (this.compactIndices)
|
|
6191
|
+
return this.finishCompact(root, info);
|
|
5957
6192
|
const start = this.bytes;
|
|
5958
6193
|
await this.text("xref\n0 " + this.offsets.length + "\n0000000000 65535 f \n");
|
|
5959
6194
|
for (let i = 1; i < this.offsets.length; i++)
|
|
@@ -5961,12 +6196,26 @@ class PdfObjects {
|
|
|
5961
6196
|
await this.text("trailer\n<< /Size " + this.offsets.length + " /Root " + root + " 0 R /Info " + info + " 0 R >>\nstartxref\n" + start + "\n%%EOF\n");
|
|
5962
6197
|
await this.flush();
|
|
5963
6198
|
}
|
|
6199
|
+
/** Xref payloads have a known length and are emitted in bounded chunks, without another copy
|
|
6200
|
+
* of the document's random-access location arrays or a whole-xref compression buffer. */
|
|
6201
|
+
async finishCompact(root, info) {
|
|
6202
|
+
const id = this.reserve(), start = this.bytes, length = this.offsets.length * pdfXrefEntryBytes;
|
|
6203
|
+
if (!Number.isSafeInteger(length))
|
|
6204
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "PDF cross-reference stream is too large.");
|
|
6205
|
+
this.start(id);
|
|
6206
|
+
await this.text(id + " 0 obj\n<< /Type /XRef /Size " + this.offsets.length + " /W [1 8 2] /Root " + root + " 0 R /Info " + info +
|
|
6207
|
+
" 0 R /Length " + length + " >>\nstream\n");
|
|
6208
|
+
for (const chunk of pdfXrefChunks(this.offsets, this.compactIndices))
|
|
6209
|
+
await this.raw(chunk);
|
|
6210
|
+
await this.text("\nendstream\nendobj\nstartxref\n" + start + "\n%%EOF\n");
|
|
6211
|
+
await this.flushBytes();
|
|
6212
|
+
}
|
|
5964
6213
|
}
|
|
5965
6214
|
const _exports = Object.freeze({ pdfNumber: pdfNumber, unicodeHex: unicodeHex, PdfObjects: PdfObjects });
|
|
5966
6215
|
return _exports;
|
|
5967
6216
|
})();
|
|
5968
6217
|
|
|
5969
|
-
const
|
|
6218
|
+
const _m65 = (() => {
|
|
5970
6219
|
/** @internal Bounded big-endian reader used for caller-provided TrueType programs. */
|
|
5971
6220
|
class FontReader {
|
|
5972
6221
|
bytes;
|
|
@@ -5995,8 +6244,8 @@ const _exports = Object.freeze({ FontReader: FontReader, checksum: checksum, ali
|
|
|
5995
6244
|
return _exports;
|
|
5996
6245
|
})();
|
|
5997
6246
|
|
|
5998
|
-
const
|
|
5999
|
-
const { align4 } =
|
|
6247
|
+
const _m66 = (() => {
|
|
6248
|
+
const { align4 } = _m65;
|
|
6000
6249
|
|
|
6001
6250
|
const { checkAbort, pause, taskYieldDue } = _m4;
|
|
6002
6251
|
|
|
@@ -6219,12 +6468,12 @@ const _exports = Object.freeze({ subsetTrueType: subsetTrueType, subsetTrueTypeC
|
|
|
6219
6468
|
return _exports;
|
|
6220
6469
|
})();
|
|
6221
6470
|
|
|
6222
|
-
const
|
|
6471
|
+
const _m64 = (() => {
|
|
6223
6472
|
const { NotSupportedError } = _m2;
|
|
6224
6473
|
|
|
6225
|
-
const { FontReader } =
|
|
6474
|
+
const { FontReader } = _m65;
|
|
6226
6475
|
|
|
6227
|
-
const { subsetTrueType, subsetTrueTypeCooperatively } =
|
|
6476
|
+
const { subsetTrueType, subsetTrueTypeCooperatively } = _m66;
|
|
6228
6477
|
|
|
6229
6478
|
const { checkAbort, pause, taskYieldDue } = _m4;
|
|
6230
6479
|
|
|
@@ -6463,8 +6712,8 @@ const _exports = Object.freeze({ TrueTypeFont: TrueTypeFont });
|
|
|
6463
6712
|
return _exports;
|
|
6464
6713
|
})();
|
|
6465
6714
|
|
|
6466
|
-
const
|
|
6467
|
-
const { TrueTypeFont } =
|
|
6715
|
+
const _m63 = (() => {
|
|
6716
|
+
const { TrueTypeFont } = _m64;
|
|
6468
6717
|
|
|
6469
6718
|
const { beginTask, checkAbort } = _m4;
|
|
6470
6719
|
|
|
@@ -6526,7 +6775,7 @@ const _exports = Object.freeze({ fontProgram: fontProgram, PdfFont: PdfFont });
|
|
|
6526
6775
|
return _exports;
|
|
6527
6776
|
})();
|
|
6528
6777
|
|
|
6529
|
-
const
|
|
6778
|
+
const _m68 = (() => {
|
|
6530
6779
|
// Generated by scripts/pdf-widths.mjs from OfficeIMO.Pdf's Adobe AFM-derived metrics.
|
|
6531
6780
|
const helveticaWidths = new Map([
|
|
6532
6781
|
[32, [278, 278]],
|
|
@@ -6848,12 +7097,12 @@ const _exports = Object.freeze({ helveticaWidths: helveticaWidths });
|
|
|
6848
7097
|
return _exports;
|
|
6849
7098
|
})();
|
|
6850
7099
|
|
|
6851
|
-
const
|
|
7100
|
+
const _m67 = (() => {
|
|
6852
7101
|
const { OfficeIMOError } = _m2;
|
|
6853
7102
|
|
|
6854
|
-
const { PdfFont, fontProgram } =
|
|
7103
|
+
const { PdfFont, fontProgram } = _m63;
|
|
6855
7104
|
|
|
6856
|
-
const { helveticaWidths } =
|
|
7105
|
+
const { helveticaWidths } = _m68;
|
|
6857
7106
|
|
|
6858
7107
|
const winAnsiExtras = new Map([0x20ac, 0, 0x201a, 0x192, 0x201e, 0x2026, 0x2020, 0x2021, 0x2c6, 0x2030, 0x160, 0x2039, 0x152, 0, 0x17d, 0, 0, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x2dc, 0x2122, 0x161, 0x203a, 0x153, 0, 0x17e, 0x178].map((cp, i) => [cp, i + 128]));
|
|
6859
7108
|
/** @internal Called after scalar support succeeds when encoding a standard-font run. */
|
|
@@ -6916,17 +7165,18 @@ const _exports = Object.freeze({ standardCode: standardCode, resolveScalar: reso
|
|
|
6916
7165
|
return _exports;
|
|
6917
7166
|
})();
|
|
6918
7167
|
|
|
6919
|
-
const
|
|
7168
|
+
const _m62 = (() => {
|
|
6920
7169
|
const { NotSupportedError, OfficeIMOError } = _m2;
|
|
6921
7170
|
|
|
6922
|
-
const { fontProgram } =
|
|
7171
|
+
const { fontProgram } = _m63;
|
|
6923
7172
|
|
|
6924
|
-
const { resolveScalar, selectFont, standardCode, validateFonts } =
|
|
7173
|
+
const { resolveScalar, selectFont, standardCode, validateFonts } = _m67;
|
|
6925
7174
|
|
|
6926
7175
|
const { pdfNumber, unicodeHex } = _m60;
|
|
6927
7176
|
|
|
6928
7177
|
const { checkAbort, pause, taskYieldDue } = _m4;
|
|
6929
7178
|
|
|
7179
|
+
const standardHexBytes = Object.freeze(Array.from({ length: 256 }, (_, byte) => byte.toString(16).padStart(2, "0")));
|
|
6930
7180
|
class PdfFontResource {
|
|
6931
7181
|
index;
|
|
6932
7182
|
bold;
|
|
@@ -6989,7 +7239,7 @@ class PdfFontResource {
|
|
|
6989
7239
|
for (const char of text) {
|
|
6990
7240
|
const cp = char.codePointAt(0);
|
|
6991
7241
|
this.width(cp);
|
|
6992
|
-
hex +=
|
|
7242
|
+
hex += this.program ? this.mappings.get(cp).cid.toString(16).padStart(4, "0") : standardHexBytes[standardCode(cp)];
|
|
6993
7243
|
}
|
|
6994
7244
|
return "<" + hex + ">";
|
|
6995
7245
|
}
|
|
@@ -7127,7 +7377,7 @@ const _exports = Object.freeze({ PdfFontResource: PdfFontResource, PdfFontResour
|
|
|
7127
7377
|
return _exports;
|
|
7128
7378
|
})();
|
|
7129
7379
|
|
|
7130
|
-
const
|
|
7380
|
+
const _m70 = (() => {
|
|
7131
7381
|
const { OfficeIMOError } = _m2;
|
|
7132
7382
|
|
|
7133
7383
|
const { ExportCell, assertExportValue } = _m5;
|
|
@@ -7138,6 +7388,11 @@ const { isDate } = _m6;
|
|
|
7138
7388
|
|
|
7139
7389
|
const { defaultBooleanText } = _m21;
|
|
7140
7390
|
|
|
7391
|
+
/** @internal Charge displayed characters: tabs paint four spaces, while CR/LF only separate lines.
|
|
7392
|
+
* Raw text remains authoritative for input limits and layout. Skip normalization when no text ceiling observes it. */
|
|
7393
|
+
function pdfBudgetText(text, budget) {
|
|
7394
|
+
return budget.limits.maxTextCharacters === undefined ? text : text.replace(/[\t\r\n]/g, character => character === "\t" ? " " : "");
|
|
7395
|
+
}
|
|
7141
7396
|
function synchronousText(value, name) {
|
|
7142
7397
|
if (typeof value === "string")
|
|
7143
7398
|
return value;
|
|
@@ -7229,11 +7484,11 @@ function* wrapSteps(text, font, size, width, maxCharacters, maxLines, wrap) {
|
|
|
7229
7484
|
}
|
|
7230
7485
|
return lines;
|
|
7231
7486
|
}
|
|
7232
|
-
const _exports = Object.freeze({ synchronousText: synchronousText, displayText: displayText, wrapText: wrapText, wrapTextCooperatively: wrapTextCooperatively });
|
|
7487
|
+
const _exports = Object.freeze({ pdfBudgetText: pdfBudgetText, synchronousText: synchronousText, displayText: displayText, wrapText: wrapText, wrapTextCooperatively: wrapTextCooperatively });
|
|
7233
7488
|
return _exports;
|
|
7234
7489
|
})();
|
|
7235
7490
|
|
|
7236
|
-
const
|
|
7491
|
+
const _m72 = (() => {
|
|
7237
7492
|
const { NotSupportedError, OfficeIMOError } = _m2;
|
|
7238
7493
|
|
|
7239
7494
|
const { checkAbort, pause, taskYieldDue, withAbort } = _m4;
|
|
@@ -7445,7 +7700,7 @@ const _exports = Object.freeze({ wrapShapedPdfText: wrapShapedPdfText });
|
|
|
7445
7700
|
return _exports;
|
|
7446
7701
|
})();
|
|
7447
7702
|
|
|
7448
|
-
const
|
|
7703
|
+
const _m71 = (() => {
|
|
7449
7704
|
const { NotSupportedError, OfficeIMOError } = _m2;
|
|
7450
7705
|
|
|
7451
7706
|
const { copyExportLink } = _m7;
|
|
@@ -7454,21 +7709,30 @@ const { checkAbort, pause, taskYieldDue } = _m4;
|
|
|
7454
7709
|
|
|
7455
7710
|
const { presentation, color } = _m17;
|
|
7456
7711
|
|
|
7457
|
-
const { wrapShapedPdfText } =
|
|
7712
|
+
const { wrapShapedPdfText } = _m72;
|
|
7713
|
+
|
|
7714
|
+
const { PdfFont } = _m63;
|
|
7458
7715
|
|
|
7459
|
-
const {
|
|
7716
|
+
const { pdfBudgetText } = _m70;
|
|
7460
7717
|
|
|
7461
|
-
/** @internal A run list is a PDF presentation value, never an alternate shared table value model. */
|
|
7462
|
-
function capturePdfText(value, base, settings, fonts, countEmpty = true) {
|
|
7463
|
-
|
|
7718
|
+
/** @internal Callers supply an owned, validated, frozen base presentation. A run list is a PDF presentation value, never an alternate shared table value model. */
|
|
7719
|
+
function capturePdfText(value, base, settings, fonts, countEmpty = true, reserveBudget = true) {
|
|
7720
|
+
if (typeof value === "string") {
|
|
7721
|
+
if (value.length > settings.limits.maxCellCharacters)
|
|
7722
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "maxCellCharacters exceeded.");
|
|
7723
|
+
if (reserveBudget && (value.length || countEmpty))
|
|
7724
|
+
settings.budget.reserve(1, pdfBudgetText(value, settings.budget).length);
|
|
7725
|
+
return Object.freeze({ text: value, runs: Object.freeze([Object.freeze({ text: value, style: base })]) });
|
|
7726
|
+
}
|
|
7727
|
+
const input = value;
|
|
7464
7728
|
if (!Array.isArray(input)) {
|
|
7465
7729
|
if (input && typeof input.then === "function")
|
|
7466
7730
|
void Promise.resolve(input).catch(() => { });
|
|
7467
7731
|
throw new TypeError("PDF text must be a string or a synchronous array of text runs.");
|
|
7468
7732
|
}
|
|
7469
|
-
if (
|
|
7733
|
+
if (input.length > settings.limits.maxTextRuns)
|
|
7470
7734
|
throw new OfficeIMOError("RESOURCE_LIMIT", "maxTextRuns exceeded.");
|
|
7471
|
-
let characters = 0;
|
|
7735
|
+
let characters = 0, budgetCharacters = 0;
|
|
7472
7736
|
const runs = [];
|
|
7473
7737
|
for (const run of input) {
|
|
7474
7738
|
if (!run || typeof run !== "object" || Object.keys(run).some(key => !["text", "bold", "italic", "color", "link", "font"].includes(key)))
|
|
@@ -7484,14 +7748,16 @@ function capturePdfText(value, base, settings, fonts, countEmpty = true) {
|
|
|
7484
7748
|
characters += text.length;
|
|
7485
7749
|
if (characters > settings.limits.maxCellCharacters)
|
|
7486
7750
|
throw new OfficeIMOError("RESOURCE_LIMIT", "maxCellCharacters exceeded.");
|
|
7751
|
+
if (reserveBudget)
|
|
7752
|
+
budgetCharacters += pdfBudgetText(text, settings.budget).length;
|
|
7487
7753
|
const style = presentation({ ...base, ...(bold === undefined ? {} : { bold }), ...(italic === undefined ? {} : { italic }), ...(color === undefined ? {} : { color }) });
|
|
7488
7754
|
if (settings.options.tagged && link !== undefined && text.length && !text.trim())
|
|
7489
7755
|
throw new TypeError("Tagged PDF inline links require nonempty displayed text.");
|
|
7490
7756
|
runs.push(Object.freeze({ text, style, ...(font === undefined ? {} : { font }), ...(link === undefined ? {} : { link: copyExportLink(link) }) }));
|
|
7491
7757
|
}
|
|
7492
7758
|
// Reserve before allocating a joined rich-text value or retaining it in a kept paragraph chain.
|
|
7493
|
-
if (characters || countEmpty)
|
|
7494
|
-
settings.budget.reserve(1,
|
|
7759
|
+
if (reserveBudget && (characters || countEmpty))
|
|
7760
|
+
settings.budget.reserve(1, budgetCharacters);
|
|
7495
7761
|
return Object.freeze({ text: runs.map(run => run.text).join(""), runs: Object.freeze(runs) });
|
|
7496
7762
|
}
|
|
7497
7763
|
/** @internal Greedy wrapping over the continuous text stream, preserving run emphasis and URI geometry. */
|
|
@@ -7500,8 +7766,39 @@ async function wrapPdfText(captured, fonts, size, width, settings, wrap = true)
|
|
|
7500
7766
|
return wrapShapedPdfText(captured, fonts, size, width, settings, wrap);
|
|
7501
7767
|
const { signal } = settings.options, { text, runs } = captured;
|
|
7502
7768
|
checkAbort(signal);
|
|
7503
|
-
|
|
7504
|
-
const
|
|
7769
|
+
// Keep font-selection order while deferring a single-run face array until wrapping needs it.
|
|
7770
|
+
const single = runs.length === 1 ? runs[0] : undefined;
|
|
7771
|
+
const singleFace = single && fonts.select(single.style.bold, single.style.italic, single.font);
|
|
7772
|
+
const selectedFaces = singleFace ? undefined : runs.map(run => fonts.select(run.style.bold, run.style.italic, run.font));
|
|
7773
|
+
const fallback = fonts.select();
|
|
7774
|
+
// Short fitting runs need no per-character layout arrays. Longer text keeps the existing
|
|
7775
|
+
// cooperative checkpoints; controls or the first overflowing advance use the general path.
|
|
7776
|
+
if (single && text.length > 0 && text.length < 4096) {
|
|
7777
|
+
const run = single, font = singleFace;
|
|
7778
|
+
let widthSoFar = 0, fits = true;
|
|
7779
|
+
for (let offset = 0; offset < text.length;) {
|
|
7780
|
+
const scalar = text.codePointAt(offset);
|
|
7781
|
+
if (scalar === 9 || scalar === 10 || scalar === 13) {
|
|
7782
|
+
fits = false;
|
|
7783
|
+
break;
|
|
7784
|
+
}
|
|
7785
|
+
const advance = font.width(scalar) * size / 1000;
|
|
7786
|
+
if (advance > width + .001 || widthSoFar + advance > width + .001) {
|
|
7787
|
+
fits = false;
|
|
7788
|
+
break;
|
|
7789
|
+
}
|
|
7790
|
+
widthSoFar += advance;
|
|
7791
|
+
offset += scalar > 0xffff ? 2 : 1;
|
|
7792
|
+
}
|
|
7793
|
+
if (fits) {
|
|
7794
|
+
if (settings.limits.maxRowLines < 1)
|
|
7795
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "maxRowLines exceeded.");
|
|
7796
|
+
return [{ text, width: widthSoFar, segments: [{ text, width: widthSoFar, font,
|
|
7797
|
+
...(run.style.color === undefined ? {} : { color: run.style.color }), ...(run.link ? { link: run.link } : {}) }],
|
|
7798
|
+
lineHeight: font.lineHeight(size), ascent: Math.max(0, (font.program?.ascent ?? 800) * size / 1000) }];
|
|
7799
|
+
}
|
|
7800
|
+
}
|
|
7801
|
+
const faces = selectedFaces ?? [singleFace], lines = [];
|
|
7505
7802
|
let chars = [], advances = [], owners = [], measured = 0, breakAt = -1;
|
|
7506
7803
|
let runIndex = 0, runEnd = runs[0]?.text.length ?? 0, scanned = 0;
|
|
7507
7804
|
const emit = (count) => {
|
|
@@ -7598,19 +7895,17 @@ const _exports = Object.freeze({ capturePdfText: capturePdfText, wrapPdfText: wr
|
|
|
7598
7895
|
return _exports;
|
|
7599
7896
|
})();
|
|
7600
7897
|
|
|
7601
|
-
const
|
|
7898
|
+
const _m73 = (() => {
|
|
7602
7899
|
const { OfficeIMOError } = _m2;
|
|
7603
7900
|
|
|
7604
|
-
const { wrapPdfText } =
|
|
7901
|
+
const { wrapPdfText } = _m71;
|
|
7605
7902
|
|
|
7606
7903
|
/** Plan without opening a source. Exact column widths never shrink in band mode. */
|
|
7607
7904
|
function planTableBands(widths, settings) {
|
|
7608
7905
|
const policy = settings.options.wideTable;
|
|
7609
7906
|
if (typeof policy !== "object")
|
|
7610
7907
|
return undefined;
|
|
7611
|
-
const available = settings.page.width - settings.margins.left - settings.margins.right, repeats =
|
|
7612
|
-
if (repeats.some(index => index >= widths.length))
|
|
7613
|
-
throw new RangeError("repeatColumns index exceeds the declared columns.");
|
|
7908
|
+
const available = settings.page.width - settings.margins.left - settings.margins.right, repeats = settings.repeatedColumns;
|
|
7614
7909
|
const repeated = new Set(repeats), rest = widths.map((_, index) => index).filter(index => !repeated.has(index));
|
|
7615
7910
|
const prefix = repeats.reduce((sum, index) => sum + widths[index], 0);
|
|
7616
7911
|
if (prefix > available + .001)
|
|
@@ -7690,7 +7985,7 @@ const _exports = Object.freeze({ planTableBands: planTableBands, projectBandRows
|
|
|
7690
7985
|
return _exports;
|
|
7691
7986
|
})();
|
|
7692
7987
|
|
|
7693
|
-
const
|
|
7988
|
+
const _m69 = (() => {
|
|
7694
7989
|
const { ExportCell } = _m5;
|
|
7695
7990
|
|
|
7696
7991
|
const { copyExportLink } = _m7;
|
|
@@ -7701,11 +7996,11 @@ const { createTotals } = _m12;
|
|
|
7701
7996
|
|
|
7702
7997
|
const { presentation, positive } = _m17;
|
|
7703
7998
|
|
|
7704
|
-
const { displayText } =
|
|
7999
|
+
const { displayText, pdfBudgetText } = _m70;
|
|
7705
8000
|
|
|
7706
|
-
const { capturePdfText, wrapPdfText } =
|
|
8001
|
+
const { capturePdfText, wrapPdfText } = _m71;
|
|
7707
8002
|
|
|
7708
|
-
const { planTableBands, projectBandRows, alignBandBlocks } =
|
|
8003
|
+
const { planTableBands, projectBandRows, alignBandBlocks } = _m73;
|
|
7709
8004
|
|
|
7710
8005
|
class PdfTableLayout {
|
|
7711
8006
|
settings;
|
|
@@ -7718,11 +8013,13 @@ class PdfTableLayout {
|
|
|
7718
8013
|
totals;
|
|
7719
8014
|
repeatedColumns;
|
|
7720
8015
|
structuredBandRows = new WeakMap();
|
|
8016
|
+
/** Plain/alternate ordinary-data defaults, validated only when a column first needs them. */
|
|
8017
|
+
dataPresentations = [];
|
|
7721
8018
|
constructor(settings, fonts) {
|
|
7722
8019
|
this.settings = settings;
|
|
7723
8020
|
this.fonts = fonts;
|
|
7724
8021
|
const { options, padding, fontSize, page, margins } = settings, columns = options.columns, available = page.width - margins.left - margins.right;
|
|
7725
|
-
this.repeatedColumns = new Set(
|
|
8022
|
+
this.repeatedColumns = new Set(settings.repeatedColumns);
|
|
7726
8023
|
let digit;
|
|
7727
8024
|
if (options.columnWidths && options.columnWidths.length !== columns.length)
|
|
7728
8025
|
throw new RangeError("columnWidths must declare one point width per column.");
|
|
@@ -7763,13 +8060,22 @@ class PdfTableLayout {
|
|
|
7763
8060
|
this.headings = headings;
|
|
7764
8061
|
this.totals = createTotals(columns, options.footer?.totals);
|
|
7765
8062
|
}
|
|
7766
|
-
async cell(value, first, span, row, style) {
|
|
8063
|
+
async cell(value, first, span, row, style, ordinaryData = false) {
|
|
7767
8064
|
const { options, padding, fontSize, budget } = this.settings, column = options.columns[first];
|
|
7768
8065
|
const own = value instanceof ExportCell ? value.presentation : undefined;
|
|
7769
8066
|
const link = value instanceof ExportCell && value.link ? copyExportLink(value.link) : undefined;
|
|
7770
|
-
const
|
|
7771
|
-
|
|
7772
|
-
|
|
8067
|
+
const alternate = ordinaryData && row % 2 && options.alternateRowColor ? options.alternateRowColor : undefined;
|
|
8068
|
+
const slot = first * 2 + (alternate ? 1 : 0), reusable = ordinaryData && own === undefined;
|
|
8069
|
+
let combined = reusable ? this.dataPresentations[slot] : undefined;
|
|
8070
|
+
if (!combined) {
|
|
8071
|
+
const rowStyle = ordinaryData ? alternate ? { background: alternate } : {} : style;
|
|
8072
|
+
combined = presentation({ ...(column.alignment === undefined ? {} : { alignment: column.alignment }),
|
|
8073
|
+
...(column.wrapText === undefined ? {} : { wrapText: column.wrapText }), ...rowStyle, ...own });
|
|
8074
|
+
// Validate only the first reached default; an authored cell may override invalid column defaults.
|
|
8075
|
+
if (reusable)
|
|
8076
|
+
this.dataPresentations[slot] = combined;
|
|
8077
|
+
}
|
|
8078
|
+
const font = this.fonts.select(combined.bold, combined.italic), width = span === 1 ? this.widths[first] : this.widths.slice(first, first + span).reduce((n, w) => n + w, 0);
|
|
7773
8079
|
const context = { rowIndex: row, columnIndex: first, column }, raw = value instanceof ExportCell ? value.value : value;
|
|
7774
8080
|
let text;
|
|
7775
8081
|
if (options.formatRuns && row >= 0 && !(value instanceof ExportCell && value.text !== undefined)) {
|
|
@@ -7788,10 +8094,11 @@ class PdfTableLayout {
|
|
|
7788
8094
|
throw new TypeError("Tagged PDF cell links require nonempty displayed text.");
|
|
7789
8095
|
if (link && captured.runs.some(run => run.link))
|
|
7790
8096
|
throw new TypeError("A PDF cell link cannot be combined with inline run links.");
|
|
8097
|
+
const budgetText = pdfBudgetText(captured.text, budget);
|
|
7791
8098
|
if (this.bands)
|
|
7792
|
-
budget.release(1,
|
|
8099
|
+
budget.release(1, budgetText.length);
|
|
7793
8100
|
else
|
|
7794
|
-
budget.cell(
|
|
8101
|
+
budget.cell(budgetText, budgetText.length);
|
|
7795
8102
|
const lines = await wrapPdfText(captured, this.fonts, fontSize, width - padding * 2, this.settings, combined.wrapText !== false);
|
|
7796
8103
|
return { first, span, width, font, style: combined, lineHeight: lines.reduce((height, line) => Math.max(height, line.lineHeight), font.lineHeight(fontSize)),
|
|
7797
8104
|
...(link ? { link } : {}), ...(this.bands ? { captured } : {}),
|
|
@@ -7890,8 +8197,8 @@ class PdfTableLayout {
|
|
|
7890
8197
|
const value = values[column], raw = value instanceof ExportCell ? value.value : value;
|
|
7891
8198
|
if (!footer)
|
|
7892
8199
|
this.totals[column].accept(raw);
|
|
7893
|
-
const
|
|
7894
|
-
cells.push(
|
|
8200
|
+
const cell = await this.cell(value, column, 1, index, footer ? options.footerPresentation ?? {} : undefined, !footer);
|
|
8201
|
+
cells.push(!footer && options.columns[column].rowHeader ? { ...cell, rowHeader: true } : cell);
|
|
7895
8202
|
}
|
|
7896
8203
|
return this.row(cells);
|
|
7897
8204
|
}
|
|
@@ -7908,7 +8215,7 @@ const _exports = Object.freeze({ PdfTableLayout: PdfTableLayout });
|
|
|
7908
8215
|
return _exports;
|
|
7909
8216
|
})();
|
|
7910
8217
|
|
|
7911
|
-
const
|
|
8218
|
+
const _m75 = (() => {
|
|
7912
8219
|
const { OfficeIMOError } = _m2;
|
|
7913
8220
|
|
|
7914
8221
|
const { checkAbort } = _m4;
|
|
@@ -7952,7 +8259,7 @@ class PdfTableBandFlow {
|
|
|
7952
8259
|
await this.flush();
|
|
7953
8260
|
}
|
|
7954
8261
|
async row(row, allowFirstFragment = false) {
|
|
7955
|
-
const { padding, options } = this.layout.settings, minimumLines = this.layout.minimumRowLines(row), minimumHeight = this.layout.minimumRowHeight(row);
|
|
8262
|
+
const { padding, fontSize, options } = this.layout.settings, minimumLines = this.layout.minimumRowLines(row), minimumHeight = this.layout.minimumRowHeight(row);
|
|
7956
8263
|
if (minimumHeight > this.painter.firstFullCapacity + .001 || minimumHeight > this.painter.continuationCapacity + .001)
|
|
7957
8264
|
throw new RangeError("Repeated PDF identifiers must fit intact below the first and continued band headings/context.");
|
|
7958
8265
|
// Keep ordinary rows intact when they fit fresh. A kept heading/caption can deliberately
|
|
@@ -7978,16 +8285,29 @@ class PdfTableBandFlow {
|
|
|
7978
8285
|
const lines = Math.min(row.lines - first, Math.floor((this.capacity - this.height - padding * 2 + .001) / row.lineHeight));
|
|
7979
8286
|
if (lines < 1)
|
|
7980
8287
|
throw new RangeError("PDF page cannot fit a table line below horizontal band headings.");
|
|
7981
|
-
|
|
8288
|
+
// Reserve one shared logical fragment, but paint only each band's visible cell geometry.
|
|
8289
|
+
const reservedLines = Math.max(lines, minimumLines), height = reservedLines * row.lineHeight + padding * 2;
|
|
7982
8290
|
const projected = await this.layout.bandRows([row]);
|
|
7983
|
-
const
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
8291
|
+
const exhaustedBands = [];
|
|
8292
|
+
const fragments = projected.map((rows, index) => {
|
|
8293
|
+
let remaining = false;
|
|
8294
|
+
const cells = rows[0].cells.map(cell => {
|
|
8295
|
+
const source = this.layout.bands[index].columns[cell.first];
|
|
8296
|
+
const repeated = this.layout.repeatedColumn(source), visible = repeated ? cell.lines : cell.lines.slice(first, first + lines);
|
|
8297
|
+
if (!repeated && (visible.length > 0 || cell.link !== undefined))
|
|
8298
|
+
remaining = true;
|
|
8299
|
+
const { height: _height, ...plain } = cell;
|
|
8300
|
+
return { ...plain, lines: visible,
|
|
8301
|
+
lineHeight: visible.reduce((value, line) => Math.max(value, line.lineHeight), cell.font.lineHeight(fontSize)),
|
|
8302
|
+
...(first > 0 && repeated ? { semanticArtifact: true } : {}) };
|
|
8303
|
+
});
|
|
8304
|
+
const fragmentLines = Math.max(1, ...cells.map(cell => cell.lines.length));
|
|
8305
|
+
const lineHeight = Math.max(this.layout.lineHeight, ...cells.filter(cell => cell.lines.length > 0).map(cell => cell.lineHeight));
|
|
8306
|
+
// Never omit an initial/new row, a structured block, or a nonrepeated link obligation.
|
|
8307
|
+
exhaustedBands.push(first > 0 && !remaining);
|
|
8308
|
+
return [{ ...rows[0], cells, lines: fragmentLines, lineHeight, height: fragmentLines * lineHeight + padding * 2 }];
|
|
8309
|
+
});
|
|
8310
|
+
await this.accept({ rows: fragments, height, count: 1, completed: first + lines >= row.lines ? [row] : [], exhaustedBands });
|
|
7991
8311
|
first += lines;
|
|
7992
8312
|
if (first < row.lines)
|
|
7993
8313
|
await this.flush();
|
|
@@ -7999,7 +8319,7 @@ class PdfTableBandFlow {
|
|
|
7999
8319
|
throw new OfficeIMOError("RESOURCE_LIMIT", "A structured PDF block exceeds maxTableWindowRows.");
|
|
8000
8320
|
for (const row of rows)
|
|
8001
8321
|
await this.painter.prepareRow?.(row);
|
|
8002
|
-
await this.accept({ rows: projected, height, count: rows.length, completed: rows });
|
|
8322
|
+
await this.accept({ rows: projected, height, count: rows.length, completed: rows, exhaustedBands: projected.map(() => false) });
|
|
8003
8323
|
}
|
|
8004
8324
|
async keptRows(rows, allowFirstFragment = false) {
|
|
8005
8325
|
const height = rows.reduce((sum, row) => sum + row.height, 0), fits = height <= this.painter.continuationCapacity + .001;
|
|
@@ -8013,6 +8333,8 @@ class PdfTableBandFlow {
|
|
|
8013
8333
|
return;
|
|
8014
8334
|
for (let band = 0; band < this.layout.bands.length; band++) {
|
|
8015
8335
|
checkAbort(this.layout.settings.options.signal);
|
|
8336
|
+
if (!this.firstWindow && this.entries.length > 0 && this.entries.every(entry => entry.exhaustedBands[band]))
|
|
8337
|
+
continue;
|
|
8016
8338
|
await this.painter.paint(band, this.headings[band], this.entries.flatMap(entry => entry.rows[band]), this.firstWindow ? this.caption : this.continuation, this.firstWindow, band === 0);
|
|
8017
8339
|
}
|
|
8018
8340
|
for (const entry of this.entries)
|
|
@@ -8029,7 +8351,7 @@ const _exports = Object.freeze({ PdfTableBandFlow: PdfTableBandFlow });
|
|
|
8029
8351
|
return _exports;
|
|
8030
8352
|
})();
|
|
8031
8353
|
|
|
8032
|
-
const
|
|
8354
|
+
const _m76 = (() => {
|
|
8033
8355
|
/** @internal Source-cell identities survive page fragments and horizontal band projections.
|
|
8034
8356
|
* Only column headers and still-owned row objects remain reachable from this table owner. */
|
|
8035
8357
|
class PdfTableStructure {
|
|
@@ -8039,6 +8361,8 @@ class PdfTableStructure {
|
|
|
8039
8361
|
cells = new WeakMap();
|
|
8040
8362
|
rows = new WeakMap();
|
|
8041
8363
|
columnHeaders = [];
|
|
8364
|
+
/** Ordinary cells without row headers share immutable dictionary references, bounded by column count. */
|
|
8365
|
+
ordinaryAttributes = [];
|
|
8042
8366
|
headerCount = 0;
|
|
8043
8367
|
headersPrepared = false;
|
|
8044
8368
|
constructor(structure, table, headers) {
|
|
@@ -8079,19 +8403,30 @@ class PdfTableStructure {
|
|
|
8079
8403
|
return row.cells.map(cell => this.cells.get(cell));
|
|
8080
8404
|
const rowId = this.structure.element("TR", parent);
|
|
8081
8405
|
this.rows.set(row, rowId);
|
|
8082
|
-
const
|
|
8083
|
-
|
|
8084
|
-
//
|
|
8406
|
+
const headers = row.cells.map((cell, index) => rowHeaderIndex === undefined ? cell.rowHeader === true : index === rowHeaderIndex);
|
|
8407
|
+
// Allocate in source order, then resolve every row header before associating even earlier data cells.
|
|
8408
|
+
// Generated summary labels override detail roles so numeric subtotal cells never become row headers.
|
|
8409
|
+
const ids = row.cells.map((cell, index) => {
|
|
8410
|
+
const id = this.structure.element(headers[index] ? "TH" : "TD", rowId);
|
|
8411
|
+
this.cells.set(cell, id);
|
|
8412
|
+
return id;
|
|
8413
|
+
});
|
|
8414
|
+
const rowHeaders = [];
|
|
8415
|
+
for (let index = 0; index < ids.length; index++)
|
|
8416
|
+
if (headers[index])
|
|
8417
|
+
rowHeaders.push(await this.structure.identifier(ids[index]));
|
|
8085
8418
|
for (let index = 0; index < row.cells.length; index++) {
|
|
8086
|
-
const cell = row.cells[index]
|
|
8419
|
+
const cell = row.cells[index];
|
|
8420
|
+
if (!rowHeaders.length && cell.span === 1 && (cell.rowSpan ?? 1) === 1) {
|
|
8421
|
+
const attributes = this.ordinaryAttributes[cell.first] ??=
|
|
8422
|
+
await this.structure.attributeReference(this.attributeDictionary(cell, this.associations(cell)));
|
|
8423
|
+
this.structure.setAttributes(ids[index], attributes);
|
|
8424
|
+
continue;
|
|
8425
|
+
}
|
|
8087
8426
|
const associations = this.associations(cell);
|
|
8088
|
-
if (
|
|
8089
|
-
associations.push(
|
|
8090
|
-
|
|
8091
|
-
this.cells.set(cell, id);
|
|
8092
|
-
ids.push(id);
|
|
8093
|
-
if (isRowHeader)
|
|
8094
|
-
rowHeaderIdentifier = await this.structure.identifier(id);
|
|
8427
|
+
if (!headers[index])
|
|
8428
|
+
associations.push(...rowHeaders);
|
|
8429
|
+
this.structure.setAttributes(ids[index], this.attributes(cell, associations, headers[index] ? "Row" : undefined));
|
|
8095
8430
|
}
|
|
8096
8431
|
return ids;
|
|
8097
8432
|
}
|
|
@@ -8117,7 +8452,10 @@ class PdfTableStructure {
|
|
|
8117
8452
|
return [...headers].sort((left, right) => left.order - right.order).map(header => header.identifier);
|
|
8118
8453
|
}
|
|
8119
8454
|
attributes(cell, headers, scope) {
|
|
8120
|
-
return " /A
|
|
8455
|
+
return " /A " + this.attributeDictionary(cell, headers, scope);
|
|
8456
|
+
}
|
|
8457
|
+
attributeDictionary(cell, headers, scope) {
|
|
8458
|
+
return "<< /O /Table" + (scope === undefined ? "" : " /Scope /" + scope) +
|
|
8121
8459
|
(cell.span > 1 ? " /ColSpan " + cell.span : "") + ((cell.rowSpan ?? 1) > 1 ? " /RowSpan " + cell.rowSpan : "") +
|
|
8122
8460
|
(headers.length ? " /Headers [" + headers.map(id => "(" + id + ")").join(" ") + "]" : "") + " >>";
|
|
8123
8461
|
}
|
|
@@ -8126,7 +8464,7 @@ const _exports = Object.freeze({ PdfTableStructure: PdfTableStructure });
|
|
|
8126
8464
|
return _exports;
|
|
8127
8465
|
})();
|
|
8128
8466
|
|
|
8129
|
-
const
|
|
8467
|
+
const _m77 = (() => {
|
|
8130
8468
|
const { OfficeIMOError } = _m2;
|
|
8131
8469
|
|
|
8132
8470
|
const { pdfNumber, unicodeHex } = _m60;
|
|
@@ -8171,7 +8509,7 @@ const _exports = Object.freeze({ linkAnnotation: linkAnnotation });
|
|
|
8171
8509
|
return _exports;
|
|
8172
8510
|
})();
|
|
8173
8511
|
|
|
8174
|
-
const
|
|
8512
|
+
const _m78 = (() => {
|
|
8175
8513
|
const { OfficeIMOError } = _m2;
|
|
8176
8514
|
|
|
8177
8515
|
const { unicodeHex } = _m60;
|
|
@@ -8219,7 +8557,7 @@ const _exports = Object.freeze({ captureBookmark: captureBookmark, captureSectio
|
|
|
8219
8557
|
return _exports;
|
|
8220
8558
|
})();
|
|
8221
8559
|
|
|
8222
|
-
const
|
|
8560
|
+
const _m79 = (() => {
|
|
8223
8561
|
const { settings } = _m17;
|
|
8224
8562
|
|
|
8225
8563
|
/** @internal Every section derives from captured document defaults, never the preceding section. */
|
|
@@ -8237,7 +8575,7 @@ const _exports = Object.freeze({ sectionSettings: sectionSettings });
|
|
|
8237
8575
|
return _exports;
|
|
8238
8576
|
})();
|
|
8239
8577
|
|
|
8240
|
-
const
|
|
8578
|
+
const _m74 = (() => {
|
|
8241
8579
|
const { OfficeIMOError } = _m2;
|
|
8242
8580
|
|
|
8243
8581
|
const { checkAbort } = _m4;
|
|
@@ -8246,19 +8584,19 @@ const { pdfNumber } = _m60;
|
|
|
8246
8584
|
|
|
8247
8585
|
const { color } = _m17;
|
|
8248
8586
|
|
|
8249
|
-
const { PdfTableBandFlow } =
|
|
8587
|
+
const { PdfTableBandFlow } = _m75;
|
|
8250
8588
|
|
|
8251
|
-
const { PdfTableStructure } =
|
|
8589
|
+
const { PdfTableStructure } = _m76;
|
|
8252
8590
|
|
|
8253
|
-
const { wrapText, wrapTextCooperatively, synchronousText } =
|
|
8591
|
+
const { wrapText, wrapTextCooperatively, synchronousText, pdfBudgetText } = _m70;
|
|
8254
8592
|
|
|
8255
|
-
const { linkAnnotation } =
|
|
8593
|
+
const { linkAnnotation } = _m77;
|
|
8256
8594
|
|
|
8257
8595
|
const { unicodeHex } = _m60;
|
|
8258
8596
|
|
|
8259
|
-
const { captureSection, captureBookmark } =
|
|
8597
|
+
const { captureSection, captureBookmark } = _m78;
|
|
8260
8598
|
|
|
8261
|
-
const { sectionSettings } =
|
|
8599
|
+
const { sectionSettings } = _m79;
|
|
8262
8600
|
|
|
8263
8601
|
/** @internal One page of drawing commands and O(page count) references, never the complete report body. */
|
|
8264
8602
|
class PdfPages {
|
|
@@ -8396,8 +8734,9 @@ class PdfPages {
|
|
|
8396
8734
|
const lineActualText = !this.structure && line.actualText !== undefined && line.actualText.length > 0;
|
|
8397
8735
|
if (lineActualText)
|
|
8398
8736
|
this.add("/Span << /ActualText <FEFF" + unicodeHex(line.actualText) + "> >> BDC\n");
|
|
8399
|
-
|
|
8737
|
+
let marks;
|
|
8400
8738
|
if (line.actualText !== undefined && this.structure && element !== undefined) {
|
|
8739
|
+
marks = new Map();
|
|
8401
8740
|
// Allocate MCIDs/Link children in logical order, then paint the independently positioned visual order.
|
|
8402
8741
|
for (const segment of [...line.segments].sort((a, b) => (a.logicalStart ?? 0) - (b.logicalStart ?? 0))) {
|
|
8403
8742
|
const owner = segment.link ? this.structure.link(element, segment.link) : element;
|
|
@@ -8405,7 +8744,7 @@ class PdfPages {
|
|
|
8405
8744
|
}
|
|
8406
8745
|
}
|
|
8407
8746
|
for (const segment of line.segments) {
|
|
8408
|
-
const registered = marks
|
|
8747
|
+
const registered = marks?.get(segment), owner = registered?.owner ?? (segment.link && this.structure && element !== undefined ? this.structure.link(element, segment.link) : element);
|
|
8409
8748
|
if (segment.glyphs) {
|
|
8410
8749
|
const font = segment.font, n = pdfNumber, shear = font.syntheticItalic ? .213 : 0;
|
|
8411
8750
|
let cursor = x, command = "q " + this.rgb(segment.color ?? "111827") + " rg " + this.rgb(segment.color ?? "111827") + " RG\nBT /" + font.name + " " + n(size) + " Tf " +
|
|
@@ -8439,7 +8778,7 @@ class PdfPages {
|
|
|
8439
8778
|
decoration(text, x, y, width) {
|
|
8440
8779
|
if (!text)
|
|
8441
8780
|
return;
|
|
8442
|
-
this.settings.budget.cell(text);
|
|
8781
|
+
this.settings.budget.cell(pdfBudgetText(text, this.settings.budget));
|
|
8443
8782
|
const font = this.fonts.select(), lines = wrapText(text, font, this.settings.fontSize, width, this.settings.limits.maxCellCharacters, 1, false);
|
|
8444
8783
|
this.text(lines[0].text, font, this.settings.fontSize, x, y);
|
|
8445
8784
|
}
|
|
@@ -8500,9 +8839,7 @@ class PdfPages {
|
|
|
8500
8839
|
}
|
|
8501
8840
|
const headers = preparedHeadings ?? (tableHeadings && this.layout ? this.activeHeadings ??= await this.layout.headers() : []), headerHeight = headers.reduce((n, h) => n + h.height, 0), continuation = tableHeadings && this.layout ? this.continuationCaption : undefined;
|
|
8502
8841
|
if (continuation?.lines.length) {
|
|
8503
|
-
if (this.continuationCaptionPaints++
|
|
8504
|
-
this.settings.budget.cell(continuation.text.text);
|
|
8505
|
-
else
|
|
8842
|
+
if (this.continuationCaptionPaints++ === 0)
|
|
8506
8843
|
this.tableCaptionOwner = this.captionAnnotations(continuation, this.tableCaptionOwner);
|
|
8507
8844
|
await this.paragraphs([continuation], headerHeight + lineHeight + this.settings.padding * 2, true, { artifact: true, ...(this.tableCaptionOwner === undefined ? {} : { annotationParent: this.tableCaptionOwner }) });
|
|
8508
8845
|
}
|
|
@@ -8620,7 +8957,7 @@ class PdfPages {
|
|
|
8620
8957
|
async paragraph(text, style = {}, size = this.settings.fontSize, paginate = true, headingLevel) {
|
|
8621
8958
|
await this.ensureStarted();
|
|
8622
8959
|
const { margins, page, limits } = this.settings, font = this.fonts.select(style.bold, style.italic), lineHeight = font.lineHeight(size);
|
|
8623
|
-
this.settings.budget.cell(text);
|
|
8960
|
+
this.settings.budget.cell(pdfBudgetText(text, this.settings.budget));
|
|
8624
8961
|
const lines = await wrapTextCooperatively(text, font, size, page.width - margins.left - margins.right, limits.maxCellCharacters, limits.maxRowLines, true, this.settings.options.signal);
|
|
8625
8962
|
if (lineHeight > page.height - margins.top - margins.bottom)
|
|
8626
8963
|
throw new RangeError("PDF page cannot fit a paragraph line at the selected font metrics.");
|
|
@@ -8663,6 +9000,8 @@ class PdfPages {
|
|
|
8663
9000
|
if (keepTogether && visible.length)
|
|
8664
9001
|
await this.reserveSpace(visible.reduce((height, paragraph) => height + paragraph.height, 0) + reservations.at(-1), "Kept PDF paragraph group");
|
|
8665
9002
|
for (const [index, paragraph] of visible.entries()) {
|
|
9003
|
+
if (paragraph.budgetOnPaint)
|
|
9004
|
+
this.settings.budget.cell(pdfBudgetText(paragraph.text.text, this.settings.budget));
|
|
8666
9005
|
if (paragraph.keepTogether || paragraph.keepWithNext)
|
|
8667
9006
|
await this.reserveSpace(paragraph.height + reservations[index], "Kept PDF paragraph chain");
|
|
8668
9007
|
const { margins, page } = this.settings;
|
|
@@ -8715,10 +9054,11 @@ class PdfPages {
|
|
|
8715
9054
|
/** The generated summary label is a row heading; no localized text/style inference is used. */
|
|
8716
9055
|
summary(row) { this.summaryRows.add(row); }
|
|
8717
9056
|
/** Begin an independent table on the current page, retaining its headings on continuation pages.
|
|
8718
|
-
* Group context uses captionArtifact: it stays visually complete without duplicating logical headings.
|
|
8719
|
-
|
|
9057
|
+
* Group context uses captionArtifact: it stays visually complete without duplicating logical headings.
|
|
9058
|
+
* An already-painted opening path only suppresses its artifact caption on that existing page. */
|
|
9059
|
+
async beginTable(layout, preparedHeadings, minimumDataHeight = layout.lineHeight + this.settings.padding * 2, caption, continuationCaption, headingsOnNewPageOnly = false, captionArtifact = false, openingContextAlreadyPainted = false) {
|
|
8720
9060
|
if (layout.bands)
|
|
8721
|
-
return this.beginBands(layout, preparedHeadings, minimumDataHeight, caption, continuationCaption, captionArtifact);
|
|
9061
|
+
return this.beginBands(layout, preparedHeadings, minimumDataHeight, caption, continuationCaption, captionArtifact, openingContextAlreadyPainted);
|
|
8722
9062
|
await this.ensureStarted();
|
|
8723
9063
|
this.layout = layout;
|
|
8724
9064
|
this.paintedHeaderCells = new WeakSet();
|
|
@@ -8732,7 +9072,7 @@ class PdfPages {
|
|
|
8732
9072
|
// Its own headings remain available when it moves or splits onto a fresh page.
|
|
8733
9073
|
const initialHeadings = headingsOnNewPageOnly && this.bodyAdded && !this.structure ? [] : headings;
|
|
8734
9074
|
const height = initialHeadings.reduce((n, row) => n + row.height, 0);
|
|
8735
|
-
if (caption) {
|
|
9075
|
+
if (caption && !(captionArtifact && openingContextAlreadyPainted)) {
|
|
8736
9076
|
await this.reserveSpace(caption.height + height + minimumDataHeight, "Kept PDF table caption and first data fragment");
|
|
8737
9077
|
this.tableCaptionOwner = captionArtifact ? this.captionAnnotations(caption)
|
|
8738
9078
|
: caption.lines.length ? this.structure?.element("Caption", this.tableElement) : undefined;
|
|
@@ -8754,7 +9094,7 @@ class PdfPages {
|
|
|
8754
9094
|
this.dataTop = this.y;
|
|
8755
9095
|
}
|
|
8756
9096
|
/** Bind the bounded logical-window owner to the existing physical page painter. */
|
|
8757
|
-
async beginBands(layout, preparedHeadings, minimumDataHeight, caption, continuation, captionArtifact) {
|
|
9097
|
+
async beginBands(layout, preparedHeadings, minimumDataHeight, caption, continuation, captionArtifact, openingContextAlreadyPainted) {
|
|
8758
9098
|
await this.ensureStarted();
|
|
8759
9099
|
const logicalHeadings = preparedHeadings ?? await layout.headers(), headings = await layout.bandRows(logicalHeadings, true);
|
|
8760
9100
|
const headerHeight = headings[0].reduce((sum, row) => sum + row.height, 0), { page, margins, padding } = this.settings;
|
|
@@ -8763,13 +9103,15 @@ class PdfPages {
|
|
|
8763
9103
|
const continuationCapacity = page.height - margins.top - margins.bottom - headerHeight - (continuation?.height ?? 0);
|
|
8764
9104
|
if (continuationCapacity + .001 < layout.lineHeight + padding * 2)
|
|
8765
9105
|
throw new RangeError("PDF band headings and continuation context leave no room for a data line.");
|
|
8766
|
-
|
|
9106
|
+
let openingContextPainted = captionArtifact && openingContextAlreadyPainted;
|
|
9107
|
+
if (this.y - margins.bottom - headerHeight - (openingContextPainted ? 0 : caption?.height ?? 0) + .001 < minimum) {
|
|
8767
9108
|
await this.pageBreak();
|
|
8768
|
-
|
|
8769
|
-
|
|
9109
|
+
openingContextPainted = false;
|
|
9110
|
+
}
|
|
9111
|
+
const firstCapacity = this.y - margins.bottom - headerHeight - (openingContextPainted ? 0 : caption?.height ?? 0);
|
|
8770
9112
|
if (firstCapacity + .001 < minimum)
|
|
8771
9113
|
throw new RangeError("PDF band caption and headings leave no room for a data line.");
|
|
8772
|
-
let
|
|
9114
|
+
let continuationPaints = 0;
|
|
8773
9115
|
this.tableElement = this.structure?.element("Table", this.groupParent);
|
|
8774
9116
|
this.paintedHeaderCells = new WeakSet();
|
|
8775
9117
|
let captionElement = this.structure && caption?.lines.length ? captionArtifact ? this.captionAnnotations(caption)
|
|
@@ -8783,21 +9125,16 @@ class PdfPages {
|
|
|
8783
9125
|
this.bandFlow = new PdfTableBandFlow(layout, headings, { firstCapacity, firstFullCapacity, continuationCapacity,
|
|
8784
9126
|
prepareRow: async (row) => { await this.tableStructure?.prepareHeaders(); await this.rowElements(row); },
|
|
8785
9127
|
completeRow: async (row) => { await this.tableStructure?.completeRow(row.source ?? row); },
|
|
8786
|
-
moveFirstToFreshPage: async () => { await this.pageBreak();
|
|
9128
|
+
moveFirstToFreshPage: async () => { await this.pageBreak(); openingContextPainted = false; },
|
|
8787
9129
|
paint: async (band, headers, rows, currentCaption, firstWindow, firstBand) => {
|
|
8788
9130
|
if (!(firstWindow && firstBand))
|
|
8789
9131
|
await this.pageBreak();
|
|
8790
|
-
if (firstWindow && !firstBand)
|
|
8791
|
-
this.y -= initialOffset;
|
|
8792
9132
|
const frame = layout.bands[band];
|
|
8793
9133
|
this.layout = { lefts: frame.lefts, lineHeight: layout.lineHeight, headers: async () => headers };
|
|
8794
9134
|
this.bandCellBudget = true;
|
|
8795
9135
|
try {
|
|
8796
|
-
if (currentCaption?.lines.length) {
|
|
8797
|
-
|
|
8798
|
-
if (paints > 0)
|
|
8799
|
-
this.settings.budget.cell(currentCaption.text.text);
|
|
8800
|
-
if (!firstWindow && paints === 0)
|
|
9136
|
+
if (currentCaption?.lines.length && !(firstWindow && firstBand && openingContextPainted)) {
|
|
9137
|
+
if (!firstWindow && continuationPaints++ === 0)
|
|
8801
9138
|
captionElement = this.captionAnnotations(currentCaption, captionElement);
|
|
8802
9139
|
const annotationParent = captionElement;
|
|
8803
9140
|
await this.paragraphs([currentCaption], headerHeight + minimum, true, firstWindow && firstBand && !captionArtifact ? { role: "Caption", keepOpen: true, ...(captionElement === undefined ? {} : { owner: captionElement }) }
|
|
@@ -8901,7 +9238,7 @@ class PdfPages {
|
|
|
8901
9238
|
this.annotations = [];
|
|
8902
9239
|
this.commandBytes = 0;
|
|
8903
9240
|
this.current = 0;
|
|
8904
|
-
await this.objects.
|
|
9241
|
+
await this.objects.flushBytes();
|
|
8905
9242
|
}
|
|
8906
9243
|
async finish() {
|
|
8907
9244
|
if (this.bandFlow) {
|
|
@@ -8932,7 +9269,7 @@ const _exports = Object.freeze({ PdfPages: PdfPages });
|
|
|
8932
9269
|
return _exports;
|
|
8933
9270
|
})();
|
|
8934
9271
|
|
|
8935
|
-
const
|
|
9272
|
+
const _m81 = (() => {
|
|
8936
9273
|
/** @internal Incremental PDF number tree: at most 64 entries/children per retained level. */
|
|
8937
9274
|
class PdfParentTree {
|
|
8938
9275
|
objects;
|
|
@@ -8994,15 +9331,38 @@ const _exports = Object.freeze({ PdfParentTree: PdfParentTree });
|
|
|
8994
9331
|
return _exports;
|
|
8995
9332
|
})();
|
|
8996
9333
|
|
|
8997
|
-
const
|
|
9334
|
+
const _m80 = (() => {
|
|
8998
9335
|
const { OfficeIMOError } = _m2;
|
|
8999
9336
|
|
|
9000
9337
|
const { checkAbort } = _m4;
|
|
9001
9338
|
|
|
9002
9339
|
const { unicodeHex } = _m60;
|
|
9003
9340
|
|
|
9004
|
-
const { PdfParentTree } =
|
|
9341
|
+
const { PdfParentTree } = _m81;
|
|
9005
9342
|
|
|
9343
|
+
/** Same-page marked content uses integer K; cross-page MCR and annotation OBJR stay explicit. */
|
|
9344
|
+
function structureChild(child) {
|
|
9345
|
+
return typeof child === "number" ? (child < 0 ? -child - 1 + " " : child + " 0 R ") : child + " ";
|
|
9346
|
+
}
|
|
9347
|
+
function structurePrefix(element) {
|
|
9348
|
+
return "<< /Type /StructElem /S /" + element.role + " /P " + element.parent + " 0 R" +
|
|
9349
|
+
(element.markedPage === undefined ? "" : " /Pg " + element.markedPage + " 0 R") +
|
|
9350
|
+
(element.identifier === undefined ? "" : " /ID (" + element.identifier + ")") + " /K [";
|
|
9351
|
+
}
|
|
9352
|
+
/** Keep the same bounded small-object representation for both completion paths. */
|
|
9353
|
+
function compactStructureBody(element, prefix) {
|
|
9354
|
+
const remaining = 32768 - prefix.length - element.attributes.length - 4;
|
|
9355
|
+
if (remaining < 0)
|
|
9356
|
+
return undefined;
|
|
9357
|
+
let children = "";
|
|
9358
|
+
for (const child of element.children) {
|
|
9359
|
+
const token = structureChild(child);
|
|
9360
|
+
if (children.length + token.length > remaining)
|
|
9361
|
+
return undefined;
|
|
9362
|
+
children += token;
|
|
9363
|
+
}
|
|
9364
|
+
return prefix + children + "]" + element.attributes + " >>";
|
|
9365
|
+
}
|
|
9006
9366
|
/** A sorted name tree retains only a small open leaf and branch at each level. */
|
|
9007
9367
|
class PdfStructureIds {
|
|
9008
9368
|
objects;
|
|
@@ -9092,7 +9452,7 @@ class PdfStructure {
|
|
|
9092
9452
|
checkAbort(this.settings.options.signal);
|
|
9093
9453
|
if (++this.allocated > this.settings.limits.maxStructureElements)
|
|
9094
9454
|
throw new OfficeIMOError("RESOURCE_LIMIT", "maxStructureElements exceeded.");
|
|
9095
|
-
const id = this.objects.reserve(), element = { id, parent, role, children: [], attributes
|
|
9455
|
+
const id = this.objects.reserve(), element = { id, parent, role, children: [], attributes };
|
|
9096
9456
|
this.elements.set(id, element);
|
|
9097
9457
|
const owner = this.elements.get(parent);
|
|
9098
9458
|
// A continuation-only linked caption is discovered during painting, after rows may exist.
|
|
@@ -9103,6 +9463,20 @@ class PdfStructure {
|
|
|
9103
9463
|
owner?.children.push(id);
|
|
9104
9464
|
return id;
|
|
9105
9465
|
}
|
|
9466
|
+
/** Attach resolved table associations while a source-ordered logical element is still open. */
|
|
9467
|
+
setAttributes(elementId, attributes) {
|
|
9468
|
+
const element = this.elements.get(elementId);
|
|
9469
|
+
if (!element)
|
|
9470
|
+
throw new Error("PDF structure attributes require an open logical owner.");
|
|
9471
|
+
element.attributes = attributes;
|
|
9472
|
+
}
|
|
9473
|
+
/** Write one immutable attribute dictionary. Its caller owns the bounded scope of reference reuse. */
|
|
9474
|
+
async attributeReference(dictionary) {
|
|
9475
|
+
checkAbort(this.settings.options.signal);
|
|
9476
|
+
const id = this.objects.reserve();
|
|
9477
|
+
await this.objects.object(id, dictionary);
|
|
9478
|
+
return " /A " + id + " 0 R";
|
|
9479
|
+
}
|
|
9106
9480
|
/** Flat visual sections share the same logical Document and cumulative resource policy. */
|
|
9107
9481
|
async beginSection() {
|
|
9108
9482
|
await this.complete(this.section);
|
|
@@ -9136,7 +9510,8 @@ class PdfStructure {
|
|
|
9136
9510
|
return existing;
|
|
9137
9511
|
const id = this.element("Link", parent, alternativeText === undefined ? "" : " /Alt <feff" + unicodeHex(alternativeText) + ">");
|
|
9138
9512
|
parents.set(parent, id);
|
|
9139
|
-
this.elements.get(parent)
|
|
9513
|
+
const owner = this.elements.get(parent);
|
|
9514
|
+
(owner.linkIdentities ??= []).push(identity);
|
|
9140
9515
|
return id;
|
|
9141
9516
|
}
|
|
9142
9517
|
/** Associate a native annotation in both directions: OBJR child and annotation ParentTree entry. */
|
|
@@ -9159,7 +9534,9 @@ class PdfStructure {
|
|
|
9159
9534
|
throw new Error("Marked content requires an open logical owner.");
|
|
9160
9535
|
const mcid = this.pageParents.length;
|
|
9161
9536
|
this.pageParents.push(elementId);
|
|
9162
|
-
element.
|
|
9537
|
+
element.markedPage ??= this.pageId;
|
|
9538
|
+
element.children.push(element.markedPage === this.pageId ? -(mcid + 1) :
|
|
9539
|
+
"<< /Type /MCR /Pg " + this.pageId + " 0 R /MCID " + mcid + " >>");
|
|
9163
9540
|
return "/" + element.role + " << /MCID " + mcid + (actualText === undefined ? "" : " /ActualText <FEFF" + unicodeHex(actualText) + ">") + " >> BDC\n";
|
|
9164
9541
|
}
|
|
9165
9542
|
get pageDictionary() { return " /StructParents " + this.pageKey + " /Tabs /S"; }
|
|
@@ -9183,37 +9560,49 @@ class PdfStructure {
|
|
|
9183
9560
|
if (!element)
|
|
9184
9561
|
return;
|
|
9185
9562
|
for (const child of element.children)
|
|
9186
|
-
if (typeof child === "number" && this.
|
|
9563
|
+
if (typeof child === "number" && child > 0 && !this.completeBuffered(child))
|
|
9187
9564
|
await this.complete(child);
|
|
9188
9565
|
checkAbort(this.settings.options.signal);
|
|
9189
|
-
const prefix =
|
|
9190
|
-
(element.identifier === undefined ? "" : " /ID (" + element.identifier + ")") + " /K [";
|
|
9191
|
-
const remaining = 32768 - prefix.length - element.attributes.length - 4;
|
|
9192
|
-
let children = "", small = remaining >= 0;
|
|
9193
|
-
if (small)
|
|
9194
|
-
for (const child of element.children) {
|
|
9195
|
-
const token = typeof child === "number" ? child + " 0 R " : child + " ";
|
|
9196
|
-
if (children.length + token.length > remaining) {
|
|
9197
|
-
small = false;
|
|
9198
|
-
break;
|
|
9199
|
-
}
|
|
9200
|
-
children += token;
|
|
9201
|
-
}
|
|
9566
|
+
const prefix = structurePrefix(element), body = compactStructureBody(element, prefix);
|
|
9202
9567
|
// Most table cells/rows fit in one encoding. Large parents and alternatives remain streamed.
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9210
|
-
|
|
9211
|
-
|
|
9212
|
-
|
|
9213
|
-
|
|
9214
|
-
|
|
9568
|
+
if (body !== undefined) {
|
|
9569
|
+
if (!this.objects.tryCompactObject(id, body))
|
|
9570
|
+
await this.objects.compactObject(id, body);
|
|
9571
|
+
}
|
|
9572
|
+
else
|
|
9573
|
+
await this.objects.object(id, this.body(element, prefix));
|
|
9574
|
+
this.releaseElement(element);
|
|
9575
|
+
}
|
|
9576
|
+
/** Close already-bufferable children without creating an async chain per leaf. A false result
|
|
9577
|
+
* leaves the current owner open for the existing awaited flush or ordinary-object path. */
|
|
9578
|
+
completeBuffered(id) {
|
|
9579
|
+
const element = this.elements.get(id);
|
|
9580
|
+
if (!element)
|
|
9581
|
+
return true;
|
|
9582
|
+
for (const child of element.children)
|
|
9583
|
+
if (typeof child === "number" && child > 0 && !this.completeBuffered(child))
|
|
9584
|
+
return false;
|
|
9585
|
+
checkAbort(this.settings.options.signal);
|
|
9586
|
+
const body = compactStructureBody(element, structurePrefix(element));
|
|
9587
|
+
if (body === undefined || !this.objects.tryCompactObject(id, body))
|
|
9588
|
+
return false;
|
|
9589
|
+
this.releaseElement(element);
|
|
9590
|
+
return true;
|
|
9591
|
+
}
|
|
9592
|
+
releaseElement(element) {
|
|
9593
|
+
if (element.linkIdentities)
|
|
9594
|
+
for (const identity of element.linkIdentities) {
|
|
9595
|
+
const parents = this.links.get(identity);
|
|
9596
|
+
parents?.delete(element.id);
|
|
9597
|
+
if (!parents?.size)
|
|
9598
|
+
this.links.delete(identity);
|
|
9599
|
+
}
|
|
9600
|
+
this.elements.delete(element.id);
|
|
9601
|
+
}
|
|
9602
|
+
*body(element, prefix) {
|
|
9603
|
+
yield prefix;
|
|
9215
9604
|
for (const child of element.children)
|
|
9216
|
-
yield
|
|
9605
|
+
yield structureChild(child);
|
|
9217
9606
|
yield "]" + element.attributes + " >>";
|
|
9218
9607
|
}
|
|
9219
9608
|
async completeRow(cells) {
|
|
@@ -9253,7 +9642,7 @@ const _exports = Object.freeze({ PdfStructure: PdfStructure, graphicAlternative:
|
|
|
9253
9642
|
return _exports;
|
|
9254
9643
|
})();
|
|
9255
9644
|
|
|
9256
|
-
const
|
|
9645
|
+
const _m82 = (() => {
|
|
9257
9646
|
const { OfficeIMOError } = _m2;
|
|
9258
9647
|
|
|
9259
9648
|
const { checkAbort } = _m4;
|
|
@@ -9319,15 +9708,15 @@ return _exports;
|
|
|
9319
9708
|
const _m59 = (() => {
|
|
9320
9709
|
const { PdfObjects, unicodeHex } = _m60;
|
|
9321
9710
|
|
|
9322
|
-
const { PdfFontResources } =
|
|
9711
|
+
const { PdfFontResources } = _m62;
|
|
9323
9712
|
|
|
9324
|
-
const { PdfTableLayout } =
|
|
9713
|
+
const { PdfTableLayout } = _m69;
|
|
9325
9714
|
|
|
9326
|
-
const { PdfPages } =
|
|
9715
|
+
const { PdfPages } = _m74;
|
|
9327
9716
|
|
|
9328
|
-
const { PdfStructure } =
|
|
9717
|
+
const { PdfStructure } = _m80;
|
|
9329
9718
|
|
|
9330
|
-
const { PdfOutlines } =
|
|
9719
|
+
const { PdfOutlines } = _m82;
|
|
9331
9720
|
|
|
9332
9721
|
/** One resource/catalog owner shared by table convenience exports and composed documents. */
|
|
9333
9722
|
class PdfWriteSession {
|
|
@@ -9344,7 +9733,7 @@ class PdfWriteSession {
|
|
|
9344
9733
|
info;
|
|
9345
9734
|
constructor(sink, settings, table = false) {
|
|
9346
9735
|
this.settings = settings;
|
|
9347
|
-
this.objects = new PdfObjects(sink, settings.options.signal, settings.budget.limits.maxOutputBytes);
|
|
9736
|
+
this.objects = new PdfObjects(sink, settings.options.signal, settings.budget.limits.maxOutputBytes, settings.options.compression !== false);
|
|
9348
9737
|
this.root = this.objects.reserve();
|
|
9349
9738
|
this.parent = this.objects.reserve();
|
|
9350
9739
|
this.resources = this.objects.reserve();
|
|
@@ -9450,7 +9839,7 @@ const _exports = Object.freeze({ writePdf: writePdf, writePdfTo: writePdfTo });
|
|
|
9450
9839
|
return _exports;
|
|
9451
9840
|
})();
|
|
9452
9841
|
|
|
9453
|
-
const
|
|
9842
|
+
const _m86 = (() => {
|
|
9454
9843
|
const { NotSupportedError, OfficeIMOError } = _m2;
|
|
9455
9844
|
|
|
9456
9845
|
const { checkAbort, pause, taskYieldDue, withAbort } = _m4;
|
|
@@ -9717,12 +10106,12 @@ const _exports = Object.freeze({ pngPixels: pngPixels });
|
|
|
9717
10106
|
return _exports;
|
|
9718
10107
|
})();
|
|
9719
10108
|
|
|
9720
|
-
const
|
|
10109
|
+
const _m85 = (() => {
|
|
9721
10110
|
const { NotSupportedError, OfficeIMOError } = _m2;
|
|
9722
10111
|
|
|
9723
10112
|
const { checkAbort, pause, taskYieldDue } = _m4;
|
|
9724
10113
|
|
|
9725
|
-
const { pngPixels } =
|
|
10114
|
+
const { pngPixels } = _m86;
|
|
9726
10115
|
|
|
9727
10116
|
/** Shared document image resources; source objects are captured on first consumption. */
|
|
9728
10117
|
class PdfDocumentImages {
|
|
@@ -9850,7 +10239,7 @@ const _exports = Object.freeze({ PdfDocumentImages: PdfDocumentImages });
|
|
|
9850
10239
|
return _exports;
|
|
9851
10240
|
})();
|
|
9852
10241
|
|
|
9853
|
-
const
|
|
10242
|
+
const _m87 = (() => {
|
|
9854
10243
|
const { OfficeIMOError } = _m2;
|
|
9855
10244
|
|
|
9856
10245
|
const { checkAbort, pause, taskYieldDue } = _m4;
|
|
@@ -9936,7 +10325,7 @@ const _exports = Object.freeze({ vectorCommands: vectorCommands });
|
|
|
9936
10325
|
return _exports;
|
|
9937
10326
|
})();
|
|
9938
10327
|
|
|
9939
|
-
const
|
|
10328
|
+
const _m88 = (() => {
|
|
9940
10329
|
const { NotSupportedError, OfficeIMOError } = _m2;
|
|
9941
10330
|
|
|
9942
10331
|
const { checkAbort, pause, taskYieldDue } = _m4;
|
|
@@ -10182,21 +10571,23 @@ const _exports = Object.freeze({ checkDrawingBlock: checkDrawingBlock, prepareDr
|
|
|
10182
10571
|
return _exports;
|
|
10183
10572
|
})();
|
|
10184
10573
|
|
|
10185
|
-
const
|
|
10574
|
+
const _m89 = (() => {
|
|
10186
10575
|
const { OfficeIMOError } = _m2;
|
|
10187
10576
|
|
|
10188
|
-
const { capturePdfText, wrapPdfText } =
|
|
10577
|
+
const { capturePdfText, wrapPdfText } = _m71;
|
|
10189
10578
|
|
|
10190
10579
|
const { positive } = _m17;
|
|
10191
10580
|
|
|
10192
10581
|
const { resolveParagraphStyle } = _m19;
|
|
10193
10582
|
|
|
10194
|
-
const { captureBookmark } =
|
|
10583
|
+
const { captureBookmark } = _m78;
|
|
10195
10584
|
|
|
10196
10585
|
const { captureFields } = _m10;
|
|
10197
10586
|
|
|
10587
|
+
const { pdfBudgetText } = _m70;
|
|
10588
|
+
|
|
10198
10589
|
/** @internal Copy public paragraph input before any cooperative layout or source enumeration. */
|
|
10199
|
-
function captureParagraph(block, settings, fonts) {
|
|
10590
|
+
function captureParagraph(block, settings, fonts, budgetOnPaint = false) {
|
|
10200
10591
|
if (!block || block.kind !== "paragraph")
|
|
10201
10592
|
throw new TypeError("PDF paragraph groups accept paragraph blocks only.");
|
|
10202
10593
|
const { text, headingLevel, presentation: inputStyle, fontSize, keepTogether, keepWithNext, spaceBefore, spaceAfter, style: styleName, bookmark: inputBookmark } = block;
|
|
@@ -10209,7 +10600,8 @@ function captureParagraph(block, settings, fonts) {
|
|
|
10209
10600
|
}, settings.paragraphStyles);
|
|
10210
10601
|
const style = resolved.presentation ?? Object.freeze({}), size = positive(resolved.fontSize ?? settings.fontSize, "Paragraph font size", 144);
|
|
10211
10602
|
const bookmark = captureBookmark(inputBookmark, settings);
|
|
10212
|
-
return Object.freeze({ text: capturePdfText(text, style, settings, fonts, false), style, size,
|
|
10603
|
+
return Object.freeze({ text: capturePdfText(text, style, settings, fonts, false, !budgetOnPaint), style, size,
|
|
10604
|
+
...(budgetOnPaint ? { budgetOnPaint: true } : {}),
|
|
10213
10605
|
...(headingLevel === undefined ? {} : { headingLevel }), ...(bookmark === undefined ? {} : { bookmark }),
|
|
10214
10606
|
keepTogether: resolved.keepTogether ?? false, keepWithNext: resolved.keepWithNext ?? false,
|
|
10215
10607
|
spaceBefore: resolved.spaceBefore ?? 0, spaceAfter: resolved.spaceAfter ?? 8 });
|
|
@@ -10220,13 +10612,16 @@ function captureCaption(caption, settings, fonts) {
|
|
|
10220
10612
|
Object.keys(caption).some(key => !["text", "style", "fontSize", "presentation", "spaceBefore", "spaceAfter"].includes(key)))
|
|
10221
10613
|
throw new TypeError("PDF captions support text, style, fontSize, presentation, spaceBefore and spaceAfter.");
|
|
10222
10614
|
return captureParagraph({ ...captureFields(caption, ["text", "style", "fontSize", "presentation", "spaceBefore", "spaceAfter"]),
|
|
10223
|
-
kind: "paragraph", keepTogether: true, keepWithNext: true }, settings, fonts);
|
|
10615
|
+
kind: "paragraph", keepTogether: true, keepWithNext: true }, settings, fonts, true);
|
|
10224
10616
|
}
|
|
10225
10617
|
/** @internal Layout is bounded by the same per-cell text and wrapped-line limits as table cells. */
|
|
10226
10618
|
async function prepareParagraph(captured, settings, fonts, width = settings.page.width - settings.margins.left - settings.margins.right) {
|
|
10227
10619
|
if (!captured.text.text)
|
|
10228
10620
|
return { ...captured, lines: [], height: 0, firstHeight: 0 };
|
|
10229
|
-
|
|
10621
|
+
if (!captured.budgetOnPaint) {
|
|
10622
|
+
const budgetText = pdfBudgetText(captured.text.text, settings.budget);
|
|
10623
|
+
settings.budget.cell(budgetText, budgetText.length);
|
|
10624
|
+
}
|
|
10230
10625
|
const lines = await wrapPdfText(captured.text, fonts, captured.size, positive(width, "Paragraph width"), settings);
|
|
10231
10626
|
return { ...captured, lines, height: captured.spaceBefore + lines.reduce((height, line) => height + line.lineHeight, 0) + captured.spaceAfter,
|
|
10232
10627
|
firstHeight: captured.spaceBefore + lines[0].lineHeight };
|
|
@@ -10259,10 +10654,10 @@ const _exports = Object.freeze({ captureParagraph: captureParagraph, captureCapt
|
|
|
10259
10654
|
return _exports;
|
|
10260
10655
|
})();
|
|
10261
10656
|
|
|
10262
|
-
const
|
|
10263
|
-
const { capturePdfText, wrapPdfText } =
|
|
10657
|
+
const _m90 = (() => {
|
|
10658
|
+
const { capturePdfText, wrapPdfText } = _m71;
|
|
10264
10659
|
|
|
10265
|
-
const { captureParagraph, prepareParagraph } =
|
|
10660
|
+
const { captureParagraph, prepareParagraph } = _m89;
|
|
10266
10661
|
|
|
10267
10662
|
const { resolveParagraphStyle } = _m19;
|
|
10268
10663
|
|
|
@@ -10316,7 +10711,7 @@ const _exports = Object.freeze({ captureListOptions: captureListOptions, prepare
|
|
|
10316
10711
|
return _exports;
|
|
10317
10712
|
})();
|
|
10318
10713
|
|
|
10319
|
-
const
|
|
10714
|
+
const _m92 = (() => {
|
|
10320
10715
|
const { assertGroupedReportSource } = _m8;
|
|
10321
10716
|
|
|
10322
10717
|
const { captureFields } = _m10;
|
|
@@ -10365,22 +10760,22 @@ const _exports = Object.freeze({ groupedPdfLabelFields: groupedPdfLabelFields, g
|
|
|
10365
10760
|
return _exports;
|
|
10366
10761
|
})();
|
|
10367
10762
|
|
|
10368
|
-
const
|
|
10763
|
+
const _m91 = (() => {
|
|
10369
10764
|
const { assertGroupedReportSource, groupedReportOperation } = _m8;
|
|
10370
10765
|
|
|
10371
10766
|
const { consumeRows } = _m4;
|
|
10372
10767
|
|
|
10373
10768
|
const { ExportCell } = _m5;
|
|
10374
10769
|
|
|
10375
|
-
const { captureGroupedPdfTableOptions } =
|
|
10770
|
+
const { captureGroupedPdfTableOptions } = _m92;
|
|
10376
10771
|
|
|
10377
10772
|
const { settings } = _m17;
|
|
10378
10773
|
|
|
10379
|
-
const { PdfTableLayout } =
|
|
10774
|
+
const { PdfTableLayout } = _m69;
|
|
10380
10775
|
|
|
10381
|
-
const { captureCaption, captureParagraph, prepareParagraph } =
|
|
10776
|
+
const { captureCaption, captureParagraph, prepareParagraph } = _m89;
|
|
10382
10777
|
|
|
10383
|
-
const { synchronousText } =
|
|
10778
|
+
const { synchronousText } = _m70;
|
|
10384
10779
|
|
|
10385
10780
|
/** @internal Render one analytical source in the existing document session. Retain one detail row and
|
|
10386
10781
|
* at most four closing subtotals. All captions, rows, pages, bytes and fonts use the document owners. */
|
|
@@ -10409,10 +10804,44 @@ async function renderGroupedPdfTable(block, context) {
|
|
|
10409
10804
|
const continuationLabels = new WeakMap();
|
|
10410
10805
|
let pending;
|
|
10411
10806
|
const closing = [];
|
|
10412
|
-
const
|
|
10807
|
+
const aggregatePositions = report.columns.flatMap((column, index) => Object.hasOwn(report.totals, column.key) ? [index] : []);
|
|
10808
|
+
const summaryValues = (label, values, positions) => Object.freeze([
|
|
10413
10809
|
new ExportCell(label, { text: label, presentation: table.options.footerPresentation }),
|
|
10414
|
-
...values.map(value => new ExportCell(value, { presentation: table.options.footerPresentation }))
|
|
10810
|
+
...(positions ? positions.map(index => values[index]) : values).map(value => new ExportCell(value, { presentation: table.options.footerPresentation }))
|
|
10415
10811
|
]);
|
|
10812
|
+
// Independent summaries have no detail values in non-aggregate columns. Project their
|
|
10813
|
+
// declared operations, including zero/null results, rather than emitting label-only bands.
|
|
10814
|
+
// Keep callback positions in the original source model after this physical projection.
|
|
10815
|
+
const summaryLayouts = new Map();
|
|
10816
|
+
const summaryLayout = (grand) => {
|
|
10817
|
+
const existing = summaryLayouts.get(grand);
|
|
10818
|
+
if (existing)
|
|
10819
|
+
return existing;
|
|
10820
|
+
const positions = [0, ...aggregatePositions.map(index => index + 1)];
|
|
10821
|
+
const projected = positions.map(position => {
|
|
10822
|
+
const column = columns[position];
|
|
10823
|
+
if (!grand)
|
|
10824
|
+
return column;
|
|
10825
|
+
const { groups: _groups, ...leaf } = column;
|
|
10826
|
+
return leaf;
|
|
10827
|
+
});
|
|
10828
|
+
const originalPosition = (position) => {
|
|
10829
|
+
const columnIndex = positions[position.columnIndex];
|
|
10830
|
+
return { ...position, columnIndex, column: columns[columnIndex] };
|
|
10831
|
+
};
|
|
10832
|
+
const repeatColumns = positions.flatMap((position, index) => position === 0 || table.repeatedColumns.includes(position) ? [index] : []);
|
|
10833
|
+
const wideTable = table.options.wideTable;
|
|
10834
|
+
const projectedSettings = { ...sharedTable,
|
|
10835
|
+
repeatedColumns: Object.freeze(repeatColumns), options: { ...table.options, columns: projected,
|
|
10836
|
+
...(table.options.columnWidths === undefined ? {} : { columnWidths: positions.map(position => table.options.columnWidths[position]) }),
|
|
10837
|
+
...(typeof wideTable !== "object" ? {} : { wideTable: { ...wideTable, repeatColumns } }),
|
|
10838
|
+
...(table.options.formatValue === undefined ? {} : { formatValue: (value, position) => table.options.formatValue(value, originalPosition(position)) }),
|
|
10839
|
+
...(table.options.formatRuns === undefined ? {} : { formatRuns: (value, position) => table.options.formatRuns(value, originalPosition(position)) })
|
|
10840
|
+
} };
|
|
10841
|
+
const projectedLayout = new PdfTableLayout(projectedSettings, fonts);
|
|
10842
|
+
summaryLayouts.set(grand, projectedLayout);
|
|
10843
|
+
return projectedLayout;
|
|
10844
|
+
};
|
|
10416
10845
|
const prepareGroupContext = async () => {
|
|
10417
10846
|
const caption = await prepareParagraph(captureCaption({ text: path.map(group => group.label).join("\n"),
|
|
10418
10847
|
presentation: { bold: true }, spaceAfter: 4 }, pages.settings, fonts), pages.settings, fonts);
|
|
@@ -10475,26 +10904,46 @@ async function renderGroupedPdfTable(block, context) {
|
|
|
10475
10904
|
...(group.label.trim() ? { bookmark: { title: group.label, level: (groupHeadingLevel + group.level) } } : {})
|
|
10476
10905
|
}, pages.settings, fonts), pages.settings, fonts));
|
|
10477
10906
|
const groupHeight = groupHeadings.reduce((height, heading) => height + heading.height, 0);
|
|
10478
|
-
|
|
10479
|
-
|
|
10907
|
+
// Newly opened semantic headings already paint the end of this path. Only the open
|
|
10908
|
+
// ancestor prefix needs an artifact here; later physical bands still paint the full path.
|
|
10909
|
+
const ancestorCaption = semantic && semanticDepth > 0 ? await prepareParagraph(captureCaption({
|
|
10910
|
+
text: path.slice(0, semanticDepth).map(group => group.label).join("\n"), presentation: { bold: true }, spaceAfter: 4
|
|
10911
|
+
}, pages.settings, fonts), pages.settings, fonts) : undefined;
|
|
10912
|
+
const openingHeight = semantic ? (ancestorCaption?.height ?? 0) + groupHeight : caption.height;
|
|
10913
|
+
await context.flushParagraphs(openingHeight + headingHeight + minimum);
|
|
10914
|
+
if (ancestorCaption)
|
|
10915
|
+
await pages.paragraphs([ancestorCaption], groupHeight + headingHeight + minimum, true, { artifact: true });
|
|
10916
|
+
let followingHeight = groupHeight + (semantic ? 0 : caption.height) + headingHeight + minimum;
|
|
10480
10917
|
for (const heading of groupHeadings) {
|
|
10481
10918
|
followingHeight -= heading.height;
|
|
10482
10919
|
await pages.beginGroup(semanticDepth++, heading, followingHeight);
|
|
10483
10920
|
}
|
|
10484
|
-
await pages.beginTable(layout, headings, minimum, caption, continuation, false, semantic);
|
|
10921
|
+
await pages.beginTable(layout, headings, minimum, caption, continuation, false, semantic, semantic);
|
|
10485
10922
|
started = true;
|
|
10486
10923
|
firstFragment = (caption?.lines.length ?? 0) > 0 || groupHeadings.some(heading => heading.lines.length > 0);
|
|
10487
10924
|
};
|
|
10488
|
-
const semanticSubtotal = async (row, level) => {
|
|
10925
|
+
const semanticSubtotal = async (row, level, values) => {
|
|
10926
|
+
if (level === report.groupBy.length - 1) {
|
|
10927
|
+
// A leaf's own subtotal shares its detail table and header identities. Keep the last
|
|
10928
|
+
// detail/summary bundle when it fits; the existing flow owns continuation and limits.
|
|
10929
|
+
pages.summary(row);
|
|
10930
|
+
closing.push(row);
|
|
10931
|
+
await finishLeaf();
|
|
10932
|
+
await pages.endGroup(level);
|
|
10933
|
+
semanticDepth = level;
|
|
10934
|
+
path = path.slice(0, level);
|
|
10935
|
+
return;
|
|
10936
|
+
}
|
|
10489
10937
|
await finishLeaf();
|
|
10490
10938
|
const { caption, continuation } = await prepareGroupContext();
|
|
10491
|
-
const
|
|
10492
|
-
await
|
|
10939
|
+
const projected = summaryLayout(false), summaryHeadings = await projected.headers();
|
|
10940
|
+
const summaryRow = await projected.data(values, 0, true), minimum = projected.minimumRowHeight(summaryRow);
|
|
10941
|
+
await context.flushParagraphs(caption.height + await projected.blockHeight(summaryHeadings) + minimum);
|
|
10493
10942
|
// An ancestor subtotal belongs to that ancestor's section, never the final child's table.
|
|
10494
10943
|
// Its own visible column headings keep the separate logical summary table truthful.
|
|
10495
|
-
await pages.beginTable(
|
|
10496
|
-
pages.summary(
|
|
10497
|
-
await pages.row(
|
|
10944
|
+
await pages.beginTable(projected, summaryHeadings, minimum, caption, continuation, false, true);
|
|
10945
|
+
pages.summary(summaryRow);
|
|
10946
|
+
await pages.row(summaryRow, caption.lines.length > 0 || summaryHeadings.length > 0);
|
|
10498
10947
|
await pages.endTable();
|
|
10499
10948
|
await pages.endGroup(level);
|
|
10500
10949
|
semanticDepth = level;
|
|
@@ -10504,25 +10953,19 @@ async function renderGroupedPdfTable(block, context) {
|
|
|
10504
10953
|
await finishLeaf();
|
|
10505
10954
|
if (!includeGrandTotal && summary.rows !== 0)
|
|
10506
10955
|
return;
|
|
10507
|
-
const
|
|
10508
|
-
const { groups: _groups, ...leaf } = column;
|
|
10509
|
-
return leaf;
|
|
10510
|
-
});
|
|
10511
|
-
const completeTable = settings({ ...table.options, columns: completeColumns,
|
|
10512
|
-
includeHeader: input.includeHeader ?? true });
|
|
10513
|
-
const completeLayout = summary.rows === 0 ? layout : new PdfTableLayout({ ...completeTable, budget: prepared.budget }, fonts);
|
|
10956
|
+
const completeLayout = summary.rows === 0 ? layout : summaryLayout(true);
|
|
10514
10957
|
const completeHeadings = summary.rows === 0 ? headings : await completeLayout.headers();
|
|
10515
10958
|
rowIndex = -1;
|
|
10516
10959
|
let total;
|
|
10517
10960
|
if (includeGrandTotal) {
|
|
10518
10961
|
context.acceptRow(false);
|
|
10519
|
-
total = await completeLayout.data(summaryValues(synchronousText(grandTotalLabel(summary), "grandTotalLabel"), summary.totals), 0, true);
|
|
10962
|
+
total = await completeLayout.data(summaryValues(synchronousText(grandTotalLabel(summary), "grandTotalLabel"), summary.totals, summary.rows === 0 ? undefined : aggregatePositions), 0, true);
|
|
10520
10963
|
}
|
|
10521
10964
|
if (!completeHeadings.length && !total)
|
|
10522
10965
|
return;
|
|
10523
10966
|
const minimum = total ? completeLayout.minimumRowHeight(total) : 0;
|
|
10524
10967
|
await context.flushParagraphs(await completeLayout.blockHeight(completeHeadings) + minimum);
|
|
10525
|
-
await pages.beginTable(completeLayout, completeHeadings, minimum
|
|
10968
|
+
await pages.beginTable(completeLayout, completeHeadings, minimum);
|
|
10526
10969
|
if (total) {
|
|
10527
10970
|
if (semantic)
|
|
10528
10971
|
pages.summary(total);
|
|
@@ -10550,9 +10993,11 @@ async function renderGroupedPdfTable(block, context) {
|
|
|
10550
10993
|
case "groupEnd": {
|
|
10551
10994
|
rowIndex = -1;
|
|
10552
10995
|
context.acceptRow(false);
|
|
10553
|
-
const
|
|
10996
|
+
const separate = semantic && event.level !== report.groupBy.length - 1;
|
|
10997
|
+
const values = summaryValues(synchronousText(subtotalLabel(event), "subtotalLabel"), event.totals, separate ? aggregatePositions : undefined);
|
|
10998
|
+
const row = separate ? undefined : await layout.data(values, 0, true);
|
|
10554
10999
|
if (semantic)
|
|
10555
|
-
await semanticSubtotal(row, event.level);
|
|
11000
|
+
await semanticSubtotal(row, event.level, values);
|
|
10556
11001
|
else
|
|
10557
11002
|
closing.push(row);
|
|
10558
11003
|
break;
|
|
@@ -10572,7 +11017,7 @@ const _exports = Object.freeze({ renderGroupedPdfTable: renderGroupedPdfTable })
|
|
|
10572
11017
|
return _exports;
|
|
10573
11018
|
})();
|
|
10574
11019
|
|
|
10575
|
-
const
|
|
11020
|
+
const _m84 = (() => {
|
|
10576
11021
|
const { BlobByteSink, withDestination } = _m3;
|
|
10577
11022
|
|
|
10578
11023
|
const { OfficeIMOError } = _m2;
|
|
@@ -10589,25 +11034,25 @@ const { settings, captureWideTable } = _m17;
|
|
|
10589
11034
|
|
|
10590
11035
|
const { pdfNumber: n } = _m60;
|
|
10591
11036
|
|
|
10592
|
-
const { PdfTableLayout } =
|
|
11037
|
+
const { PdfTableLayout } = _m69;
|
|
10593
11038
|
|
|
10594
11039
|
const { PdfWriteSession } = _m59;
|
|
10595
11040
|
|
|
10596
|
-
const { PdfDocumentImages } =
|
|
11041
|
+
const { PdfDocumentImages } = _m85;
|
|
10597
11042
|
|
|
10598
|
-
const { vectorCommands } =
|
|
11043
|
+
const { vectorCommands } = _m87;
|
|
10599
11044
|
|
|
10600
|
-
const { graphicAlternative } =
|
|
11045
|
+
const { graphicAlternative } = _m80;
|
|
10601
11046
|
|
|
10602
|
-
const { checkDrawingBlock, prepareDrawing } =
|
|
11047
|
+
const { checkDrawingBlock, prepareDrawing } = _m88;
|
|
10603
11048
|
|
|
10604
|
-
const { captureParagraph, captureCaption, prepareParagraph, checkParagraphBuffer, paragraphStartHeight } =
|
|
11049
|
+
const { captureParagraph, captureCaption, prepareParagraph, checkParagraphBuffer, paragraphStartHeight } = _m89;
|
|
10605
11050
|
|
|
10606
|
-
const { captureListOptions, prepareListItem } =
|
|
11051
|
+
const { captureListOptions, prepareListItem } = _m90;
|
|
10607
11052
|
|
|
10608
|
-
const { captureSection } =
|
|
11053
|
+
const { captureSection } = _m78;
|
|
10609
11054
|
|
|
10610
|
-
const { renderGroupedPdfTable } =
|
|
11055
|
+
const { renderGroupedPdfTable } = _m91;
|
|
10611
11056
|
|
|
10612
11057
|
const tableOptionFields = ["columns", "includeHeader", "headerRows", "footer", "headerPresentation", "footerPresentation", "alternateRowColor", "columnWidths", "wideTable", "formatValue", "formatRuns"];
|
|
10613
11058
|
/** Capture typed columns for a single-use table source in a composed document. */
|
|
@@ -10865,18 +11310,18 @@ const _exports = Object.freeze({ pdfTable: pdfTable, writePdfDocument: writePdfD
|
|
|
10865
11310
|
return _exports;
|
|
10866
11311
|
})();
|
|
10867
11312
|
|
|
10868
|
-
const
|
|
11313
|
+
const _m83 = (() => {
|
|
10869
11314
|
const { assertGroupedReportSource } = _m8;
|
|
10870
11315
|
|
|
10871
11316
|
const { BlobByteSink } = _m3;
|
|
10872
11317
|
|
|
10873
|
-
const { writePdfDocumentTo } =
|
|
11318
|
+
const { writePdfDocumentTo } = _m84;
|
|
10874
11319
|
|
|
10875
11320
|
const { pdfOptionFields } = _m17;
|
|
10876
11321
|
|
|
10877
11322
|
const { captureFields } = _m10;
|
|
10878
11323
|
|
|
10879
|
-
const { pdfGroupedTable, groupedPdfLabelFields, groupedPdfTableFields } =
|
|
11324
|
+
const { pdfGroupedTable, groupedPdfLabelFields, groupedPdfTableFields } = _m92;
|
|
10880
11325
|
|
|
10881
11326
|
|
|
10882
11327
|
|
|
@@ -10910,14 +11355,14 @@ async function writeGroupedPdfTo(report, destination, configuration) {
|
|
|
10910
11355
|
delete documentOptions.footer;
|
|
10911
11356
|
return writePdfDocumentTo([pdfGroupedTable(report, tableOptions)], destination, documentOptions);
|
|
10912
11357
|
}
|
|
10913
|
-
const _exports = Object.freeze({ pdfGroupedTable:
|
|
11358
|
+
const _exports = Object.freeze({ pdfGroupedTable: _m92.pdfGroupedTable, writeGroupedPdf: writeGroupedPdf, writeGroupedPdfTo: writeGroupedPdfTo });
|
|
10914
11359
|
return _exports;
|
|
10915
11360
|
})();
|
|
10916
11361
|
|
|
10917
|
-
const
|
|
10918
|
-
const { fontProgram } =
|
|
11362
|
+
const _m93 = (() => {
|
|
11363
|
+
const { fontProgram } = _m63;
|
|
10919
11364
|
|
|
10920
|
-
const { resolveScalar, selectFont, validateFonts } =
|
|
11365
|
+
const { resolveScalar, selectFont, validateFonts } = _m67;
|
|
10921
11366
|
|
|
10922
11367
|
/**
|
|
10923
11368
|
* Check one text run against the writer's selected font and scalar-layout rules.
|
|
@@ -10955,11 +11400,11 @@ return _exports;
|
|
|
10955
11400
|
|
|
10956
11401
|
const _m57 = (() => {
|
|
10957
11402
|
|
|
10958
|
-
const _exports = Object.freeze({ writePdf: _m58.writePdf, writePdfTo: _m58.writePdfTo, writeGroupedPdf:
|
|
11403
|
+
const _exports = Object.freeze({ writePdf: _m58.writePdf, writePdfTo: _m58.writePdfTo, writeGroupedPdf: _m83.writeGroupedPdf, writeGroupedPdfTo: _m83.writeGroupedPdfTo, pdfGroupedTable: _m83.pdfGroupedTable, createGroupedReport: _m8.createGroupedReport, writePdfDocument: _m84.writePdfDocument, writePdfDocumentTo: _m84.writePdfDocumentTo, pdfTable: _m84.pdfTable, PdfFont: _m63.PdfFont, preflightPdfText: _m93.preflightPdfText, ExportCell: _m5.ExportCell, saveBlob: _m1.saveBlob });
|
|
10959
11404
|
return _exports;
|
|
10960
11405
|
})();
|
|
10961
11406
|
|
|
10962
|
-
const
|
|
11407
|
+
const _m95 = (() => {
|
|
10963
11408
|
/** @internal Typed conversion follows declared datetime intent, never localized display text. */
|
|
10964
11409
|
function datetime(value, mode, clock) {
|
|
10965
11410
|
if (mode === "text")
|
|
@@ -10998,13 +11443,21 @@ const _exports = Object.freeze({ datetime: datetime });
|
|
|
10998
11443
|
return _exports;
|
|
10999
11444
|
})();
|
|
11000
11445
|
|
|
11001
|
-
const
|
|
11446
|
+
const _m94 = (() => {
|
|
11002
11447
|
const { ExportCell, checkAbort, inputRows } = _m1;
|
|
11003
11448
|
|
|
11004
|
-
const { datetime } =
|
|
11449
|
+
const { datetime } = _m95;
|
|
11450
|
+
|
|
11451
|
+
const { captureFields } = _m10;
|
|
11452
|
+
|
|
11453
|
+
const { copyColumns } = _m11;
|
|
11454
|
+
|
|
11455
|
+
const { copyCellPresentation } = _m5;
|
|
11005
11456
|
|
|
11457
|
+
const columnFields = ["width", "format", "wrapText", "alignment", "rowHeader", "groups"];
|
|
11006
11458
|
/** Map an immutable CanopyX record capture to a writer without querying the grid or retaining its body. */
|
|
11007
11459
|
function createCanopyExport(capture, format, options = {}) {
|
|
11460
|
+
options = captureFields(options, ["tones", "columnOptions", "unsupportedPresentation", "datetime", "xlsx", "signal", "onDiagnostic"]);
|
|
11008
11461
|
if (format !== "xlsx" && format !== "csv" && format !== "pdf")
|
|
11009
11462
|
throw new TypeError("Canopy export format must be xlsx, csv or pdf.");
|
|
11010
11463
|
if (!capture || typeof capture.rows !== "function" || !capture.request)
|
|
@@ -11047,7 +11500,7 @@ function createCanopyExport(capture, format, options = {}) {
|
|
|
11047
11500
|
const tones = new Map(Object.entries(options.tones ?? {}).map(([name, style]) => {
|
|
11048
11501
|
if (!style || typeof style !== "object" || Array.isArray(style))
|
|
11049
11502
|
throw new TypeError("Tone mappings must be portable presentation objects.");
|
|
11050
|
-
return [name,
|
|
11503
|
+
return [name, copyCellPresentation(style)];
|
|
11051
11504
|
}));
|
|
11052
11505
|
const tone = (name, rowId, columnId) => {
|
|
11053
11506
|
if (name === undefined)
|
|
@@ -11071,15 +11524,16 @@ function createCanopyExport(capture, format, options = {}) {
|
|
|
11071
11524
|
throw new TypeError("Invalid or duplicate Canopy export column.");
|
|
11072
11525
|
ids.add(column.id);
|
|
11073
11526
|
diagnostics(column.diagnostics, undefined, column.id);
|
|
11074
|
-
const
|
|
11075
|
-
for (const key of Object.keys(
|
|
11076
|
-
if (!
|
|
11527
|
+
const selected = Object.hasOwn(options.columnOptions ?? {}, column.id) ? options.columnOptions[column.id] : {};
|
|
11528
|
+
for (const key of Object.keys(selected))
|
|
11529
|
+
if (!columnFields.includes(key))
|
|
11077
11530
|
throw new TypeError("Unsupported Canopy column option: " + key);
|
|
11078
|
-
|
|
11531
|
+
const override = captureFields(selected, columnFields);
|
|
11532
|
+
const [captured] = copyColumns([{ ...override, key: column.id, header: column.title,
|
|
11079
11533
|
...(values === "raw" && column.kind === "number" ? { type: "number" } : {}),
|
|
11080
11534
|
...(override.wrapText === undefined && column.wrap === undefined ? {} : { wrapText: override.wrapText ?? column.wrap }),
|
|
11081
|
-
...(override.alignment === undefined && column.alignment === undefined ? {} : { alignment: override.alignment ?? column.alignment })
|
|
11082
|
-
|
|
11535
|
+
...(override.alignment === undefined && column.alignment === undefined ? {} : { alignment: override.alignment ?? column.alignment }) }]);
|
|
11536
|
+
return Object.freeze({ id: column.id, kind: column.kind, column: Object.freeze(captured) });
|
|
11083
11537
|
});
|
|
11084
11538
|
const rowCount = request.recordCount;
|
|
11085
11539
|
return Object.freeze({ columns: Object.freeze(specs.map(spec => spec.column)), rowCount, async *rows() {
|
|
@@ -11136,7 +11590,7 @@ const { writeCsvTo } = _m55;
|
|
|
11136
11590
|
|
|
11137
11591
|
const { writePdfTo } = _m57;
|
|
11138
11592
|
|
|
11139
|
-
const { createCanopyExport } =
|
|
11593
|
+
const { createCanopyExport } = _m94;
|
|
11140
11594
|
|
|
11141
11595
|
|
|
11142
11596
|
|
|
@@ -11178,7 +11632,7 @@ async function exportCanopy(capture, format, options = {}) {
|
|
|
11178
11632
|
throw error;
|
|
11179
11633
|
}
|
|
11180
11634
|
}
|
|
11181
|
-
const _exports = Object.freeze({ createCanopyExport:
|
|
11635
|
+
const _exports = Object.freeze({ createCanopyExport: _m94.createCanopyExport, ExportCell: _m5.ExportCell, PdfFont: _m63.PdfFont, writeCanopyTo: writeCanopyTo, exportCanopy: exportCanopy });
|
|
11182
11636
|
return _exports;
|
|
11183
11637
|
})();
|
|
11184
11638
|
const { createCanopyExport, ExportCell, PdfFont, writeCanopyTo, exportCanopy } = _m0;
|