@evotecit/officeimo 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +1219 -2
- package/bundles/officeimo-canopyx.js +11286 -0
- package/bundles/officeimo-canopyx.mjs +11185 -0
- package/bundles/officeimo-csv.js +1254 -0
- package/bundles/officeimo-csv.mjs +1229 -0
- package/bundles/officeimo-datatables.js +11572 -0
- package/bundles/officeimo-datatables.mjs +11470 -0
- package/bundles/officeimo-execution.js +1503 -0
- package/bundles/officeimo-execution.mjs +1479 -0
- package/bundles/officeimo-pdf.js +6564 -0
- package/bundles/officeimo-pdf.mjs +6502 -0
- package/bundles/officeimo-xlsx.js +5333 -0
- package/bundles/officeimo-xlsx.mjs +5279 -0
- package/bundles/officeimo.js +11022 -0
- package/bundles/officeimo.mjs +10924 -0
- package/dist/core/dates.d.ts +1 -0
- package/dist/core/dates.js +16 -0
- package/dist/core/errors.d.ts +12 -0
- package/dist/core/errors.js +31 -0
- package/dist/core/grouped-report.d.ts +87 -0
- package/dist/core/grouped-report.js +252 -0
- package/dist/core/index.d.ts +72 -0
- package/dist/core/index.js +37 -0
- package/dist/core/iteration.d.ts +7 -0
- package/dist/core/iteration.js +149 -0
- package/dist/core/limits.d.ts +7 -0
- package/dist/core/limits.js +56 -0
- package/dist/core/links.d.ts +5 -0
- package/dist/core/links.js +14 -0
- package/dist/core/presentation.d.ts +29 -0
- package/dist/core/presentation.js +59 -0
- package/dist/core/progress.d.ts +1 -0
- package/dist/core/progress.js +10 -0
- package/dist/core/sinks.d.ts +33 -0
- package/dist/core/sinks.js +101 -0
- package/dist/core/table.d.ts +8 -0
- package/dist/core/table.js +1 -0
- package/dist/core/value-text.d.ts +7 -0
- package/dist/core/value-text.js +13 -0
- package/dist/csv/index.d.ts +44 -0
- package/dist/csv/index.js +133 -0
- package/dist/csv/options.d.ts +1 -0
- package/dist/csv/options.js +8 -0
- package/dist/csv/structured-rows.d.ts +3 -0
- package/dist/csv/structured-rows.js +15 -0
- package/dist/execution/host.d.ts +5 -0
- package/dist/execution/host.js +164 -0
- package/dist/execution/index.d.ts +3 -0
- package/dist/execution/index.js +2 -0
- package/dist/execution/protocol.d.ts +48 -0
- package/dist/execution/protocol.js +173 -0
- package/dist/execution/types.d.ts +42 -0
- package/dist/execution/types.js +1 -0
- package/dist/execution/worker.d.ts +3 -0
- package/dist/execution/worker.js +147 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +14 -0
- package/dist/integrations/canopyx/dates.d.ts +1 -0
- package/dist/integrations/canopyx/dates.js +34 -0
- package/dist/integrations/canopyx/index.d.ts +10 -0
- package/dist/integrations/canopyx/index.js +45 -0
- package/dist/integrations/canopyx/source.d.ts +3 -0
- package/dist/integrations/canopyx/source.js +116 -0
- package/dist/integrations/canopyx/types.d.ts +83 -0
- package/dist/integrations/canopyx/types.js +1 -0
- package/dist/integrations/datatables/api.d.ts +1 -0
- package/dist/integrations/datatables/api.js +27 -0
- package/dist/integrations/datatables/headings.d.ts +1 -0
- package/dist/integrations/datatables/headings.js +65 -0
- package/dist/integrations/datatables/index.d.ts +12 -0
- package/dist/integrations/datatables/index.js +167 -0
- package/dist/integrations/datatables/snapshot.d.ts +3 -0
- package/dist/integrations/datatables/snapshot.js +206 -0
- package/dist/integrations/datatables/types.d.ts +98 -0
- package/dist/integrations/datatables/types.js +1 -0
- package/dist/integrations/options.d.ts +13 -0
- package/dist/integrations/options.js +34 -0
- package/dist/internal/capture.d.ts +4 -0
- package/dist/internal/capture.js +14 -0
- package/dist/internal/columns.d.ts +27 -0
- package/dist/internal/columns.js +1 -0
- package/dist/internal/crc32.d.ts +6 -0
- package/dist/internal/crc32.js +17 -0
- package/dist/internal/export-values.d.ts +3 -0
- package/dist/internal/export-values.js +14 -0
- package/dist/internal/rows.d.ts +6 -0
- package/dist/internal/rows.js +68 -0
- package/dist/internal/table-spans.d.ts +11 -0
- package/dist/internal/table-spans.js +58 -0
- package/dist/internal/totals.d.ts +15 -0
- package/dist/internal/totals.js +42 -0
- package/dist/opc/index.d.ts +67 -0
- package/dist/opc/index.js +233 -0
- package/dist/opc/properties.d.ts +15 -0
- package/dist/opc/properties.js +18 -0
- package/dist/opc/uri.d.ts +5 -0
- package/dist/opc/uri.js +41 -0
- package/dist/pdf/annotations.d.ts +1 -0
- package/dist/pdf/annotations.js +38 -0
- package/dist/pdf/binary.d.ts +6 -0
- package/dist/pdf/binary.js +24 -0
- package/dist/pdf/document-drawings.d.ts +15 -0
- package/dist/pdf/document-drawings.js +237 -0
- package/dist/pdf/document-grouped.d.ts +1 -0
- package/dist/pdf/document-grouped.js +194 -0
- package/dist/pdf/document-images.d.ts +19 -0
- package/dist/pdf/document-images.js +125 -0
- package/dist/pdf/document-types.d.ts +160 -0
- package/dist/pdf/document-types.js +1 -0
- package/dist/pdf/document-vectors.d.ts +11 -0
- package/dist/pdf/document-vectors.js +77 -0
- package/dist/pdf/document.d.ts +9 -0
- package/dist/pdf/document.js +270 -0
- package/dist/pdf/drawing-types.d.ts +53 -0
- package/dist/pdf/drawing-types.js +1 -0
- package/dist/pdf/font-resources.d.ts +43 -0
- package/dist/pdf/font-resources.js +201 -0
- package/dist/pdf/font-support.d.ts +1 -0
- package/dist/pdf/font-support.js +60 -0
- package/dist/pdf/font.d.ts +17 -0
- package/dist/pdf/font.js +56 -0
- package/dist/pdf/grouped-table.d.ts +6 -0
- package/dist/pdf/grouped-table.js +40 -0
- package/dist/pdf/grouped-types.d.ts +34 -0
- package/dist/pdf/grouped-types.js +1 -0
- package/dist/pdf/grouped.d.ts +10 -0
- package/dist/pdf/grouped.js +37 -0
- package/dist/pdf/index.d.ts +22 -0
- package/dist/pdf/index.js +8 -0
- package/dist/pdf/inline-text.d.ts +30 -0
- package/dist/pdf/inline-text.js +142 -0
- package/dist/pdf/inline-types.d.ts +15 -0
- package/dist/pdf/inline-types.js +1 -0
- package/dist/pdf/list-layout.d.ts +6 -0
- package/dist/pdf/list-layout.js +49 -0
- package/dist/pdf/objects.d.ts +2 -0
- package/dist/pdf/objects.js +143 -0
- package/dist/pdf/outlines.d.ts +1 -0
- package/dist/pdf/outlines.js +55 -0
- package/dist/pdf/page-context.d.ts +1 -0
- package/dist/pdf/page-context.js +12 -0
- package/dist/pdf/pages.d.ts +1 -0
- package/dist/pdf/pages.js +679 -0
- package/dist/pdf/paragraph-layout.d.ts +19 -0
- package/dist/pdf/paragraph-layout.js +66 -0
- package/dist/pdf/paragraph-styles.d.ts +1 -0
- package/dist/pdf/paragraph-styles.js +66 -0
- package/dist/pdf/png.d.ts +9 -0
- package/dist/pdf/png.js +259 -0
- package/dist/pdf/preflight.d.ts +7 -0
- package/dist/pdf/preflight.js +32 -0
- package/dist/pdf/presentation-settings.d.ts +5 -0
- package/dist/pdf/presentation-settings.js +28 -0
- package/dist/pdf/providers/harfbuzz.d.ts +60 -0
- package/dist/pdf/providers/harfbuzz.js +112 -0
- package/dist/pdf/providers/unicode13-profile.d.ts +2 -0
- package/dist/pdf/providers/unicode13-profile.js +115 -0
- package/dist/pdf/section-types.d.ts +15 -0
- package/dist/pdf/section-types.js +40 -0
- package/dist/pdf/session.d.ts +25 -0
- package/dist/pdf/session.js +55 -0
- package/dist/pdf/settings.d.ts +15 -0
- package/dist/pdf/settings.js +171 -0
- package/dist/pdf/shaped-text.d.ts +5 -0
- package/dist/pdf/shaped-text.js +205 -0
- package/dist/pdf/standard-widths.d.ts +1 -0
- package/dist/pdf/standard-widths.js +317 -0
- package/dist/pdf/structure-parent-tree.d.ts +1 -0
- package/dist/pdf/structure-parent-tree.js +57 -0
- package/dist/pdf/structure.d.ts +6 -0
- package/dist/pdf/structure.js +250 -0
- package/dist/pdf/table-band-flow.d.ts +34 -0
- package/dist/pdf/table-band-flow.js +114 -0
- package/dist/pdf/table-band-plan.d.ts +10 -0
- package/dist/pdf/table-band-plan.js +85 -0
- package/dist/pdf/table-layout.d.ts +71 -0
- package/dist/pdf/table-layout.js +205 -0
- package/dist/pdf/table-structure.d.ts +1 -0
- package/dist/pdf/table-structure.js +92 -0
- package/dist/pdf/text-shaping-types.d.ts +39 -0
- package/dist/pdf/text-shaping-types.js +1 -0
- package/dist/pdf/text.d.ts +13 -0
- package/dist/pdf/text.js +96 -0
- package/dist/pdf/truetype-subset.d.ts +5 -0
- package/dist/pdf/truetype-subset.js +217 -0
- package/dist/pdf/truetype.d.ts +1 -0
- package/dist/pdf/truetype.js +235 -0
- package/dist/pdf/types.d.ts +169 -0
- package/dist/pdf/types.js +1 -0
- package/dist/pdf/write.d.ts +6 -0
- package/dist/pdf/write.js +57 -0
- package/dist/xlsx/attachments.d.ts +30 -0
- package/dist/xlsx/attachments.js +67 -0
- package/dist/xlsx/chart-bindings.d.ts +1 -0
- package/dist/xlsx/chart-bindings.js +122 -0
- package/dist/xlsx/chart-types.d.ts +73 -0
- package/dist/xlsx/chart-types.js +1 -0
- package/dist/xlsx/chart-xml.d.ts +2 -0
- package/dist/xlsx/chart-xml.js +103 -0
- package/dist/xlsx/charts.d.ts +1 -0
- package/dist/xlsx/charts.js +159 -0
- package/dist/xlsx/conditional-formatting.d.ts +1 -0
- package/dist/xlsx/conditional-formatting.js +158 -0
- package/dist/xlsx/conditional-types.d.ts +64 -0
- package/dist/xlsx/conditional-types.js +1 -0
- package/dist/xlsx/data-row-ranges.d.ts +5 -0
- package/dist/xlsx/data-row-ranges.js +39 -0
- package/dist/xlsx/differential-styles.d.ts +1 -0
- package/dist/xlsx/differential-styles.js +102 -0
- package/dist/xlsx/formula.d.ts +8 -0
- package/dist/xlsx/formula.js +104 -0
- package/dist/xlsx/grouped-layout.d.ts +61 -0
- package/dist/xlsx/grouped-layout.js +79 -0
- package/dist/xlsx/grouped.d.ts +16 -0
- package/dist/xlsx/grouped.js +161 -0
- package/dist/xlsx/index.d.ts +24 -0
- package/dist/xlsx/index.js +10 -0
- package/dist/xlsx/layout.d.ts +1 -0
- package/dist/xlsx/layout.js +186 -0
- package/dist/xlsx/options.d.ts +1 -0
- package/dist/xlsx/options.js +16 -0
- package/dist/xlsx/portable.d.ts +27 -0
- package/dist/xlsx/portable.js +44 -0
- package/dist/xlsx/preservation.d.ts +1 -0
- package/dist/xlsx/preservation.js +60 -0
- package/dist/xlsx/ranges.d.ts +1 -0
- package/dist/xlsx/ranges.js +24 -0
- package/dist/xlsx/regions.d.ts +1 -0
- package/dist/xlsx/regions.js +97 -0
- package/dist/xlsx/structured-rows.d.ts +11 -0
- package/dist/xlsx/structured-rows.js +28 -0
- package/dist/xlsx/style-xml.d.ts +1 -0
- package/dist/xlsx/style-xml.js +6 -0
- package/dist/xlsx/styles.d.ts +70 -0
- package/dist/xlsx/styles.js +203 -0
- package/dist/xlsx/table.d.ts +12 -0
- package/dist/xlsx/table.js +35 -0
- package/dist/xlsx/types.d.ts +180 -0
- package/dist/xlsx/types.js +1 -0
- package/dist/xlsx/validation-types.d.ts +18 -0
- package/dist/xlsx/validation-types.js +1 -0
- package/dist/xlsx/validation.d.ts +1 -0
- package/dist/xlsx/validation.js +92 -0
- package/dist/xlsx/values.d.ts +13 -0
- package/dist/xlsx/values.js +86 -0
- package/dist/xlsx/workbook.d.ts +50 -0
- package/dist/xlsx/workbook.js +452 -0
- package/dist/xlsx/worksheet.d.ts +71 -0
- package/dist/xlsx/worksheet.js +700 -0
- package/dist/xlsx/write.d.ts +15 -0
- package/dist/xlsx/write.js +47 -0
- package/dist/xml/index.d.ts +24 -0
- package/dist/xml/index.js +74 -0
- package/dist/zip/entry.d.ts +39 -0
- package/dist/zip/entry.js +122 -0
- package/dist/zip/index.d.ts +44 -0
- package/dist/zip/index.js +248 -0
- package/package.json +104 -4
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { OfficeIMOError } from "../core/errors.js";
|
|
2
|
+
import { checkAbort } from "../core/iteration.js";
|
|
3
|
+
import { unicodeHex } from "./objects.js";
|
|
4
|
+
import { PdfParentTree } from "./structure-parent-tree.js";
|
|
5
|
+
/** A sorted name tree retains only a small open leaf and branch at each level. */
|
|
6
|
+
class PdfStructureIds {
|
|
7
|
+
objects;
|
|
8
|
+
root;
|
|
9
|
+
entries = [];
|
|
10
|
+
levels = [];
|
|
11
|
+
lastKey = "";
|
|
12
|
+
constructor(objects, root) {
|
|
13
|
+
this.objects = objects;
|
|
14
|
+
this.root = root;
|
|
15
|
+
}
|
|
16
|
+
async append(key, value) {
|
|
17
|
+
if (key <= this.lastKey)
|
|
18
|
+
throw new Error("PDF structure IDs must be appended in increasing order.");
|
|
19
|
+
this.lastKey = key;
|
|
20
|
+
this.entries.push({ key, value });
|
|
21
|
+
if (this.entries.length === 64)
|
|
22
|
+
await this.leaf();
|
|
23
|
+
}
|
|
24
|
+
async leaf() {
|
|
25
|
+
if (!this.entries.length)
|
|
26
|
+
return;
|
|
27
|
+
const id = this.objects.reserve(), first = this.entries[0].key, last = this.entries.at(-1).key;
|
|
28
|
+
const body = "<< /Limits [(" + first + ") (" + last + ")] /Names [" +
|
|
29
|
+
this.entries.map(entry => "(" + entry.key + ") " + entry.value + " 0 R").join(" ") + "] >>";
|
|
30
|
+
this.entries.length = 0;
|
|
31
|
+
await this.objects.object(id, body);
|
|
32
|
+
await this.node({ id, first, last }, 0);
|
|
33
|
+
}
|
|
34
|
+
async node(node, level) {
|
|
35
|
+
const nodes = this.levels[level] ??= [];
|
|
36
|
+
nodes.push(node);
|
|
37
|
+
if (nodes.length === 64) {
|
|
38
|
+
const parent = await this.branch(nodes);
|
|
39
|
+
nodes.length = 0;
|
|
40
|
+
await this.node(parent, level + 1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async branch(nodes) {
|
|
44
|
+
const id = this.objects.reserve(), first = nodes[0].first, last = nodes.at(-1).last;
|
|
45
|
+
await this.objects.object(id, "<< /Limits [(" + first + ") (" + last + ")] /Kids [" +
|
|
46
|
+
nodes.map(node => node.id + " 0 R").join(" ") + "] >>");
|
|
47
|
+
return { id, first, last };
|
|
48
|
+
}
|
|
49
|
+
async finish() {
|
|
50
|
+
await this.leaf();
|
|
51
|
+
for (let level = 0; level < this.levels.length - 1; level++) {
|
|
52
|
+
const nodes = this.levels[level];
|
|
53
|
+
if (nodes.length) {
|
|
54
|
+
const parent = await this.branch(nodes);
|
|
55
|
+
nodes.length = 0;
|
|
56
|
+
await this.node(parent, level + 1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const nodes = this.levels.at(-1) ?? [];
|
|
60
|
+
await this.objects.object(this.root, nodes.length ? "<< /Kids [" + nodes.map(node => node.id + " 0 R").join(" ") + "] >>" : "<< /Names [] >>");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** @internal Only open logical elements retain content; completed subtrees retain compact parent references. */
|
|
64
|
+
export class PdfStructure {
|
|
65
|
+
objects;
|
|
66
|
+
settings;
|
|
67
|
+
root;
|
|
68
|
+
document;
|
|
69
|
+
parentTree;
|
|
70
|
+
elements = new Map();
|
|
71
|
+
parentTreeWriter;
|
|
72
|
+
annotations = [];
|
|
73
|
+
links = new WeakMap();
|
|
74
|
+
identifiers;
|
|
75
|
+
pageParents = [];
|
|
76
|
+
pageId = 0;
|
|
77
|
+
pageKey = 0;
|
|
78
|
+
nextParentKey = 0;
|
|
79
|
+
references = 0;
|
|
80
|
+
allocated = 0;
|
|
81
|
+
section;
|
|
82
|
+
constructor(objects, settings) {
|
|
83
|
+
this.objects = objects;
|
|
84
|
+
this.settings = settings;
|
|
85
|
+
this.root = objects.reserve();
|
|
86
|
+
this.parentTree = objects.reserve();
|
|
87
|
+
this.parentTreeWriter = new PdfParentTree(objects, this.parentTree);
|
|
88
|
+
this.document = this.element("Document", this.root);
|
|
89
|
+
}
|
|
90
|
+
element(role, parent = this.section ?? this.document, attributes = "") {
|
|
91
|
+
checkAbort(this.settings.options.signal);
|
|
92
|
+
if (++this.allocated > this.settings.limits.maxStructureElements)
|
|
93
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "maxStructureElements exceeded.");
|
|
94
|
+
const id = this.objects.reserve(), element = { id, parent, role, children: [], attributes, linkIdentities: [] };
|
|
95
|
+
this.elements.set(id, element);
|
|
96
|
+
const owner = this.elements.get(parent);
|
|
97
|
+
// A continuation-only linked caption is discovered during painting, after rows may exist.
|
|
98
|
+
// Its one logical Caption still precedes the Table's rows; other owners retain source order.
|
|
99
|
+
if (role === "Caption" && owner?.role === "Table")
|
|
100
|
+
owner.children.unshift(id);
|
|
101
|
+
else
|
|
102
|
+
owner?.children.push(id);
|
|
103
|
+
return id;
|
|
104
|
+
}
|
|
105
|
+
/** Flat visual sections share the same logical Document and cumulative resource policy. */
|
|
106
|
+
async beginSection() {
|
|
107
|
+
await this.complete(this.section);
|
|
108
|
+
this.section = this.element("Sect", this.document);
|
|
109
|
+
}
|
|
110
|
+
/** Register an explicit header identity in allocation order, without retaining completed headers. */
|
|
111
|
+
async identifier(elementId) {
|
|
112
|
+
checkAbort(this.settings.options.signal);
|
|
113
|
+
const element = this.elements.get(elementId);
|
|
114
|
+
if (!element)
|
|
115
|
+
throw new Error("PDF structure IDs require an open logical owner.");
|
|
116
|
+
if (element.identifier !== undefined)
|
|
117
|
+
return element.identifier;
|
|
118
|
+
// Object numbers increase monotonically. Fixed-width ASCII preserves name-tree lexical ordering.
|
|
119
|
+
const identifier = "e" + String(elementId).padStart(16, "0");
|
|
120
|
+
this.identifiers ??= new PdfStructureIds(this.objects, this.objects.reserve());
|
|
121
|
+
await this.identifiers.append(identifier, elementId);
|
|
122
|
+
element.identifier = identifier;
|
|
123
|
+
return identifier;
|
|
124
|
+
}
|
|
125
|
+
beginPage(pageId) { this.pageId = pageId; this.pageParents = []; this.pageKey = this.nextParentKey++; }
|
|
126
|
+
/** A source link retains one logical identity when its text/annotation continues on another page. */
|
|
127
|
+
link(parent, identity, alternativeText) {
|
|
128
|
+
let parents = this.links.get(identity);
|
|
129
|
+
if (!parents) {
|
|
130
|
+
parents = new Map();
|
|
131
|
+
this.links.set(identity, parents);
|
|
132
|
+
}
|
|
133
|
+
const existing = parents.get(parent);
|
|
134
|
+
if (existing !== undefined)
|
|
135
|
+
return existing;
|
|
136
|
+
const id = this.element("Link", parent, alternativeText === undefined ? "" : " /Alt <feff" + unicodeHex(alternativeText) + ">");
|
|
137
|
+
parents.set(parent, id);
|
|
138
|
+
this.elements.get(parent).linkIdentities.push(identity);
|
|
139
|
+
return id;
|
|
140
|
+
}
|
|
141
|
+
/** Associate a native annotation in both directions: OBJR child and annotation ParentTree entry. */
|
|
142
|
+
annotation(elementId, annotationId) {
|
|
143
|
+
checkAbort(this.settings.options.signal);
|
|
144
|
+
const element = this.elements.get(elementId);
|
|
145
|
+
if (!element || element.role !== "Link")
|
|
146
|
+
throw new Error("Tagged link annotations require a logical Link owner.");
|
|
147
|
+
const key = this.nextParentKey++;
|
|
148
|
+
element.children.push("<< /Type /OBJR /Obj " + annotationId + " 0 R /Pg " + this.pageId + " 0 R >>");
|
|
149
|
+
this.annotations.push({ key, owner: elementId });
|
|
150
|
+
return key;
|
|
151
|
+
}
|
|
152
|
+
/** Every MCID is local to its page; its parent entry points back to the owning logical element. */
|
|
153
|
+
mark(elementId, actualText) {
|
|
154
|
+
if (++this.references > this.settings.limits.maxMarkedContentReferences)
|
|
155
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "maxMarkedContentReferences exceeded.");
|
|
156
|
+
const element = this.elements.get(elementId);
|
|
157
|
+
if (!element)
|
|
158
|
+
throw new Error("Marked content requires an open logical owner.");
|
|
159
|
+
const mcid = this.pageParents.length;
|
|
160
|
+
this.pageParents.push(elementId);
|
|
161
|
+
element.children.push("<< /Type /MCR /Pg " + this.pageId + " 0 R /MCID " + mcid + " >>");
|
|
162
|
+
return "/" + element.role + " << /MCID " + mcid + (actualText === undefined ? "" : " /ActualText <FEFF" + unicodeHex(actualText) + ">") + " >> BDC\n";
|
|
163
|
+
}
|
|
164
|
+
get pageDictionary() { return " /StructParents " + this.pageKey + " /Tabs /S"; }
|
|
165
|
+
get catalogDictionary() {
|
|
166
|
+
return " /MarkInfo << /Marked true >> /Lang <feff" + unicodeHex(this.settings.options.tagged.language) + "> /StructTreeRoot " + this.root + " 0 R";
|
|
167
|
+
}
|
|
168
|
+
async finishPage() {
|
|
169
|
+
const array = this.objects.reserve();
|
|
170
|
+
await this.objects.object(array, "[" + this.pageParents.map(id => id + " 0 R").join(" ") + "]");
|
|
171
|
+
await this.parentTreeWriter.append(this.pageKey, array);
|
|
172
|
+
for (const annotation of this.annotations)
|
|
173
|
+
await this.parentTreeWriter.append(annotation.key, annotation.owner);
|
|
174
|
+
this.annotations.length = 0;
|
|
175
|
+
this.pageParents = [];
|
|
176
|
+
}
|
|
177
|
+
/** Complete only after the last fragment/annotation; split content keeps the same owner until then. */
|
|
178
|
+
async complete(id) {
|
|
179
|
+
if (id === undefined)
|
|
180
|
+
return;
|
|
181
|
+
const element = this.elements.get(id);
|
|
182
|
+
if (!element)
|
|
183
|
+
return;
|
|
184
|
+
for (const child of element.children)
|
|
185
|
+
if (typeof child === "number" && this.elements.has(child))
|
|
186
|
+
await this.complete(child);
|
|
187
|
+
checkAbort(this.settings.options.signal);
|
|
188
|
+
const prefix = "<< /Type /StructElem /S /" + element.role + " /P " + element.parent + " 0 R" +
|
|
189
|
+
(element.identifier === undefined ? "" : " /ID (" + element.identifier + ")") + " /K [";
|
|
190
|
+
const remaining = 32768 - prefix.length - element.attributes.length - 4;
|
|
191
|
+
let children = "", small = remaining >= 0;
|
|
192
|
+
if (small)
|
|
193
|
+
for (const child of element.children) {
|
|
194
|
+
const token = typeof child === "number" ? child + " 0 R " : child + " ";
|
|
195
|
+
if (children.length + token.length > remaining) {
|
|
196
|
+
small = false;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
children += token;
|
|
200
|
+
}
|
|
201
|
+
// Most table cells/rows fit in one encoding. Large parents and alternatives remain streamed.
|
|
202
|
+
await this.objects.object(id, small ? prefix + children + "]" + element.attributes + " >>" : this.body(element));
|
|
203
|
+
for (const identity of element.linkIdentities) {
|
|
204
|
+
const parents = this.links.get(identity);
|
|
205
|
+
parents?.delete(id);
|
|
206
|
+
if (!parents?.size)
|
|
207
|
+
this.links.delete(identity);
|
|
208
|
+
}
|
|
209
|
+
this.elements.delete(id);
|
|
210
|
+
}
|
|
211
|
+
*body(element) {
|
|
212
|
+
yield "<< /Type /StructElem /S /" + element.role + " /P " + element.parent + " 0 R" +
|
|
213
|
+
(element.identifier === undefined ? "" : " /ID (" + element.identifier + ")") + " /K [";
|
|
214
|
+
for (const child of element.children)
|
|
215
|
+
yield typeof child === "number" ? child + " 0 R " : child + " ";
|
|
216
|
+
yield "]" + element.attributes + " >>";
|
|
217
|
+
}
|
|
218
|
+
async completeRow(cells) {
|
|
219
|
+
if (cells?.length)
|
|
220
|
+
await this.complete(this.elements.get(cells[0])?.parent);
|
|
221
|
+
}
|
|
222
|
+
async finish() {
|
|
223
|
+
await this.complete(this.document);
|
|
224
|
+
await this.parentTreeWriter.finish();
|
|
225
|
+
await this.identifiers?.finish();
|
|
226
|
+
await this.objects.object(this.root, "<< /Type /StructTreeRoot /K [" + this.document + " 0 R] /ParentTree " +
|
|
227
|
+
this.parentTree + " 0 R /ParentTreeNextKey " + this.nextParentKey +
|
|
228
|
+
(this.identifiers ? " /IDTree " + this.identifiers.root + " 0 R" : "") + " >>");
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/** Validate author intent even in untagged output so a later opt-in cannot silently change meaning. */
|
|
232
|
+
export function graphicAlternative(value, settings) {
|
|
233
|
+
const decorative = value.decorative, alternativeText = value.alternativeText;
|
|
234
|
+
if (decorative !== undefined && typeof decorative !== "boolean")
|
|
235
|
+
throw new TypeError("Graphic decorative must be boolean.");
|
|
236
|
+
if (alternativeText !== undefined) {
|
|
237
|
+
if (typeof alternativeText !== "string" || !alternativeText.trim())
|
|
238
|
+
throw new TypeError("Graphic alternativeText must be nonempty text.");
|
|
239
|
+
if (alternativeText.length > settings.limits.maxCellCharacters)
|
|
240
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "maxCellCharacters exceeded by graphic alternativeText.");
|
|
241
|
+
unicodeHex(alternativeText);
|
|
242
|
+
if (decorative)
|
|
243
|
+
throw new TypeError("A decorative graphic cannot also have alternativeText.");
|
|
244
|
+
}
|
|
245
|
+
if (settings.options.tagged && alternativeText === undefined && decorative !== true)
|
|
246
|
+
throw new TypeError("Tagged PDF graphics require alternativeText or decorative:true.");
|
|
247
|
+
if (settings.options.tagged && alternativeText !== undefined)
|
|
248
|
+
settings.budget.cell(alternativeText);
|
|
249
|
+
return alternativeText;
|
|
250
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { PdfLayoutRow, PdfTableLayout } from "./table-layout.js";
|
|
2
|
+
import type { PdfPreparedParagraph } from "./paragraph-layout.js";
|
|
3
|
+
interface BandWindowPainter {
|
|
4
|
+
prepareRow?(row: PdfLayoutRow): Promise<void>;
|
|
5
|
+
completeRow?(row: PdfLayoutRow): Promise<void>;
|
|
6
|
+
readonly firstCapacity: number;
|
|
7
|
+
readonly firstFullCapacity: number;
|
|
8
|
+
moveFirstToFreshPage(): Promise<void>;
|
|
9
|
+
readonly continuationCapacity: number;
|
|
10
|
+
paint(band: number, headers: readonly PdfLayoutRow[], rows: readonly PdfLayoutRow[], caption: PdfPreparedParagraph | undefined, firstWindow: boolean, firstBand: boolean): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
/** One source pass and one bounded window. A slow sink is awaited before accepting further source rows.
|
|
13
|
+
* Data projection, formatting and numeric totals belong to the logical layout, never the physical bands. */
|
|
14
|
+
export declare class PdfTableBandFlow {
|
|
15
|
+
private readonly layout;
|
|
16
|
+
private readonly headings;
|
|
17
|
+
private readonly painter;
|
|
18
|
+
private readonly caption?;
|
|
19
|
+
private readonly continuation?;
|
|
20
|
+
private entries;
|
|
21
|
+
private height;
|
|
22
|
+
private count;
|
|
23
|
+
private firstWindow;
|
|
24
|
+
private firstCapacity;
|
|
25
|
+
private painted;
|
|
26
|
+
constructor(layout: PdfTableLayout, headings: readonly (readonly PdfLayoutRow[])[], painter: BandWindowPainter, caption?: PdfPreparedParagraph | undefined, continuation?: PdfPreparedParagraph | undefined);
|
|
27
|
+
private get capacity();
|
|
28
|
+
private accept;
|
|
29
|
+
row(row: PdfLayoutRow, allowFirstFragment?: boolean): Promise<void>;
|
|
30
|
+
block(rows: readonly PdfLayoutRow[]): Promise<void>;
|
|
31
|
+
keptRows(rows: readonly PdfLayoutRow[], allowFirstFragment?: boolean): Promise<void>;
|
|
32
|
+
flush(forceHeadings?: boolean): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { OfficeIMOError } from "../core/errors.js";
|
|
2
|
+
import { checkAbort } from "../core/iteration.js";
|
|
3
|
+
/** One source pass and one bounded window. A slow sink is awaited before accepting further source rows.
|
|
4
|
+
* Data projection, formatting and numeric totals belong to the logical layout, never the physical bands. */
|
|
5
|
+
export class PdfTableBandFlow {
|
|
6
|
+
layout;
|
|
7
|
+
headings;
|
|
8
|
+
painter;
|
|
9
|
+
caption;
|
|
10
|
+
continuation;
|
|
11
|
+
entries = [];
|
|
12
|
+
height = 0;
|
|
13
|
+
count = 0;
|
|
14
|
+
firstWindow = true;
|
|
15
|
+
firstCapacity;
|
|
16
|
+
painted = false;
|
|
17
|
+
constructor(layout, headings, painter, caption, continuation) {
|
|
18
|
+
this.layout = layout;
|
|
19
|
+
this.headings = headings;
|
|
20
|
+
this.painter = painter;
|
|
21
|
+
this.caption = caption;
|
|
22
|
+
this.continuation = continuation;
|
|
23
|
+
this.firstCapacity = painter.firstCapacity;
|
|
24
|
+
}
|
|
25
|
+
get capacity() { return this.firstWindow ? this.firstCapacity : this.painter.continuationCapacity; }
|
|
26
|
+
async accept(entry) {
|
|
27
|
+
if (this.entries.length && (this.height + entry.height > this.capacity + .001 || this.count + entry.count > this.layout.settings.limits.maxTableWindowRows))
|
|
28
|
+
await this.flush();
|
|
29
|
+
if (this.firstWindow && !this.entries.length && entry.height > this.capacity + .001 && entry.height <= this.painter.firstFullCapacity + .001) {
|
|
30
|
+
await this.painter.moveFirstToFreshPage();
|
|
31
|
+
this.firstCapacity = this.painter.firstFullCapacity;
|
|
32
|
+
}
|
|
33
|
+
if (entry.height > this.capacity + .001)
|
|
34
|
+
throw new RangeError("PDF band window cannot fit the requested table fragment.");
|
|
35
|
+
this.entries.push(entry);
|
|
36
|
+
this.height += entry.height;
|
|
37
|
+
this.count += entry.count;
|
|
38
|
+
if (this.count >= this.layout.settings.limits.maxTableWindowRows)
|
|
39
|
+
await this.flush();
|
|
40
|
+
}
|
|
41
|
+
async row(row, allowFirstFragment = false) {
|
|
42
|
+
const { padding, options } = this.layout.settings, minimumLines = this.layout.minimumRowLines(row), minimumHeight = this.layout.minimumRowHeight(row);
|
|
43
|
+
if (minimumHeight > this.painter.firstFullCapacity + .001 || minimumHeight > this.painter.continuationCapacity + .001)
|
|
44
|
+
throw new RangeError("Repeated PDF identifiers must fit intact below the first and continued band headings/context.");
|
|
45
|
+
// Keep ordinary rows intact when they fit fresh. A kept heading/caption can deliberately
|
|
46
|
+
// retain the first fragment here instead of being orphaned by a later table-only page move.
|
|
47
|
+
if (this.entries.length && row.height <= this.painter.continuationCapacity + .001 && row.height > this.capacity - this.height + .001)
|
|
48
|
+
await this.flush();
|
|
49
|
+
if (!allowFirstFragment && this.firstWindow && !this.entries.length && row.height > this.capacity + .001 && row.height <= this.painter.firstFullCapacity + .001) {
|
|
50
|
+
await this.painter.moveFirstToFreshPage();
|
|
51
|
+
this.firstCapacity = this.painter.firstFullCapacity;
|
|
52
|
+
}
|
|
53
|
+
await this.painter.prepareRow?.(row);
|
|
54
|
+
let first = 0;
|
|
55
|
+
while (first < row.lines) {
|
|
56
|
+
checkAbort(options.signal);
|
|
57
|
+
if (this.entries.length && this.capacity - this.height + .001 < minimumHeight)
|
|
58
|
+
await this.flush();
|
|
59
|
+
if (this.firstWindow && !this.entries.length && this.capacity + .001 < minimumHeight) {
|
|
60
|
+
await this.painter.moveFirstToFreshPage();
|
|
61
|
+
this.firstCapacity = this.painter.firstFullCapacity;
|
|
62
|
+
}
|
|
63
|
+
if (this.capacity - this.height + .001 < minimumHeight)
|
|
64
|
+
throw new RangeError("PDF band window cannot fit its complete repeated identifiers.");
|
|
65
|
+
const lines = Math.min(row.lines - first, Math.floor((this.capacity - this.height - padding * 2 + .001) / row.lineHeight));
|
|
66
|
+
if (lines < 1)
|
|
67
|
+
throw new RangeError("PDF page cannot fit a table line below horizontal band headings.");
|
|
68
|
+
const paintedLines = Math.max(lines, minimumLines), height = paintedLines * row.lineHeight + padding * 2;
|
|
69
|
+
const projected = await this.layout.bandRows([row]);
|
|
70
|
+
const fragments = projected.map((rows, index) => [{ ...rows[0], lines: paintedLines, height,
|
|
71
|
+
cells: rows[0].cells.map(cell => {
|
|
72
|
+
const source = this.layout.bands[index].columns[cell.first];
|
|
73
|
+
const visible = this.layout.repeatedColumn(source) ? cell.lines : cell.lines.slice(first, first + lines);
|
|
74
|
+
const { height: _height, ...plain } = cell;
|
|
75
|
+
return { ...plain, lines: visible, ...(first > 0 && this.layout.repeatedColumn(source) ? { semanticArtifact: true } : {}) };
|
|
76
|
+
}) }]);
|
|
77
|
+
await this.accept({ rows: fragments, height, count: 1, completed: first + lines >= row.lines ? [row] : [] });
|
|
78
|
+
first += lines;
|
|
79
|
+
if (first < row.lines)
|
|
80
|
+
await this.flush();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async block(rows) {
|
|
84
|
+
const projected = await this.layout.bandRows(rows, true), height = projected[0].reduce((sum, row) => sum + row.height, 0);
|
|
85
|
+
if (rows.length > this.layout.settings.limits.maxTableWindowRows)
|
|
86
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "A structured PDF block exceeds maxTableWindowRows.");
|
|
87
|
+
for (const row of rows)
|
|
88
|
+
await this.painter.prepareRow?.(row);
|
|
89
|
+
await this.accept({ rows: projected, height, count: rows.length, completed: rows });
|
|
90
|
+
}
|
|
91
|
+
async keptRows(rows, allowFirstFragment = false) {
|
|
92
|
+
const height = rows.reduce((sum, row) => sum + row.height, 0), fits = height <= this.painter.continuationCapacity + .001;
|
|
93
|
+
if (this.entries.length && fits && height > this.capacity - this.height + .001)
|
|
94
|
+
await this.flush();
|
|
95
|
+
for (const [index, row] of rows.entries())
|
|
96
|
+
await this.row(row, !fits && index === 0 && allowFirstFragment);
|
|
97
|
+
}
|
|
98
|
+
async flush(forceHeadings = false) {
|
|
99
|
+
if (!this.entries.length && (!forceHeadings || this.painted || !this.headings.some(rows => rows.length)))
|
|
100
|
+
return;
|
|
101
|
+
for (let band = 0; band < this.layout.bands.length; band++) {
|
|
102
|
+
checkAbort(this.layout.settings.options.signal);
|
|
103
|
+
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);
|
|
104
|
+
}
|
|
105
|
+
for (const entry of this.entries)
|
|
106
|
+
for (const row of entry.completed)
|
|
107
|
+
await this.painter.completeRow?.(row);
|
|
108
|
+
this.entries = [];
|
|
109
|
+
this.height = 0;
|
|
110
|
+
this.count = 0;
|
|
111
|
+
this.firstWindow = false;
|
|
112
|
+
this.painted = true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PdfSettings } from "./settings.js";
|
|
2
|
+
import type { PdfLayoutRow } from "./table-layout.js";
|
|
3
|
+
import type { PdfFontResources } from "./font-resources.js";
|
|
4
|
+
/** Plan without opening a source. Exact column widths never shrink in band mode. */
|
|
5
|
+
export declare function planTableBands(widths: readonly number[], settings: PdfSettings): readonly PdfTableBand[] | undefined;
|
|
6
|
+
/** A span crossing a band boundary repeats its captured text at each visible intersection.
|
|
7
|
+
* Runs/formatters are never recaptured, and vertical spans retain their original row ownership. */
|
|
8
|
+
export declare function projectBandRows(rows: readonly PdfLayoutRow[], band: PdfTableBand, widths: readonly number[], settings: PdfSettings, fonts: PdfFontResources): Promise<readonly PdfLayoutRow[]>;
|
|
9
|
+
/** Equal row heights across every physical band keep structured headings and row windows aligned. */
|
|
10
|
+
export declare function alignBandBlocks(bands: readonly (readonly PdfLayoutRow[])[], settings: PdfSettings): readonly (readonly PdfLayoutRow[])[];
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { OfficeIMOError } from "../core/errors.js";
|
|
2
|
+
import { wrapPdfText } from "./inline-text.js";
|
|
3
|
+
/** Plan without opening a source. Exact column widths never shrink in band mode. */
|
|
4
|
+
export function planTableBands(widths, settings) {
|
|
5
|
+
const policy = settings.options.wideTable;
|
|
6
|
+
if (typeof policy !== "object")
|
|
7
|
+
return undefined;
|
|
8
|
+
const available = settings.page.width - settings.margins.left - settings.margins.right, repeats = policy.repeatColumns ?? [];
|
|
9
|
+
if (repeats.some(index => index >= widths.length))
|
|
10
|
+
throw new RangeError("repeatColumns index exceeds the declared columns.");
|
|
11
|
+
const repeated = new Set(repeats), rest = widths.map((_, index) => index).filter(index => !repeated.has(index));
|
|
12
|
+
const prefix = repeats.reduce((sum, index) => sum + widths[index], 0);
|
|
13
|
+
if (prefix > available + .001)
|
|
14
|
+
throw new RangeError("Repeated PDF columns exceed the printable width.");
|
|
15
|
+
const groups = [];
|
|
16
|
+
let current = [...repeats], used = prefix;
|
|
17
|
+
for (const index of rest) {
|
|
18
|
+
const width = widths[index];
|
|
19
|
+
if (prefix + width > available + .001)
|
|
20
|
+
throw new RangeError("A PDF column and its repeated identifiers cannot fit a band.");
|
|
21
|
+
if (used + width > available + .001) {
|
|
22
|
+
groups.push(current);
|
|
23
|
+
current = [...repeats];
|
|
24
|
+
used = prefix;
|
|
25
|
+
}
|
|
26
|
+
current.push(index);
|
|
27
|
+
used += width;
|
|
28
|
+
}
|
|
29
|
+
if (current.length)
|
|
30
|
+
groups.push(current);
|
|
31
|
+
if (groups.length > settings.limits.maxTableBands)
|
|
32
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "maxTableBands exceeded.");
|
|
33
|
+
if (settings.limits.maxTableWindowRows < 1)
|
|
34
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "maxTableWindowRows must allow at least one row fragment.");
|
|
35
|
+
return Object.freeze(groups.map(columns => {
|
|
36
|
+
let x = settings.margins.left;
|
|
37
|
+
const lefts = columns.map(index => { const left = x; x += widths[index]; return left; });
|
|
38
|
+
return Object.freeze({ columns: Object.freeze(columns), lefts: Object.freeze(lefts) });
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
/** A span crossing a band boundary repeats its captured text at each visible intersection.
|
|
42
|
+
* Runs/formatters are never recaptured, and vertical spans retain their original row ownership. */
|
|
43
|
+
export async function projectBandRows(rows, band, widths, settings, fonts) {
|
|
44
|
+
const result = [];
|
|
45
|
+
for (const row of rows) {
|
|
46
|
+
const cells = [];
|
|
47
|
+
for (const cell of row.cells) {
|
|
48
|
+
for (let first = 0; first < band.columns.length;) {
|
|
49
|
+
const source = band.columns[first];
|
|
50
|
+
if (source < cell.first || source >= cell.first + cell.span) {
|
|
51
|
+
first++;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
let end = first + 1;
|
|
55
|
+
while (end < band.columns.length && band.columns[end] === band.columns[end - 1] + 1 && band.columns[end] < cell.first + cell.span)
|
|
56
|
+
end++;
|
|
57
|
+
const width = band.columns.slice(first, end).reduce((sum, index) => sum + widths[index], 0);
|
|
58
|
+
const lines = cell.span === 1 ? cell.lines : await wrapPdfText(cell.captured, fonts, settings.fontSize, width - settings.padding * 2, settings, cell.style.wrapText !== false);
|
|
59
|
+
cells.push({ ...cell, source: cell.source ?? cell, first, span: end - first, width, lines,
|
|
60
|
+
lineHeight: lines.reduce((height, line) => Math.max(height, line.lineHeight), cell.font.lineHeight(settings.fontSize)) });
|
|
61
|
+
first = end;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
cells.sort((a, b) => a.first - b.first);
|
|
65
|
+
result.push({ ...row, source: row.source ?? row, cells });
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
/** Equal row heights across every physical band keep structured headings and row windows aligned. */
|
|
70
|
+
export function alignBandBlocks(bands, settings) {
|
|
71
|
+
if (!bands.length || !bands[0].length)
|
|
72
|
+
return bands;
|
|
73
|
+
const rows = bands[0].length;
|
|
74
|
+
const heights = Array.from({ length: rows }, (_, index) => Math.max(...bands.map(band => Math.max(settings.padding * 2 + band[index].lineHeight, ...band[index].cells.filter(cell => (cell.rowSpan ?? 1) === 1).map(cell => cell.lines.length * cell.lineHeight + settings.padding * 2)))));
|
|
75
|
+
for (const band of bands)
|
|
76
|
+
for (const [index, row] of band.entries())
|
|
77
|
+
for (const cell of row.cells) {
|
|
78
|
+
const span = cell.rowSpan ?? 1, height = heights.slice(index, index + span).reduce((sum, value) => sum + value, 0), needed = cell.lines.length * cell.lineHeight + settings.padding * 2;
|
|
79
|
+
if (needed > height)
|
|
80
|
+
for (let i = index; i < index + span; i++)
|
|
81
|
+
heights[i] += (needed - height) / span;
|
|
82
|
+
}
|
|
83
|
+
return bands.map(band => band.map((row, index) => ({ ...row, structured: true, height: heights[index],
|
|
84
|
+
cells: row.cells.map(cell => ({ ...cell, height: heights.slice(index, index + (cell.rowSpan ?? 1)).reduce((sum, value) => sum + value, 0) })) })));
|
|
85
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ExportLink } from "../core/links.js";
|
|
2
|
+
import type { ExportValue, CellPresentation, TableSpanRows } from "../core/index.js";
|
|
3
|
+
import type { NumericAggregate } from "../internal/totals.js";
|
|
4
|
+
import type { PdfFontResources, PdfFontResource } from "./font-resources.js";
|
|
5
|
+
import type { PdfSettings } from "./settings.js";
|
|
6
|
+
import type { PdfTableBand } from "./table-band-plan.js";
|
|
7
|
+
import type { PdfCapturedText } from "./inline-text.js";
|
|
8
|
+
import type { PdfInlineLine } from "./inline-text.js";
|
|
9
|
+
export interface PdfLayoutCell {
|
|
10
|
+
/** Original source anchor when a captured cell is projected into a physical band. */
|
|
11
|
+
readonly source?: PdfLayoutCell;
|
|
12
|
+
/** Repeated visual content has no second logical reading occurrence. */
|
|
13
|
+
readonly semanticArtifact?: boolean;
|
|
14
|
+
readonly first: number;
|
|
15
|
+
readonly span: number;
|
|
16
|
+
readonly width: number;
|
|
17
|
+
readonly font: PdfFontResource;
|
|
18
|
+
readonly style: Readonly<CellPresentation>;
|
|
19
|
+
readonly lines: readonly PdfInlineLine[];
|
|
20
|
+
readonly lineHeight: number;
|
|
21
|
+
readonly rowSpan?: number;
|
|
22
|
+
readonly height?: number;
|
|
23
|
+
readonly link?: Readonly<ExportLink>;
|
|
24
|
+
/** Captured once for band span projection; ordinary layouts do not retain it. */
|
|
25
|
+
readonly captured?: PdfCapturedText;
|
|
26
|
+
}
|
|
27
|
+
export interface PdfLayoutRow {
|
|
28
|
+
readonly cells: readonly PdfLayoutCell[];
|
|
29
|
+
readonly lines: number;
|
|
30
|
+
readonly lineHeight: number;
|
|
31
|
+
readonly height: number;
|
|
32
|
+
readonly structured?: boolean;
|
|
33
|
+
/** Original logical row retained only by its bounded physical window. */
|
|
34
|
+
readonly source?: PdfLayoutRow;
|
|
35
|
+
}
|
|
36
|
+
interface HeadingCell {
|
|
37
|
+
readonly first: number;
|
|
38
|
+
readonly span: number;
|
|
39
|
+
readonly text: string;
|
|
40
|
+
}
|
|
41
|
+
export declare class PdfTableLayout {
|
|
42
|
+
readonly settings: PdfSettings;
|
|
43
|
+
readonly fonts: PdfFontResources;
|
|
44
|
+
readonly bands: readonly PdfTableBand[] | undefined;
|
|
45
|
+
readonly widths: readonly number[];
|
|
46
|
+
readonly lefts: readonly number[];
|
|
47
|
+
readonly lineHeight: number;
|
|
48
|
+
readonly headings: readonly (readonly HeadingCell[])[];
|
|
49
|
+
readonly totals: readonly NumericAggregate[];
|
|
50
|
+
private readonly repeatedColumns;
|
|
51
|
+
private readonly structuredBandRows;
|
|
52
|
+
constructor(settings: PdfSettings, fonts: PdfFontResources);
|
|
53
|
+
private cell;
|
|
54
|
+
private row;
|
|
55
|
+
headers(): Promise<readonly PdfLayoutRow[]>;
|
|
56
|
+
block(matrix: TableSpanRows, style: CellPresentation): Promise<readonly PdfLayoutRow[]>;
|
|
57
|
+
/** Repeated identifiers stay complete on every vertical fragment at the row's shared line height. */
|
|
58
|
+
minimumRowLines(row: PdfLayoutRow): number;
|
|
59
|
+
minimumRowHeight(row: PdfLayoutRow): number;
|
|
60
|
+
repeatedColumn(index: number): boolean;
|
|
61
|
+
/** Measure the physical block before kept content is painted. Structured band projections are
|
|
62
|
+
* shared with the painter, so measurement cannot disagree with narrower span intersections. */
|
|
63
|
+
blockHeight(rows: readonly PdfLayoutRow[]): Promise<number>;
|
|
64
|
+
/** Project already captured cells. Cache only bounded structured headings/footer matrices;
|
|
65
|
+
* ordinary data windows remain owned and released by PdfTableBandFlow. */
|
|
66
|
+
bandRows(rows: readonly PdfLayoutRow[], structured?: boolean): Promise<readonly (readonly PdfLayoutRow[])[]>;
|
|
67
|
+
private projectBandRows;
|
|
68
|
+
data(values: readonly ExportValue[], index: number, footer?: boolean): Promise<PdfLayoutRow>;
|
|
69
|
+
footer(index: number): Promise<readonly PdfLayoutRow[] | undefined>;
|
|
70
|
+
}
|
|
71
|
+
export {};
|