@evotecit/officeimo 0.1.1 → 0.1.3
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 +43 -49
- package/bundles/officeimo-canopyx.js +1047 -193
- package/bundles/officeimo-canopyx.mjs +958 -111
- package/bundles/officeimo-csv.js +18 -15
- package/bundles/officeimo-csv.mjs +16 -13
- package/bundles/officeimo-datatables.js +249 -153
- package/bundles/officeimo-datatables.mjs +169 -73
- package/bundles/officeimo-pdf.js +151 -67
- package/bundles/officeimo-pdf.mjs +127 -43
- package/bundles/officeimo-xlsx.js +78 -69
- package/bundles/officeimo-xlsx.mjs +26 -17
- package/bundles/officeimo.js +249 -153
- package/bundles/officeimo.mjs +169 -73
- package/dist/csv/index.js +16 -13
- package/dist/integrations/canopyx/diagnostics.d.ts +3 -0
- package/dist/integrations/canopyx/diagnostics.js +17 -0
- package/dist/integrations/canopyx/grouping.d.ts +6 -0
- package/dist/integrations/canopyx/grouping.js +188 -0
- package/dist/integrations/canopyx/index.d.ts +2 -2
- package/dist/integrations/canopyx/index.js +72 -15
- package/dist/integrations/canopyx/metadata.d.ts +4 -0
- package/dist/integrations/canopyx/metadata.js +51 -0
- package/dist/integrations/canopyx/presentation.d.ts +8 -0
- package/dist/integrations/canopyx/presentation.js +40 -0
- package/dist/integrations/canopyx/rule-predicates.d.ts +3 -0
- package/dist/integrations/canopyx/rule-predicates.js +110 -0
- package/dist/integrations/canopyx/rules.d.ts +6 -0
- package/dist/integrations/canopyx/rules.js +176 -0
- package/dist/integrations/canopyx/source.js +24 -22
- package/dist/integrations/canopyx/types.d.ts +89 -8
- package/dist/integrations/canopyx/workbook.d.ts +6 -0
- package/dist/integrations/canopyx/workbook.js +52 -0
- package/dist/opc/index.js +14 -9
- package/dist/pdf/font-resources.js +33 -14
- package/dist/pdf/pages.js +63 -16
- package/dist/pdf/table-band-flow.js +7 -2
- package/dist/pdf/table-band-plan.js +9 -1
- package/dist/pdf/table-layout.js +6 -2
- package/dist/pdf/table-structure.js +9 -8
- package/dist/xlsx/workbook.js +7 -4
- package/dist/xlsx/worksheet.js +2 -1
- package/dist/xml/index.js +3 -3
- package/package.json +1 -1
package/bundles/officeimo-pdf.js
CHANGED
|
@@ -2352,7 +2352,7 @@ _modules.set("59911f0fe023545e9e97521b268551078bdc4c5f303e446a13b7d52f905e8070",
|
|
|
2352
2352
|
return _exports;
|
|
2353
2353
|
})();
|
|
2354
2354
|
|
|
2355
|
-
const _m21 = _modules.get("
|
|
2355
|
+
const _m21 = _modules.get("4d4736e6b8e2aaecc6f6c1b124b7e6bc0a5e141dcc725edf0ad4847d87fca1b3") ?? (() => {
|
|
2356
2356
|
const { NotSupportedError, OfficeIMOError } = _m4;
|
|
2357
2357
|
|
|
2358
2358
|
const { fontProgram } = _m22;
|
|
@@ -2363,7 +2363,8 @@ const { pdfNumber, unicodeHex } = _m19;
|
|
|
2363
2363
|
|
|
2364
2364
|
const { checkAbort, pause, taskYieldDue } = _m3;
|
|
2365
2365
|
|
|
2366
|
-
const
|
|
2366
|
+
const hexBytes = Object.freeze(Array.from({ length: 256 }, (_, byte) => byte.toString(16).padStart(2, "0")));
|
|
2367
|
+
function cidHex(cid) { return hexBytes[cid >>> 8] + hexBytes[cid & 255]; }
|
|
2367
2368
|
class PdfFontResource {
|
|
2368
2369
|
index;
|
|
2369
2370
|
bold;
|
|
@@ -2394,12 +2395,16 @@ class PdfFontResource {
|
|
|
2394
2395
|
width(scalar) {
|
|
2395
2396
|
if (this.shared)
|
|
2396
2397
|
return this.shared.width(scalar);
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2398
|
+
if (this.program) {
|
|
2399
|
+
const existing = this.mappings.get(scalar);
|
|
2400
|
+
if (existing)
|
|
2401
|
+
return existing.width;
|
|
2402
|
+
}
|
|
2403
|
+
else {
|
|
2404
|
+
const standard = this.standardWidths.get(scalar);
|
|
2405
|
+
if (standard !== undefined)
|
|
2406
|
+
return standard;
|
|
2407
|
+
}
|
|
2403
2408
|
const resolved = resolveScalar(scalar, this.program, this.bold);
|
|
2404
2409
|
if (!resolved.supported) {
|
|
2405
2410
|
if (resolved.code === "unpaired-surrogate")
|
|
@@ -2412,7 +2417,8 @@ class PdfFontResource {
|
|
|
2412
2417
|
}
|
|
2413
2418
|
if (this.mappings.size >= 65535)
|
|
2414
2419
|
throw new OfficeIMOError("RESOURCE_LIMIT", "A PDF font supports at most 65,535 distinct Unicode scalars.");
|
|
2415
|
-
const
|
|
2420
|
+
const cid = this.mappings.size + 1;
|
|
2421
|
+
const mapping = { cid, hex: cidHex(cid), glyph: resolved.glyph, width: resolved.width, text: String.fromCodePoint(scalar) };
|
|
2416
2422
|
this.mappings.set(scalar, mapping);
|
|
2417
2423
|
return mapping.width;
|
|
2418
2424
|
}
|
|
@@ -2425,8 +2431,20 @@ class PdfFontResource {
|
|
|
2425
2431
|
let hex = "";
|
|
2426
2432
|
for (const char of text) {
|
|
2427
2433
|
const cp = char.codePointAt(0);
|
|
2428
|
-
this.
|
|
2429
|
-
|
|
2434
|
+
if (this.program) {
|
|
2435
|
+
let mapping = this.mappings.get(cp);
|
|
2436
|
+
// Layout normally registered the scalar already; validate only a newly painted scalar.
|
|
2437
|
+
if (!mapping) {
|
|
2438
|
+
this.width(cp);
|
|
2439
|
+
mapping = this.mappings.get(cp);
|
|
2440
|
+
}
|
|
2441
|
+
hex += mapping.hex;
|
|
2442
|
+
}
|
|
2443
|
+
else {
|
|
2444
|
+
if (!this.standardWidths.has(cp))
|
|
2445
|
+
this.width(cp);
|
|
2446
|
+
hex += hexBytes[standardCode(cp)];
|
|
2447
|
+
}
|
|
2430
2448
|
}
|
|
2431
2449
|
return "<" + hex + ">";
|
|
2432
2450
|
}
|
|
@@ -2441,10 +2459,11 @@ class PdfFontResource {
|
|
|
2441
2459
|
if (!mapping) {
|
|
2442
2460
|
if (this.mappings.size >= 65535)
|
|
2443
2461
|
throw new OfficeIMOError("RESOURCE_LIMIT", "A PDF font supports at most 65,535 distinct CID mappings.");
|
|
2444
|
-
|
|
2462
|
+
const cid = this.mappings.size + 1;
|
|
2463
|
+
mapping = { cid, hex: cidHex(cid), glyph, width: this.program.widths[glyph], text };
|
|
2445
2464
|
this.mappings.set(key, mapping);
|
|
2446
2465
|
}
|
|
2447
|
-
return "<" + mapping.
|
|
2466
|
+
return "<" + mapping.hex + ">";
|
|
2448
2467
|
}
|
|
2449
2468
|
async write(objects, compression) {
|
|
2450
2469
|
checkAbort(this.signal);
|
|
@@ -2493,7 +2512,7 @@ class PdfFontResource {
|
|
|
2493
2512
|
const batch = mapped.slice(i, i + 100);
|
|
2494
2513
|
cmap += batch.length + " beginbfchar\n";
|
|
2495
2514
|
for (const [, m] of batch)
|
|
2496
|
-
cmap += "<" + m.
|
|
2515
|
+
cmap += "<" + m.hex + "> <" + unicodeHex(m.text) + ">\n";
|
|
2497
2516
|
cmap += "endbfchar\n";
|
|
2498
2517
|
if (taskYieldDue())
|
|
2499
2518
|
await pause();
|
|
@@ -2544,7 +2563,7 @@ class PdfFontResources {
|
|
|
2544
2563
|
if (!found)
|
|
2545
2564
|
this.explicitSelections.set(explicit, selections);
|
|
2546
2565
|
}
|
|
2547
|
-
const key =
|
|
2566
|
+
const key = (bold ? 2 : 0) | (italic ? 1 : 0), existing = selections.get(key);
|
|
2548
2567
|
if (existing)
|
|
2549
2568
|
return existing;
|
|
2550
2569
|
const { font, syntheticBold, syntheticItalic } = explicit ? { font: explicit, syntheticBold: bold, syntheticItalic: italic } : selectFont(this.fonts, bold, italic);
|
|
@@ -2561,7 +2580,7 @@ class PdfFontResources {
|
|
|
2561
2580
|
dictionary() { return "<< " + this.resources.map(f => "/" + f.name + " " + f.object + " 0 R").join(" ") + " >>"; }
|
|
2562
2581
|
}
|
|
2563
2582
|
const _exports = Object.freeze({ PdfFontResource: PdfFontResource, PdfFontResources: PdfFontResources });
|
|
2564
|
-
_modules.set("
|
|
2583
|
+
_modules.set("4d4736e6b8e2aaecc6f6c1b124b7e6bc0a5e141dcc725edf0ad4847d87fca1b3", _exports);
|
|
2565
2584
|
return _exports;
|
|
2566
2585
|
})();
|
|
2567
2586
|
|
|
@@ -3134,7 +3153,7 @@ _modules.set("0a1c79b51ac9a164b86197239117df6497f45ca2892b423b1ec77a663ccc1c47",
|
|
|
3134
3153
|
return _exports;
|
|
3135
3154
|
})();
|
|
3136
3155
|
|
|
3137
|
-
const _m33 = _modules.get("
|
|
3156
|
+
const _m33 = _modules.get("2f40af05ba09102fe440c1d46385b64cecdd233371771796c9ae4e8d523f2cea") ?? (() => {
|
|
3138
3157
|
const { OfficeIMOError } = _m4;
|
|
3139
3158
|
|
|
3140
3159
|
const { wrapPdfText } = _m31;
|
|
@@ -3182,6 +3201,14 @@ async function projectBandRows(rows, band, widths, settings, fonts) {
|
|
|
3182
3201
|
for (const row of rows) {
|
|
3183
3202
|
const cells = [];
|
|
3184
3203
|
for (const cell of row.cells) {
|
|
3204
|
+
// Ordinary data and leaf headings keep their captured width and lines in every band.
|
|
3205
|
+
// Look up their physical position without allocating another per-row column index.
|
|
3206
|
+
if (cell.span === 1) {
|
|
3207
|
+
const first = band.columns.indexOf(cell.first);
|
|
3208
|
+
if (first >= 0)
|
|
3209
|
+
cells.push({ ...cell, source: cell.source ?? cell, first });
|
|
3210
|
+
continue;
|
|
3211
|
+
}
|
|
3185
3212
|
for (let first = 0; first < band.columns.length;) {
|
|
3186
3213
|
const source = band.columns[first];
|
|
3187
3214
|
if (source < cell.first || source >= cell.first + cell.span) {
|
|
@@ -3192,7 +3219,7 @@ async function projectBandRows(rows, band, widths, settings, fonts) {
|
|
|
3192
3219
|
while (end < band.columns.length && band.columns[end] === band.columns[end - 1] + 1 && band.columns[end] < cell.first + cell.span)
|
|
3193
3220
|
end++;
|
|
3194
3221
|
const width = band.columns.slice(first, end).reduce((sum, index) => sum + widths[index], 0);
|
|
3195
|
-
const lines =
|
|
3222
|
+
const lines = await wrapPdfText(cell.captured, fonts, settings.fontSize, width - settings.padding * 2, settings, cell.style.wrapText !== false);
|
|
3196
3223
|
cells.push({ ...cell, source: cell.source ?? cell, first, span: end - first, width, lines,
|
|
3197
3224
|
lineHeight: lines.reduce((height, line) => Math.max(height, line.lineHeight), cell.font.lineHeight(settings.fontSize)) });
|
|
3198
3225
|
first = end;
|
|
@@ -3221,11 +3248,11 @@ function alignBandBlocks(bands, settings) {
|
|
|
3221
3248
|
cells: row.cells.map(cell => ({ ...cell, height: heights.slice(index, index + (cell.rowSpan ?? 1)).reduce((sum, value) => sum + value, 0) })) })));
|
|
3222
3249
|
}
|
|
3223
3250
|
const _exports = Object.freeze({ planTableBands: planTableBands, projectBandRows: projectBandRows, alignBandBlocks: alignBandBlocks });
|
|
3224
|
-
_modules.set("
|
|
3251
|
+
_modules.set("2f40af05ba09102fe440c1d46385b64cecdd233371771796c9ae4e8d523f2cea", _exports);
|
|
3225
3252
|
return _exports;
|
|
3226
3253
|
})();
|
|
3227
3254
|
|
|
3228
|
-
const _m28 = _modules.get("
|
|
3255
|
+
const _m28 = _modules.get("ad81357e627d3100e1068a8ce521aa1c1cd65de5c6c6ab36f807a3e5da50d874") ?? (() => {
|
|
3229
3256
|
const { ExportCell } = _m7;
|
|
3230
3257
|
|
|
3231
3258
|
const { copyExportLink } = _m9;
|
|
@@ -3345,8 +3372,12 @@ class PdfTableLayout {
|
|
|
3345
3372
|
lines };
|
|
3346
3373
|
}
|
|
3347
3374
|
row(cells) {
|
|
3348
|
-
|
|
3349
|
-
|
|
3375
|
+
let lines = 1, lineHeight = this.lineHeight;
|
|
3376
|
+
for (let index = 0; index < cells.length; index++) {
|
|
3377
|
+
const cell = cells[index];
|
|
3378
|
+
lines = Math.max(lines, cell.lines.length);
|
|
3379
|
+
lineHeight = Math.max(lineHeight, cell.lineHeight);
|
|
3380
|
+
}
|
|
3350
3381
|
return { cells, lines, lineHeight, height: lines * lineHeight + this.settings.padding * 2 };
|
|
3351
3382
|
}
|
|
3352
3383
|
async headers() {
|
|
@@ -3452,11 +3483,11 @@ class PdfTableLayout {
|
|
|
3452
3483
|
}
|
|
3453
3484
|
}
|
|
3454
3485
|
const _exports = Object.freeze({ PdfTableLayout: PdfTableLayout });
|
|
3455
|
-
_modules.set("
|
|
3486
|
+
_modules.set("ad81357e627d3100e1068a8ce521aa1c1cd65de5c6c6ab36f807a3e5da50d874", _exports);
|
|
3456
3487
|
return _exports;
|
|
3457
3488
|
})();
|
|
3458
3489
|
|
|
3459
|
-
const _m35 = _modules.get("
|
|
3490
|
+
const _m35 = _modules.get("9ea74d93c18250e809a7be745444b886bcd5ec924a78e6ab004d649789db1f72") ?? (() => {
|
|
3460
3491
|
const { OfficeIMOError } = _m4;
|
|
3461
3492
|
|
|
3462
3493
|
const { checkAbort } = _m3;
|
|
@@ -3500,7 +3531,7 @@ class PdfTableBandFlow {
|
|
|
3500
3531
|
await this.flush();
|
|
3501
3532
|
}
|
|
3502
3533
|
async row(row, allowFirstFragment = false) {
|
|
3503
|
-
const { padding, fontSize, options } = this.layout.settings, minimumLines = this.layout.minimumRowLines(row), minimumHeight =
|
|
3534
|
+
const { padding, fontSize, options } = this.layout.settings, minimumLines = this.layout.minimumRowLines(row), minimumHeight = minimumLines * row.lineHeight + padding * 2;
|
|
3504
3535
|
if (minimumHeight > this.painter.firstFullCapacity + .001 || minimumHeight > this.painter.continuationCapacity + .001)
|
|
3505
3536
|
throw new RangeError("Repeated PDF identifiers must fit intact below the first and continued band headings/context.");
|
|
3506
3537
|
// Keep ordinary rows intact when they fit fresh. A kept heading/caption can deliberately
|
|
@@ -3534,9 +3565,14 @@ class PdfTableBandFlow {
|
|
|
3534
3565
|
let remaining = false;
|
|
3535
3566
|
const cells = rows[0].cells.map(cell => {
|
|
3536
3567
|
const source = this.layout.bands[index].columns[cell.first];
|
|
3537
|
-
const repeated = this.layout.repeatedColumn(source),
|
|
3568
|
+
const repeated = this.layout.repeatedColumn(source), reusable = cell.span === 1 && (cell.source?.span ?? 1) === 1 && (cell.rowSpan ?? 1) === 1 &&
|
|
3569
|
+
cell.height === undefined && first === 0 && (repeated || lines >= cell.lines.length);
|
|
3570
|
+
const visible = repeated || reusable ? cell.lines : cell.lines.slice(first, first + lines);
|
|
3538
3571
|
if (!repeated && (visible.length > 0 || cell.link !== undefined))
|
|
3539
3572
|
remaining = true;
|
|
3573
|
+
// A complete first fragment already owns these lines and their maximum font metrics.
|
|
3574
|
+
if (reusable)
|
|
3575
|
+
return cell;
|
|
3540
3576
|
const { height: _height, ...plain } = cell;
|
|
3541
3577
|
return { ...plain, lines: visible,
|
|
3542
3578
|
lineHeight: visible.reduce((value, line) => Math.max(value, line.lineHeight), cell.font.lineHeight(fontSize)),
|
|
@@ -3589,11 +3625,11 @@ class PdfTableBandFlow {
|
|
|
3589
3625
|
}
|
|
3590
3626
|
}
|
|
3591
3627
|
const _exports = Object.freeze({ PdfTableBandFlow: PdfTableBandFlow });
|
|
3592
|
-
_modules.set("
|
|
3628
|
+
_modules.set("9ea74d93c18250e809a7be745444b886bcd5ec924a78e6ab004d649789db1f72", _exports);
|
|
3593
3629
|
return _exports;
|
|
3594
3630
|
})();
|
|
3595
3631
|
|
|
3596
|
-
const _m36 = _modules.get("
|
|
3632
|
+
const _m36 = _modules.get("9deed79565a5da5009f7a01579df8d6a3f019b78eb7b17d831c7964840e9a6bf") ?? (() => {
|
|
3597
3633
|
/** @internal Source-cell identities survive page fragments and horizontal band projections.
|
|
3598
3634
|
* Only column headers and still-owned row objects remain reachable from this table owner. */
|
|
3599
3635
|
class PdfTableStructure {
|
|
@@ -3645,30 +3681,31 @@ class PdfTableStructure {
|
|
|
3645
3681
|
return row.cells.map(cell => this.cells.get(cell));
|
|
3646
3682
|
const rowId = this.structure.element("TR", parent);
|
|
3647
3683
|
this.rows.set(row, rowId);
|
|
3648
|
-
const headers = row.cells.map((cell, index) => rowHeaderIndex === undefined ? cell.rowHeader === true : index === rowHeaderIndex);
|
|
3649
3684
|
// Allocate in source order, then resolve every row header before associating even earlier data cells.
|
|
3650
3685
|
// Generated summary labels override detail roles so numeric subtotal cells never become row headers.
|
|
3651
3686
|
const ids = row.cells.map((cell, index) => {
|
|
3652
|
-
const
|
|
3687
|
+
const header = rowHeaderIndex === undefined ? cell.rowHeader === true : index === rowHeaderIndex;
|
|
3688
|
+
const id = this.structure.element(header ? "TH" : "TD", rowId);
|
|
3653
3689
|
this.cells.set(cell, id);
|
|
3654
3690
|
return id;
|
|
3655
3691
|
});
|
|
3656
|
-
|
|
3692
|
+
let rowHeaders;
|
|
3657
3693
|
for (let index = 0; index < ids.length; index++)
|
|
3658
|
-
if (
|
|
3659
|
-
rowHeaders.push(await this.structure.identifier(ids[index]));
|
|
3694
|
+
if (rowHeaderIndex === undefined ? row.cells[index].rowHeader === true : index === rowHeaderIndex)
|
|
3695
|
+
(rowHeaders ??= []).push(await this.structure.identifier(ids[index]));
|
|
3660
3696
|
for (let index = 0; index < row.cells.length; index++) {
|
|
3661
3697
|
const cell = row.cells[index];
|
|
3662
|
-
if (!rowHeaders
|
|
3698
|
+
if (!rowHeaders && cell.span === 1 && (cell.rowSpan ?? 1) === 1) {
|
|
3663
3699
|
const attributes = this.ordinaryAttributes[cell.first] ??=
|
|
3664
3700
|
await this.structure.attributeReference(this.attributeDictionary(cell, this.associations(cell)));
|
|
3665
3701
|
this.structure.setAttributes(ids[index], attributes);
|
|
3666
3702
|
continue;
|
|
3667
3703
|
}
|
|
3668
3704
|
const associations = this.associations(cell);
|
|
3669
|
-
|
|
3705
|
+
const header = rowHeaderIndex === undefined ? cell.rowHeader === true : index === rowHeaderIndex;
|
|
3706
|
+
if (!header && rowHeaders)
|
|
3670
3707
|
associations.push(...rowHeaders);
|
|
3671
|
-
this.structure.setAttributes(ids[index], this.attributes(cell, associations,
|
|
3708
|
+
this.structure.setAttributes(ids[index], this.attributes(cell, associations, header ? "Row" : undefined));
|
|
3672
3709
|
}
|
|
3673
3710
|
return ids;
|
|
3674
3711
|
}
|
|
@@ -3703,7 +3740,7 @@ class PdfTableStructure {
|
|
|
3703
3740
|
}
|
|
3704
3741
|
}
|
|
3705
3742
|
const _exports = Object.freeze({ PdfTableStructure: PdfTableStructure });
|
|
3706
|
-
_modules.set("
|
|
3743
|
+
_modules.set("9deed79565a5da5009f7a01579df8d6a3f019b78eb7b17d831c7964840e9a6bf", _exports);
|
|
3707
3744
|
return _exports;
|
|
3708
3745
|
})();
|
|
3709
3746
|
|
|
@@ -3821,7 +3858,7 @@ _modules.set("a66257a32f03d958aa57be4de9da7f80b708cebca26b5cc6404de0ee11bfe052",
|
|
|
3821
3858
|
return _exports;
|
|
3822
3859
|
})();
|
|
3823
3860
|
|
|
3824
|
-
const _m34 = _modules.get("
|
|
3861
|
+
const _m34 = _modules.get("3ed7114181be5a3066742336da574fef7f2fc04ee6dfc5e64211f3bedad4cab9") ?? (() => {
|
|
3825
3862
|
const { OfficeIMOError } = _m4;
|
|
3826
3863
|
|
|
3827
3864
|
const { checkAbort } = _m3;
|
|
@@ -3856,7 +3893,8 @@ class PdfPages {
|
|
|
3856
3893
|
outlines;
|
|
3857
3894
|
references = [];
|
|
3858
3895
|
current = 0;
|
|
3859
|
-
commands =
|
|
3896
|
+
commands = "";
|
|
3897
|
+
commandParts = [];
|
|
3860
3898
|
commandBytes = 0;
|
|
3861
3899
|
annotations = [];
|
|
3862
3900
|
hyperlinks = 0;
|
|
@@ -3874,6 +3912,12 @@ class PdfPages {
|
|
|
3874
3912
|
pendingBookmarks = [];
|
|
3875
3913
|
pageNumberWidth = 0;
|
|
3876
3914
|
colors = new Map();
|
|
3915
|
+
textFont;
|
|
3916
|
+
textSize = 0;
|
|
3917
|
+
textColor = "";
|
|
3918
|
+
textPrefix = "";
|
|
3919
|
+
rectangleLefts;
|
|
3920
|
+
rectangleColumns = [];
|
|
3877
3921
|
externalObjects = new Map();
|
|
3878
3922
|
bandFlow;
|
|
3879
3923
|
bandCellBudget = false;
|
|
@@ -3940,7 +3984,7 @@ class PdfPages {
|
|
|
3940
3984
|
}
|
|
3941
3985
|
add(command) {
|
|
3942
3986
|
this.retainPageBytes(command.length);
|
|
3943
|
-
this.commands
|
|
3987
|
+
this.commands += command;
|
|
3944
3988
|
}
|
|
3945
3989
|
retainPageBytes(length) {
|
|
3946
3990
|
this.commandBytes += length;
|
|
@@ -3960,9 +4004,17 @@ class PdfPages {
|
|
|
3960
4004
|
return this.structure ? "/Artifact << /Type /" + type + " >> BDC\n" + command + "EMC\n" : command;
|
|
3961
4005
|
}
|
|
3962
4006
|
text(text, font, size, x, baseline, foreground = "111827", element) {
|
|
3963
|
-
const n = pdfNumber
|
|
3964
|
-
|
|
3965
|
-
|
|
4007
|
+
const n = pdfNumber;
|
|
4008
|
+
if (font !== this.textFont || size !== this.textSize || foreground !== this.textColor) {
|
|
4009
|
+
const shear = font.syntheticItalic ? .213 : 0, rgb = this.rgb(foreground);
|
|
4010
|
+
// Keep one prefix, independent of report size. Resource identity includes synthetic styling.
|
|
4011
|
+
this.textPrefix = "q " + rgb + " rg " + rgb + " RG\nBT /" + font.name + " " + n(size) + " Tf " +
|
|
4012
|
+
(font.syntheticBold ? n(size * .025) + " w 2 Tr " : "0 Tr ") + "1 0 " + n(shear) + " 1 ";
|
|
4013
|
+
this.textFont = font;
|
|
4014
|
+
this.textSize = size;
|
|
4015
|
+
this.textColor = foreground;
|
|
4016
|
+
}
|
|
4017
|
+
const command = this.textPrefix + n(x) + " " + n(baseline) + " Tm " + font.encode(text) + " Tj ET Q\n";
|
|
3966
4018
|
this.add(this.structure && element !== undefined ? this.structure.mark(element) + command + "EMC\n" : this.artifact(command, "Pagination"));
|
|
3967
4019
|
}
|
|
3968
4020
|
link(link, x, bottom, width, height, element) {
|
|
@@ -3992,8 +4044,8 @@ class PdfPages {
|
|
|
3992
4044
|
for (const segment of line.segments) {
|
|
3993
4045
|
const registered = marks?.get(segment), owner = registered?.owner ?? (segment.link && this.structure && element !== undefined ? this.structure.link(element, segment.link) : element);
|
|
3994
4046
|
if (segment.glyphs) {
|
|
3995
|
-
const font = segment.font, n = pdfNumber, shear = font.syntheticItalic ? .213 : 0;
|
|
3996
|
-
let cursor = x, command = "q " +
|
|
4047
|
+
const font = segment.font, n = pdfNumber, shear = font.syntheticItalic ? .213 : 0, rgb = this.rgb(segment.color ?? "111827");
|
|
4048
|
+
let cursor = x, command = "q " + rgb + " rg " + rgb + " RG\nBT /" + font.name + " " + n(size) + " Tf " +
|
|
3997
4049
|
(font.syntheticBold ? n(size * .025) + " w 2 Tr " : "0 Tr ");
|
|
3998
4050
|
for (const glyph of segment.glyphs) {
|
|
3999
4051
|
command += "1 0 " + n(shear) + " 1 " + n(cursor + (glyph.xOffset + shear * glyph.yOffset) * size / 1000) + " " + n(baseline + glyph.yOffset * size / 1000) + " Tm " + font.encodeGlyph(glyph.id, glyph.logicalText) + " Tj\n";
|
|
@@ -4041,7 +4093,8 @@ class PdfPages {
|
|
|
4041
4093
|
this.current = this.objects.reserve();
|
|
4042
4094
|
this.references.push(this.current);
|
|
4043
4095
|
}
|
|
4044
|
-
this.commands =
|
|
4096
|
+
this.commands = "";
|
|
4097
|
+
this.commandParts = [];
|
|
4045
4098
|
this.annotations = [];
|
|
4046
4099
|
this.commandBytes = 0;
|
|
4047
4100
|
this.bodyAdded = false;
|
|
@@ -4106,7 +4159,7 @@ class PdfPages {
|
|
|
4106
4159
|
// Charge physical repeats without recapturing callbacks or making them semantic duplicates.
|
|
4107
4160
|
for (const cell of header.cells)
|
|
4108
4161
|
if (!this.bandCellBudget && this.paintedHeaderBudgetCells.has(cell.source ?? cell))
|
|
4109
|
-
this.settings.budget.cell(cell.lines.map(line => line.text).join(""));
|
|
4162
|
+
this.settings.budget.cell(this.settings.budget.limits.maxTextCharacters === undefined ? "" : cell.lines.map(line => line.text).join(""));
|
|
4110
4163
|
const elements = this.tableStructure ? header.cells.map(cell => this.tableStructure.owner(cell.source ?? cell)) : undefined;
|
|
4111
4164
|
const repeated = header.cells.map(cell => this.paintedHeaderCells.has(cell.source ?? cell));
|
|
4112
4165
|
this.draw(header, 0, header.lines, elements, repeated);
|
|
@@ -4124,14 +4177,32 @@ class PdfPages {
|
|
|
4124
4177
|
if (!this.layout)
|
|
4125
4178
|
throw new Error("A table layout is required before drawing rows.");
|
|
4126
4179
|
this.bodyAdded = true;
|
|
4127
|
-
const { padding, fontSize } = this.settings, n = pdfNumber, height = lineCount * row.lineHeight + padding * 2;
|
|
4180
|
+
const { padding, fontSize } = this.settings, n = pdfNumber, height = lineCount * row.lineHeight + padding * 2, lefts = this.layout.lefts;
|
|
4181
|
+
// One geometry token per active physical column; table/band changes release the old tokens.
|
|
4182
|
+
if (this.rectangleLefts !== lefts) {
|
|
4183
|
+
this.rectangleLefts = lefts;
|
|
4184
|
+
this.rectangleColumns = [];
|
|
4185
|
+
}
|
|
4186
|
+
let rectangleHeight, rectangleBottom = "", rectangleHeightText = "";
|
|
4128
4187
|
for (const [index, cell] of row.cells.entries()) {
|
|
4129
4188
|
if (this.bandCellBudget)
|
|
4130
|
-
this.settings.budget.cell(
|
|
4131
|
-
|
|
4189
|
+
this.settings.budget.cell(this.settings.budget.limits.maxTextCharacters === undefined ? "" :
|
|
4190
|
+
(cell.height === undefined ? cell.lines.slice(firstLine, firstLine + lineCount) : cell.lines).map(line => line.text).join(""));
|
|
4191
|
+
const x = lefts[cell.first], cellHeight = cell.height ?? height;
|
|
4192
|
+
if (cellHeight !== rectangleHeight) {
|
|
4193
|
+
rectangleBottom = n(this.y - cellHeight);
|
|
4194
|
+
rectangleHeightText = n(cellHeight);
|
|
4195
|
+
rectangleHeight = cellHeight;
|
|
4196
|
+
}
|
|
4197
|
+
let horizontal = this.rectangleColumns[cell.first];
|
|
4198
|
+
if (!horizontal || horizontal.x !== x || horizontal.width !== cell.width) {
|
|
4199
|
+
horizontal = { x, width: cell.width, left: n(x), widthText: n(cell.width) };
|
|
4200
|
+
this.rectangleColumns[cell.first] = horizontal;
|
|
4201
|
+
}
|
|
4202
|
+
const rectangle = horizontal.left + " " + rectangleBottom + " " + horizontal.widthText + " " + rectangleHeightText;
|
|
4132
4203
|
if (cell.style.background)
|
|
4133
|
-
this.add(this.artifact("q " + this.rgb(cell.style.background) + " rg " +
|
|
4134
|
-
this.add(this.artifact("q 0.82 0.85 0.89 RG 0.4 w " +
|
|
4204
|
+
this.add(this.artifact("q " + this.rgb(cell.style.background) + " rg " + rectangle + " re f Q\n"));
|
|
4205
|
+
this.add(this.artifact("q 0.82 0.85 0.89 RG 0.4 w " + rectangle + " re S Q\n"));
|
|
4135
4206
|
const element = elements?.[index], artifact = cell.semanticArtifact || repeated[index], owner = cell.link && this.structure && element !== undefined ? this.structure.link(element, cell.link) : element;
|
|
4136
4207
|
for (let line = firstLine; line < Math.min(cell.lines.length, cell.height ? cell.lines.length : firstLine + lineCount); line++) {
|
|
4137
4208
|
const text = cell.lines[line], left = cell.style.alignment === "right" ? cell.width - padding - text.width : cell.style.alignment === "center" ? (cell.width - text.width) / 2 : padding;
|
|
@@ -4141,6 +4212,7 @@ class PdfPages {
|
|
|
4141
4212
|
this.link(cell.link, x, this.y - cellHeight, cell.width, cellHeight, owner);
|
|
4142
4213
|
}
|
|
4143
4214
|
this.y -= row.structured ? row.height : height;
|
|
4215
|
+
this.sealCommands();
|
|
4144
4216
|
}
|
|
4145
4217
|
async block(rows) {
|
|
4146
4218
|
if (this.bandFlow)
|
|
@@ -4466,9 +4538,22 @@ class PdfPages {
|
|
|
4466
4538
|
marker: { line: item.marker, gap: item.markerGap, ...(label === undefined ? {} : { owner: label }) } });
|
|
4467
4539
|
await this.structure?.complete(li);
|
|
4468
4540
|
}
|
|
4541
|
+
sealCommands() {
|
|
4542
|
+
if (this.commands) {
|
|
4543
|
+
this.commandParts.push(this.commands);
|
|
4544
|
+
this.commands = "";
|
|
4545
|
+
}
|
|
4546
|
+
}
|
|
4547
|
+
takeCommands() {
|
|
4548
|
+
this.sealCommands();
|
|
4549
|
+
const content = this.commandParts.join("");
|
|
4550
|
+
// Encoding and awaited delivery own the page value; the next page starts independently.
|
|
4551
|
+
this.commandParts = [];
|
|
4552
|
+
return content;
|
|
4553
|
+
}
|
|
4469
4554
|
async finishPage() {
|
|
4470
4555
|
const contents = this.objects.reserve(), { page, options } = this.settings;
|
|
4471
|
-
await this.objects.stream(contents, this.
|
|
4556
|
+
await this.objects.stream(contents, this.takeCommands(), "", options.compression !== false);
|
|
4472
4557
|
const annotations = [];
|
|
4473
4558
|
for (const annotation of this.annotations) {
|
|
4474
4559
|
annotations.push(annotation.id);
|
|
@@ -4480,7 +4565,6 @@ class PdfPages {
|
|
|
4480
4565
|
(annotations.length ? " /Annots [" + annotations.map(id => id + " 0 R").join(" ") + "]" : "") + " >>");
|
|
4481
4566
|
if (this.structure)
|
|
4482
4567
|
await this.structure.finishPage();
|
|
4483
|
-
this.commands = [];
|
|
4484
4568
|
this.annotations = [];
|
|
4485
4569
|
this.commandBytes = 0;
|
|
4486
4570
|
this.current = 0;
|
|
@@ -4512,7 +4596,7 @@ class PdfPages {
|
|
|
4512
4596
|
}
|
|
4513
4597
|
}
|
|
4514
4598
|
const _exports = Object.freeze({ PdfPages: PdfPages });
|
|
4515
|
-
_modules.set("
|
|
4599
|
+
_modules.set("3ed7114181be5a3066742336da574fef7f2fc04ee6dfc5e64211f3bedad4cab9", _exports);
|
|
4516
4600
|
return _exports;
|
|
4517
4601
|
})();
|
|
4518
4602
|
|
|
@@ -4955,7 +5039,7 @@ _modules.set("52c78ca6833cee7e5a96b657e2c00172d550176daf2c95e742692f8416977bea",
|
|
|
4955
5039
|
return _exports;
|
|
4956
5040
|
})();
|
|
4957
5041
|
|
|
4958
|
-
const _m18 = _modules.get("
|
|
5042
|
+
const _m18 = _modules.get("afdad27eb363e8de0c3bd69ebf358860eb76f5c6fb29f43a87635807cb7fc273") ?? (() => {
|
|
4959
5043
|
const { PdfObjects, unicodeHex } = _m19;
|
|
4960
5044
|
|
|
4961
5045
|
const { PdfFontResources } = _m21;
|
|
@@ -5018,11 +5102,11 @@ class PdfWriteSession {
|
|
|
5018
5102
|
}
|
|
5019
5103
|
}
|
|
5020
5104
|
const _exports = Object.freeze({ PdfWriteSession: PdfWriteSession });
|
|
5021
|
-
_modules.set("
|
|
5105
|
+
_modules.set("afdad27eb363e8de0c3bd69ebf358860eb76f5c6fb29f43a87635807cb7fc273", _exports);
|
|
5022
5106
|
return _exports;
|
|
5023
5107
|
})();
|
|
5024
5108
|
|
|
5025
|
-
const _m1 = _modules.get("
|
|
5109
|
+
const _m1 = _modules.get("45cf9fd6b6293c1a83bc8554e1bcb5cf119f44701fbad7849f39a712cab5074b") ?? (() => {
|
|
5026
5110
|
const { BlobByteSink, withDestination } = _m2;
|
|
5027
5111
|
|
|
5028
5112
|
const { beginTask, checkAbort, consumeRows, pause, taskYieldDue } = _m3;
|
|
@@ -5087,7 +5171,7 @@ async function writePdfTo(rows, destination, configuration) {
|
|
|
5087
5171
|
});
|
|
5088
5172
|
}
|
|
5089
5173
|
const _exports = Object.freeze({ writePdf: writePdf, writePdfTo: writePdfTo });
|
|
5090
|
-
_modules.set("
|
|
5174
|
+
_modules.set("45cf9fd6b6293c1a83bc8554e1bcb5cf119f44701fbad7849f39a712cab5074b", _exports);
|
|
5091
5175
|
return _exports;
|
|
5092
5176
|
})();
|
|
5093
5177
|
|
|
@@ -6308,7 +6392,7 @@ _modules.set("d04686d2c067355dfd215333b83eb5f79f96e9e4be49f942e050f21ac0795343",
|
|
|
6308
6392
|
return _exports;
|
|
6309
6393
|
})();
|
|
6310
6394
|
|
|
6311
|
-
const _m53 = _modules.get("
|
|
6395
|
+
const _m53 = _modules.get("289fa3a052c7fbab2a3ca0fb91fb9974db709d24b7d850f1175810258f0409a0") ?? (() => {
|
|
6312
6396
|
const { assertGroupedReportSource, groupedReportOperation } = _m44;
|
|
6313
6397
|
|
|
6314
6398
|
const { consumeRows } = _m3;
|
|
@@ -6562,11 +6646,11 @@ async function renderGroupedPdfTable(block, context) {
|
|
|
6562
6646
|
}
|
|
6563
6647
|
}
|
|
6564
6648
|
const _exports = Object.freeze({ renderGroupedPdfTable: renderGroupedPdfTable });
|
|
6565
|
-
_modules.set("
|
|
6649
|
+
_modules.set("289fa3a052c7fbab2a3ca0fb91fb9974db709d24b7d850f1175810258f0409a0", _exports);
|
|
6566
6650
|
return _exports;
|
|
6567
6651
|
})();
|
|
6568
6652
|
|
|
6569
|
-
const _m45 = _modules.get("
|
|
6653
|
+
const _m45 = _modules.get("9051bf9fc3168e24b53b16c123a42816198456846003fb49191c03a18cdab904") ?? (() => {
|
|
6570
6654
|
const { BlobByteSink, withDestination } = _m2;
|
|
6571
6655
|
|
|
6572
6656
|
const { OfficeIMOError } = _m4;
|
|
@@ -6856,11 +6940,11 @@ function captureTableOptions(options) {
|
|
|
6856
6940
|
return { ...captured, ...(captured.wideTable === undefined ? {} : { wideTable: captureWideTable(captured.wideTable) }) };
|
|
6857
6941
|
}
|
|
6858
6942
|
const _exports = Object.freeze({ pdfTable: pdfTable, writePdfDocument: writePdfDocument, writePdfDocumentTo: writePdfDocumentTo });
|
|
6859
|
-
_modules.set("
|
|
6943
|
+
_modules.set("9051bf9fc3168e24b53b16c123a42816198456846003fb49191c03a18cdab904", _exports);
|
|
6860
6944
|
return _exports;
|
|
6861
6945
|
})();
|
|
6862
6946
|
|
|
6863
|
-
const _m43 = _modules.get("
|
|
6947
|
+
const _m43 = _modules.get("abe76e52ffeed11ab42477c83ddde1d1d7de28b803096436b5b23cb153af58ba") ?? (() => {
|
|
6864
6948
|
const { assertGroupedReportSource } = _m44;
|
|
6865
6949
|
|
|
6866
6950
|
const { BlobByteSink } = _m2;
|
|
@@ -6906,7 +6990,7 @@ async function writeGroupedPdfTo(report, destination, configuration) {
|
|
|
6906
6990
|
return writePdfDocumentTo([pdfGroupedTable(report, tableOptions)], destination, documentOptions);
|
|
6907
6991
|
}
|
|
6908
6992
|
const _exports = Object.freeze({ pdfGroupedTable: _m54.pdfGroupedTable, writeGroupedPdf: writeGroupedPdf, writeGroupedPdfTo: writeGroupedPdfTo });
|
|
6909
|
-
_modules.set("
|
|
6993
|
+
_modules.set("abe76e52ffeed11ab42477c83ddde1d1d7de28b803096436b5b23cb153af58ba", _exports);
|
|
6910
6994
|
return _exports;
|
|
6911
6995
|
})();
|
|
6912
6996
|
|
|
@@ -6999,10 +7083,10 @@ _modules.set("81b3d47c02b7d8443b79e02b3cfb52032d6b73d9a3fb592b777ebe028ad0ef00",
|
|
|
6999
7083
|
return _exports;
|
|
7000
7084
|
})();
|
|
7001
7085
|
|
|
7002
|
-
const _m0 = _modules.get("
|
|
7086
|
+
const _m0 = _modules.get("027aafa08408056b10d7d717d63d1f7c0ee20ecfc68213aa66feacc75ec525fe") ?? (() => {
|
|
7003
7087
|
|
|
7004
7088
|
const _exports = Object.freeze({ writePdf: _m1.writePdf, writePdfTo: _m1.writePdfTo, writeGroupedPdf: _m43.writeGroupedPdf, writeGroupedPdfTo: _m43.writeGroupedPdfTo, pdfGroupedTable: _m43.pdfGroupedTable, createGroupedReport: _m44.createGroupedReport, writePdfDocument: _m45.writePdfDocument, writePdfDocumentTo: _m45.writePdfDocumentTo, pdfTable: _m45.pdfTable, PdfFont: _m22.PdfFont, preflightPdfText: _m55.preflightPdfText, ExportCell: _m7.ExportCell, saveBlob: _m56.saveBlob });
|
|
7005
|
-
_modules.set("
|
|
7089
|
+
_modules.set("027aafa08408056b10d7d717d63d1f7c0ee20ecfc68213aa66feacc75ec525fe", _exports);
|
|
7006
7090
|
return _exports;
|
|
7007
7091
|
})();
|
|
7008
7092
|
Object.assign(officeimo, _m0, { core: _m56, pdf: _m0 });
|