@evotecit/officeimo 0.1.19 → 0.1.43
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 +44 -10
- package/bundles/officeimo-canopyx-adapter.js +147 -65
- package/bundles/officeimo-canopyx-adapter.min.js +1 -1
- package/bundles/officeimo-canopyx-adapter.min.mjs +1 -1
- package/bundles/officeimo-canopyx-adapter.mjs +134 -53
- package/bundles/officeimo-canopyx.js +554 -234
- package/bundles/officeimo-canopyx.min.js +1 -1
- package/bundles/officeimo-canopyx.min.mjs +1 -1
- package/bundles/officeimo-canopyx.mjs +477 -158
- package/bundles/officeimo-chartforgex-adapter.js +1924 -0
- package/bundles/officeimo-chartforgex-adapter.min.js +2 -0
- package/bundles/officeimo-chartforgex-adapter.min.mjs +2 -0
- package/bundles/officeimo-chartforgex-adapter.mjs +1910 -0
- package/bundles/officeimo-chartforgex.js +13594 -0
- package/bundles/officeimo-chartforgex.min.js +2 -0
- package/bundles/officeimo-chartforgex.min.mjs +2 -0
- package/bundles/officeimo-chartforgex.mjs +13487 -0
- package/bundles/officeimo-csv.js +12 -7
- package/bundles/officeimo-csv.min.js +1 -1
- package/bundles/officeimo-csv.min.mjs +1 -1
- package/bundles/officeimo-csv.mjs +8 -3
- package/bundles/officeimo-datatables-adapter.js +11 -11
- package/bundles/officeimo-datatables-adapter.min.js +1 -1
- package/bundles/officeimo-datatables-adapter.min.mjs +1 -1
- package/bundles/officeimo-datatables-adapter.mjs +7 -7
- package/bundles/officeimo-datatables.js +418 -180
- package/bundles/officeimo-datatables.min.js +1 -1
- package/bundles/officeimo-datatables.min.mjs +1 -1
- package/bundles/officeimo-datatables.mjs +350 -112
- package/bundles/officeimo-execution.js +14 -9
- package/bundles/officeimo-execution.min.js +1 -1
- package/bundles/officeimo-execution.min.mjs +1 -1
- package/bundles/officeimo-execution.mjs +8 -3
- package/bundles/officeimo-pdf.js +286 -120
- package/bundles/officeimo-pdf.min.js +1 -1
- package/bundles/officeimo-pdf.min.mjs +1 -1
- package/bundles/officeimo-pdf.mjs +244 -78
- package/bundles/officeimo-xlsx.js +136 -59
- package/bundles/officeimo-xlsx.min.js +1 -1
- package/bundles/officeimo-xlsx.min.mjs +1 -1
- package/bundles/officeimo-xlsx.mjs +114 -37
- package/bundles/officeimo.js +416 -178
- package/bundles/officeimo.min.js +1 -1
- package/bundles/officeimo.min.mjs +1 -1
- package/bundles/officeimo.mjs +351 -113
- package/dist/core/progress.js +7 -2
- package/dist/index.d.ts +1 -1
- package/dist/integrations/canopyx/index.js +13 -4
- package/dist/integrations/canopyx/pdf-number.js +9 -6
- package/dist/integrations/canopyx/rule-predicates.d.ts +1 -1
- package/dist/integrations/canopyx/rule-predicates.js +2 -1
- package/dist/integrations/canopyx/rules.d.ts +1 -1
- package/dist/integrations/canopyx/rules.js +11 -13
- package/dist/integrations/canopyx/source.js +57 -7
- package/dist/integrations/canopyx/tones.d.ts +10 -0
- package/dist/integrations/canopyx/tones.js +12 -0
- package/dist/integrations/canopyx/types.d.ts +8 -1
- package/dist/integrations/chartforgex/capture.d.ts +31 -0
- package/dist/integrations/chartforgex/capture.js +103 -0
- package/dist/integrations/chartforgex/index.d.ts +13 -0
- package/dist/integrations/chartforgex/index.js +88 -0
- package/dist/integrations/chartforgex/svg-drawing.d.ts +5 -0
- package/dist/integrations/chartforgex/svg-drawing.js +775 -0
- package/dist/integrations/chartforgex/svg-geometry.d.ts +23 -0
- package/dist/integrations/chartforgex/svg-geometry.js +304 -0
- package/dist/integrations/chartforgex/svg-image.d.ts +9 -0
- package/dist/integrations/chartforgex/svg-image.js +46 -0
- package/dist/integrations/chartforgex/svg-markup.d.ts +10 -0
- package/dist/integrations/chartforgex/svg-markup.js +124 -0
- package/dist/integrations/chartforgex/svg-paint.d.ts +16 -0
- package/dist/integrations/chartforgex/svg-paint.js +146 -0
- package/dist/integrations/chartforgex/types.d.ts +77 -0
- package/dist/integrations/chartforgex/types.js +1 -0
- package/dist/integrations/chartforgex/winansi.d.ts +4 -0
- package/dist/integrations/chartforgex/winansi.js +48 -0
- package/dist/integrations/chartforgex/workbook.d.ts +12 -0
- package/dist/integrations/chartforgex/workbook.js +137 -0
- package/dist/pdf/document-drawings.d.ts +1 -1
- package/dist/pdf/document-drawings.js +91 -17
- package/dist/pdf/document-images.d.ts +7 -1
- package/dist/pdf/document-images.js +59 -24
- package/dist/pdf/document-types.d.ts +3 -1
- package/dist/pdf/document.d.ts +2 -2
- package/dist/pdf/document.js +3 -1
- package/dist/pdf/drawing-types.d.ts +37 -10
- package/dist/pdf/font-resources.d.ts +1 -1
- package/dist/pdf/font-resources.js +6 -3
- package/dist/pdf/index.d.ts +1 -1
- package/dist/pdf/pages.js +15 -0
- package/dist/pdf/png.d.ts +11 -2
- package/dist/pdf/png.js +50 -23
- package/dist/pdf/session.js +3 -2
- package/dist/pdf/settings.d.ts +2 -2
- package/dist/pdf/settings.js +7 -3
- package/dist/xlsx/options.js +2 -2
- package/dist/xlsx/portable.js +1 -1
- package/dist/xlsx/styles.js +28 -18
- package/dist/xlsx/types.d.ts +13 -1
- package/dist/xlsx/workbook.js +9 -1
- package/dist/xlsx/worksheet.d.ts +13 -1
- package/dist/xlsx/worksheet.js +65 -11
- package/package.json +9 -2
|
@@ -7,13 +7,19 @@ interface ImageResource {
|
|
|
7
7
|
readonly width: number;
|
|
8
8
|
readonly height: number;
|
|
9
9
|
}
|
|
10
|
+
type ImageSource = PdfImageBlock["image"];
|
|
10
11
|
/** Shared document image resources; source objects are captured on first consumption. */
|
|
11
12
|
export declare class PdfDocumentImages {
|
|
12
13
|
private readonly objects;
|
|
13
14
|
private readonly settings;
|
|
14
15
|
private readonly images;
|
|
16
|
+
private readonly snapshots;
|
|
15
17
|
private bytes;
|
|
18
|
+
private pendingBytes;
|
|
16
19
|
constructor(objects: PdfObjects, settings: PdfSettings);
|
|
17
|
-
|
|
20
|
+
/** Own a drawing image before preparing earlier elements can yield to the caller. */
|
|
21
|
+
snapshot(image: ImageSource): void;
|
|
22
|
+
private capture;
|
|
23
|
+
prepare(image: ImageSource): Promise<ImageResource>;
|
|
18
24
|
}
|
|
19
25
|
export {};
|
|
@@ -1,52 +1,81 @@
|
|
|
1
1
|
import { NotSupportedError, OfficeIMOError } from "../core/errors.js";
|
|
2
2
|
import { checkAbort, pause, taskYieldDue } from "../core/iteration.js";
|
|
3
|
-
import { pngPixels } from "./png.js";
|
|
3
|
+
import { pngPixels, pngShape } from "./png.js";
|
|
4
4
|
/** Shared document image resources; source objects are captured on first consumption. */
|
|
5
5
|
export class PdfDocumentImages {
|
|
6
6
|
objects;
|
|
7
7
|
settings;
|
|
8
8
|
images = new Map();
|
|
9
|
+
snapshots = new WeakMap();
|
|
9
10
|
bytes = 0;
|
|
11
|
+
pendingBytes = 0;
|
|
10
12
|
constructor(objects, settings) {
|
|
11
13
|
this.objects = objects;
|
|
12
14
|
this.settings = settings;
|
|
13
15
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
return
|
|
16
|
+
/** Own a drawing image before preparing earlier elements can yield to the caller. */
|
|
17
|
+
snapshot(image) {
|
|
18
|
+
if (this.images.has(image) || this.snapshots.has(image))
|
|
19
|
+
return;
|
|
20
|
+
const captured = this.capture(image);
|
|
21
|
+
this.snapshots.set(image, captured);
|
|
22
|
+
this.pendingBytes += captured.data.length;
|
|
23
|
+
}
|
|
24
|
+
capture(image) {
|
|
18
25
|
const { limits, options } = this.settings;
|
|
26
|
+
checkAbort(options.signal);
|
|
19
27
|
if (!image || typeof image !== "object")
|
|
20
28
|
throw new TypeError("PDF images require a byte array.");
|
|
21
|
-
const
|
|
29
|
+
const format = image.format;
|
|
30
|
+
// Dimension getters may change a resizable backing buffer. Read them before measuring the byte view.
|
|
31
|
+
const raw = format === "rgb" || format === "rgba" ? image : undefined;
|
|
32
|
+
const widthValue = raw?.width, heightValue = raw?.height;
|
|
33
|
+
const data = image.data;
|
|
22
34
|
if (!(data instanceof Uint8Array))
|
|
23
35
|
throw new TypeError("PDF images require a byte array.");
|
|
24
36
|
const byteLength = data.length;
|
|
25
|
-
if (this.bytes + byteLength > limits.maxImageBytes)
|
|
37
|
+
if (this.bytes + this.pendingBytes + byteLength > limits.maxImageBytes)
|
|
26
38
|
throw new OfficeIMOError("RESOURCE_LIMIT", "maxImageBytes exceeded.");
|
|
27
|
-
let width, height, components, decoded, decodedAlpha;
|
|
28
39
|
const maximumWorkingBytes = limits.maxImageWorkingBytes;
|
|
29
|
-
if (format === "png")
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
if (format === "png") {
|
|
41
|
+
const shape = pngShape(data, limits.maxImagePixels, maximumWorkingBytes);
|
|
42
|
+
return { format, shape, data: new Uint8Array(data) };
|
|
43
|
+
}
|
|
44
|
+
let shape;
|
|
45
|
+
if (format === "jpeg")
|
|
46
|
+
shape = jpegSize(data);
|
|
33
47
|
else if (format === "rgb" || format === "rgba") {
|
|
34
|
-
|
|
35
|
-
components = format === "rgba" ? 4 : 3;
|
|
48
|
+
shape = { width: widthValue, height: heightValue, components: format === "rgba" ? 4 : 3 };
|
|
36
49
|
}
|
|
37
50
|
else
|
|
38
51
|
throw new NotSupportedError("PDF images support unprofiled PNG/JPEG or decoded RGB/RGBA pixels.");
|
|
52
|
+
const { width, height, components } = shape;
|
|
39
53
|
if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height) || width < 1 || height < 1 ||
|
|
40
54
|
!Number.isSafeInteger(width * height) || width * height > limits.maxImagePixels)
|
|
41
55
|
throw new OfficeIMOError("RESOURCE_LIMIT", "Image dimensions must be positive integers within maxImagePixels.");
|
|
42
|
-
if (
|
|
56
|
+
if (format !== "jpeg" && byteLength !== width * height * components)
|
|
43
57
|
throw new RangeError("Raw image bytes must match width × height × channels exactly.");
|
|
44
|
-
if (
|
|
58
|
+
if (maximumWorkingBytes !== undefined && byteLength + (components === 4 ? width * height : 0) > maximumWorkingBytes)
|
|
45
59
|
throw new OfficeIMOError("RESOURCE_LIMIT", "maxImageWorkingBytes exceeded by image snapshot and alpha plane.");
|
|
60
|
+
return { format, shape, data: new Uint8Array(data) };
|
|
61
|
+
}
|
|
62
|
+
async prepare(image) {
|
|
63
|
+
const existing = this.images.get(image);
|
|
64
|
+
if (existing)
|
|
65
|
+
return existing;
|
|
66
|
+
const { options } = this.settings, snapshot = this.snapshots.get(image);
|
|
67
|
+
const source = snapshot ?? this.capture(image);
|
|
68
|
+
if (snapshot) {
|
|
69
|
+
this.snapshots.delete(image);
|
|
70
|
+
this.pendingBytes -= source.data.length;
|
|
71
|
+
}
|
|
72
|
+
this.bytes += source.data.length;
|
|
73
|
+
const { format } = source;
|
|
74
|
+
const decoded = format === "png" ? await pngPixels(source.data, source.shape, options.signal) : undefined;
|
|
75
|
+
const { width, height, components } = decoded ?? source.shape;
|
|
46
76
|
checkAbort(options.signal);
|
|
47
77
|
const id = this.objects.reserve(), name = "Image" + (this.images.size + 1);
|
|
48
|
-
|
|
49
|
-
const captured = decoded ?? new Uint8Array(data);
|
|
78
|
+
const captured = decoded?.data ?? source.data, decodedAlpha = decoded?.alpha;
|
|
50
79
|
let pixels = captured, alpha = decodedAlpha, mask;
|
|
51
80
|
if (components === 4) {
|
|
52
81
|
// Compact the owned RGBA snapshot in place. Forward writes never overwrite unread channels.
|
|
@@ -68,20 +97,22 @@ export class PdfDocumentImages {
|
|
|
68
97
|
mask = this.objects.reserve();
|
|
69
98
|
await this.objects.stream(mask, alpha, "/Type /XObject /Subtype /Image /Width " + width + " /Height " + height + " /ColorSpace /DeviceGray /BitsPerComponent 8", options.compression !== false, true);
|
|
70
99
|
}
|
|
100
|
+
const jpegFilter = format === "jpeg" ? " /Filter /DCTDecode" +
|
|
101
|
+
(source.shape.colorTransform === 0 ? " /DecodeParms << /ColorTransform 0 >>" : "") : "";
|
|
71
102
|
const dictionary = "/Type /XObject /Subtype /Image /Width " + width + " /Height " + height + " /ColorSpace /" +
|
|
72
103
|
(components === 1 ? "DeviceGray" : "DeviceRGB") + " /BitsPerComponent 8" + (mask ? " /SMask " + mask + " 0 R" : "") +
|
|
73
|
-
|
|
104
|
+
jpegFilter;
|
|
74
105
|
await this.objects.stream(id, pixels, dictionary, format === "jpeg" ? false : options.compression !== false, true);
|
|
75
106
|
const resource = { name, id, width, height };
|
|
76
107
|
this.images.set(image, resource);
|
|
77
108
|
return resource;
|
|
78
109
|
}
|
|
79
110
|
}
|
|
80
|
-
/** Inspect bounded JPEG headers; JPEG entropy decoding remains the independent reader's job. */
|
|
81
|
-
function jpegSize(bytes) {
|
|
111
|
+
/** @internal Inspect bounded JPEG headers; JPEG entropy decoding remains the independent reader's job. */
|
|
112
|
+
export function jpegSize(bytes) {
|
|
82
113
|
if (bytes.length < 4 || bytes[0] !== 255 || bytes[1] !== 216 || bytes[bytes.length - 2] !== 255 || bytes[bytes.length - 1] !== 217)
|
|
83
114
|
throw new TypeError("JPEG images need complete SOI/EOI markers.");
|
|
84
|
-
let result;
|
|
115
|
+
let result, rgb = false, adobe = false;
|
|
85
116
|
for (let p = 2; p < bytes.length;) {
|
|
86
117
|
if (bytes[p++] !== 255)
|
|
87
118
|
throw new TypeError("Invalid JPEG marker.");
|
|
@@ -91,7 +122,8 @@ function jpegSize(bytes) {
|
|
|
91
122
|
if (marker === 218) {
|
|
92
123
|
if (!result)
|
|
93
124
|
throw new TypeError("JPEG scan precedes its frame header.");
|
|
94
|
-
|
|
125
|
+
// PDF decoders otherwise assume a color transform for three-component JPEGs.
|
|
126
|
+
return rgb && !adobe ? { ...result, colorTransform: 0 } : result;
|
|
95
127
|
}
|
|
96
128
|
if (marker === 217)
|
|
97
129
|
break;
|
|
@@ -100,6 +132,8 @@ function jpegSize(bytes) {
|
|
|
100
132
|
const length = bytes[p] * 256 + bytes[p + 1], end = p + length;
|
|
101
133
|
if (length < 2 || end > bytes.length)
|
|
102
134
|
throw new TypeError("Truncated JPEG segment.");
|
|
135
|
+
if (marker === 238 && length >= 14 && String.fromCharCode(...bytes.subarray(p + 2, p + 7)) === "Adobe")
|
|
136
|
+
adobe = true;
|
|
103
137
|
if (marker === 226 && length >= 14 && String.fromCharCode(...bytes.subarray(p + 2, p + 14)) === "ICC_PROFILE\0")
|
|
104
138
|
throw new NotSupportedError("Normalize ICC-profiled JPEG colors before PDF embedding.");
|
|
105
139
|
if (marker === 225 && length >= 8 && String.fromCharCode(...bytes.subarray(p + 2, p + 8)) === "Exif\0\0")
|
|
@@ -112,7 +146,8 @@ function jpegSize(bytes) {
|
|
|
112
146
|
throw new NotSupportedError("PDF JPEG images require grayscale or RGB components; CMYK is unsupported.");
|
|
113
147
|
if (components === 3) {
|
|
114
148
|
const ids = [bytes[p + 8], bytes[p + 11], bytes[p + 14]].join(",");
|
|
115
|
-
|
|
149
|
+
rgb = ids === "82,71,66";
|
|
150
|
+
if (ids !== "1,2,3" && !rgb)
|
|
116
151
|
throw new NotSupportedError("Unsupported JPEG component color layout.");
|
|
117
152
|
}
|
|
118
153
|
if (result)
|
|
@@ -9,6 +9,8 @@ import type { GroupedPdfTableOptions } from "./grouped-types.js";
|
|
|
9
9
|
export interface PdfDocumentOptions extends Omit<PdfOptions<never>, "columns" | "includeHeader" | "headerRows" | "footer" | "headerPresentation" | "footerPresentation" | "alternateRowColor" | "columnWidths" | "wideTable" | "formatValue" | "formatRuns"> {
|
|
10
10
|
/** Named paragraph appearance and keep rules, copied before the block source is consumed. No style inheritance. */
|
|
11
11
|
readonly paragraphStyles?: Readonly<Record<string, PdfParagraphStyle>>;
|
|
12
|
+
/** PDF document information title when it differs from the visible title. */
|
|
13
|
+
readonly metadataTitle?: string;
|
|
12
14
|
}
|
|
13
15
|
/** A table's own columns, repeated headings, presentation and numeric totals. */
|
|
14
16
|
export type PdfTableOptions<T = never> = Pick<PdfOptions<T>, "columns" | "includeHeader" | "headerRows" | "footer" | "headerPresentation" | "footerPresentation" | "alternateRowColor" | "columnWidths" | "wideTable" | "formatValue" | "formatRuns">;
|
|
@@ -157,4 +159,4 @@ export interface PdfVectorBlock {
|
|
|
157
159
|
readonly caption?: PdfCaption;
|
|
158
160
|
}
|
|
159
161
|
/** Blocks are consumed once in order; each table owns its row source until that table completes. */
|
|
160
|
-
export type PdfDocumentBlock = PdfParagraphBlock | PdfGroupBlock | PdfTableBlock | PdfGroupedTableBlock | PdfPageBreakBlock | PdfImageBlock | PdfVectorBlock | PdfDrawingBlock | PdfListBlock | PdfSectionBlock;
|
|
162
|
+
export type PdfDocumentBlock<DrawingVersion extends 1 | 2 = 1> = PdfParagraphBlock | PdfGroupBlock | PdfTableBlock | PdfGroupedTableBlock | PdfPageBreakBlock | PdfImageBlock | PdfVectorBlock | PdfDrawingBlock<DrawingVersion> | PdfListBlock | PdfSectionBlock;
|
package/dist/pdf/document.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { PdfDocumentBlock, PdfDocumentOptions, PdfTableBlock, PdfTableOptio
|
|
|
3
3
|
/** Capture typed columns for a single-use table source in a composed document. */
|
|
4
4
|
export declare function pdfTable<T extends object>(rows: Iterable<T> | AsyncIterable<T>, options: PdfTableOptions<NoInfer<T>>): PdfTableBlock;
|
|
5
5
|
/** Write sequential report blocks to a PDF Blob, retaining finished output proportional to file size. */
|
|
6
|
-
export declare function writePdfDocument(blocks: Iterable<PdfDocumentBlock
|
|
6
|
+
export declare function writePdfDocument(blocks: Iterable<PdfDocumentBlock<1 | 2>> | AsyncIterable<PdfDocumentBlock<1 | 2>>, options?: PdfDocumentOptions): Promise<Blob>;
|
|
7
7
|
/** Stream composed pages with backpressure. Rows sum table source rows; columns reports the widest table.
|
|
8
8
|
* Analytical subtotals/grand totals also consume the cumulative maxRows output budget. */
|
|
9
|
-
export declare function writePdfDocumentTo(blocks: Iterable<PdfDocumentBlock
|
|
9
|
+
export declare function writePdfDocumentTo(blocks: Iterable<PdfDocumentBlock<1 | 2>> | AsyncIterable<PdfDocumentBlock<1 | 2>>, destination: OutputDestination, configuration?: PdfDocumentOptions): Promise<ExportResult>;
|
package/dist/pdf/document.js
CHANGED
|
@@ -229,7 +229,9 @@ export async function writePdfDocumentTo(blocks, destination, configuration = {}
|
|
|
229
229
|
const inputDrawing = block.drawing, capturedCaption = snapshotCaption(block.caption), alternative = graphicAlternative(block, pages.settings), alignment = graphicAlignment(block.alignment);
|
|
230
230
|
if (capturedCaption && alternative === undefined)
|
|
231
231
|
throw new TypeError("A captioned PDF graphic requires alternativeText and cannot be decorative.");
|
|
232
|
-
const drawing = await prepareDrawing(inputDrawing, pages.settings, fonts, { commands, elements: drawingElements }
|
|
232
|
+
const drawing = await prepareDrawing(inputDrawing, pages.settings, fonts, { commands, elements: drawingElements }, {
|
|
233
|
+
images, registerImage: (name, id) => pages.registerXObject(name, id), opacity: alpha => pages.opacityState(alpha)
|
|
234
|
+
}), caption = await prepareCaption(capturedCaption);
|
|
233
235
|
commands += drawing.commands;
|
|
234
236
|
drawingElements += drawing.elements;
|
|
235
237
|
await flushParagraphs((caption?.height ?? 0) + pages.graphicHeight(drawing.width, drawing.height));
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import type { PdfCaption, PdfPathCommand } from "./document-types.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
readonly version: 1;
|
|
1
|
+
import type { PdfCaption, PdfJpegImage, PdfPathCommand, PdfPngImage, PdfRawImage } from "./document-types.js";
|
|
2
|
+
interface PdfDrawingData<Version extends 1 | 2> {
|
|
3
|
+
readonly version: Version;
|
|
5
4
|
readonly width: number;
|
|
6
5
|
readonly height: number;
|
|
7
|
-
readonly elements: readonly PdfDrawingElement[];
|
|
6
|
+
readonly elements: readonly PdfDrawingElement<Version>[];
|
|
7
|
+
/** Paint text whose slot has no supplied TrueType face with the standard Helvetica face (WinAnsi characters only)
|
|
8
|
+
* instead of rejecting it. Default false: drawing text requires exact embedded faces. */
|
|
9
|
+
readonly standardFonts?: boolean;
|
|
8
10
|
}
|
|
11
|
+
/** Versioned portable drawing. Lengths are points, with a top-left origin and downward y axis. */
|
|
12
|
+
export type PdfDrawing<Version extends 1 | 2 = 1> = Version extends 1 | 2 ? PdfDrawingData<Version> : never;
|
|
9
13
|
/** One painted path; colors are six-digit RGB hex strings. */
|
|
10
14
|
export interface PdfDrawingPath {
|
|
11
15
|
readonly kind: "path";
|
|
@@ -16,6 +20,12 @@ export interface PdfDrawingPath {
|
|
|
16
20
|
readonly fillRule?: "nonzero" | "evenodd";
|
|
17
21
|
readonly lineCap?: "butt" | "round" | "square";
|
|
18
22
|
readonly lineJoin?: "miter" | "round" | "bevel";
|
|
23
|
+
/** Miter-to-stroke-width ratio from 1 through 1,000,000. Default 10. */
|
|
24
|
+
readonly miterLimit?: number;
|
|
25
|
+
/** 1 through 16 stroke dash lengths from 0 through 14,400 points. At least one must survive rounding to 0.001 pt. */
|
|
26
|
+
readonly dash?: readonly number[];
|
|
27
|
+
/** Dash phase from -1,000,000 through 1,000,000 points; requires dash. */
|
|
28
|
+
readonly dashOffset?: number;
|
|
19
29
|
}
|
|
20
30
|
/** A face explicitly supplied in the PDF document's embedded static TrueType family. */
|
|
21
31
|
export type PdfDrawingFont = "regular" | "bold" | "italic" | "boldItalic";
|
|
@@ -28,6 +38,10 @@ export interface PdfDrawingText {
|
|
|
28
38
|
readonly font: PdfDrawingFont;
|
|
29
39
|
readonly fontSize: number;
|
|
30
40
|
readonly color: string;
|
|
41
|
+
/** Which point of the measured run sits at x and y. Default start. */
|
|
42
|
+
readonly anchor?: "start" | "middle" | "end";
|
|
43
|
+
/** Clockwise baseline rotation in degrees about the anchor, -360 through 360. Default 0. */
|
|
44
|
+
readonly rotation?: number;
|
|
31
45
|
}
|
|
32
46
|
export interface PdfDrawingClip {
|
|
33
47
|
readonly x: number;
|
|
@@ -36,18 +50,31 @@ export interface PdfDrawingClip {
|
|
|
36
50
|
readonly height: number;
|
|
37
51
|
}
|
|
38
52
|
/** Ordered children, optionally restricted by an axis-aligned rectangular clip. */
|
|
39
|
-
export interface PdfDrawingGroup {
|
|
53
|
+
export interface PdfDrawingGroup<Version extends 1 | 2 = 1> {
|
|
40
54
|
readonly kind: "group";
|
|
41
55
|
readonly clip?: PdfDrawingClip;
|
|
42
|
-
readonly elements: readonly PdfDrawingElement[];
|
|
56
|
+
readonly elements: readonly PdfDrawingElement<Version>[];
|
|
57
|
+
}
|
|
58
|
+
/** A PNG, JPEG or raw RGB(A) image stretched over a rectangle whose top-left corner is x and y.
|
|
59
|
+
* Every placement of the same image object, in any drawing or image block, shares one PDF image. */
|
|
60
|
+
export interface PdfDrawingImage {
|
|
61
|
+
readonly kind: "image";
|
|
62
|
+
readonly image: PdfRawImage | PdfJpegImage | PdfPngImage;
|
|
63
|
+
readonly x: number;
|
|
64
|
+
readonly y: number;
|
|
65
|
+
readonly width: number;
|
|
66
|
+
readonly height: number;
|
|
67
|
+
/** Constant opacity from 0 through 1. Default 1. */
|
|
68
|
+
readonly opacity?: number;
|
|
43
69
|
}
|
|
44
|
-
export type PdfDrawingElement = PdfDrawingPath | PdfDrawingText | PdfDrawingGroup;
|
|
70
|
+
export type PdfDrawingElement<Version extends 1 | 2 = 1> = PdfDrawingPath | PdfDrawingText | (Version extends 2 ? PdfDrawingGroup<2> | PdfDrawingImage : PdfDrawingGroup<1>);
|
|
45
71
|
/** An indivisible drawing, automatically scaled down to fit the printable page. */
|
|
46
|
-
export interface PdfDrawingBlock {
|
|
72
|
+
export interface PdfDrawingBlock<Version extends 1 | 2 = 1> {
|
|
47
73
|
readonly kind: "drawing";
|
|
48
|
-
readonly drawing: PdfDrawing
|
|
74
|
+
readonly drawing: PdfDrawing<Version>;
|
|
49
75
|
readonly alignment?: "left" | "center" | "right";
|
|
50
76
|
readonly alternativeText?: string;
|
|
51
77
|
readonly decorative?: boolean;
|
|
52
78
|
readonly caption?: PdfCaption;
|
|
53
79
|
}
|
|
80
|
+
export {};
|
|
@@ -38,6 +38,6 @@ export declare class PdfFontResources {
|
|
|
38
38
|
constructor(objects: PdfObjects, fonts?: PdfFonts | undefined, maxBytes?: number, signal?: AbortSignal | undefined);
|
|
39
39
|
/** The same operation budget covers unused declared faces and every explicit run face, once per identity. */
|
|
40
40
|
registerFont(font: PdfFont): void;
|
|
41
|
-
select(bold?: boolean, italic?: boolean, explicit?: PdfFont): PdfFontResource;
|
|
41
|
+
select(bold?: boolean, italic?: boolean, explicit?: PdfFont, standardForMissingFace?: boolean): PdfFontResource;
|
|
42
42
|
dictionary(): string;
|
|
43
43
|
}
|
|
@@ -193,7 +193,7 @@ export class PdfFontResources {
|
|
|
193
193
|
this.fontBytes += bytes;
|
|
194
194
|
this.registered.add(font);
|
|
195
195
|
}
|
|
196
|
-
select(bold = false, italic = false, explicit) {
|
|
196
|
+
select(bold = false, italic = false, explicit, standardForMissingFace = false) {
|
|
197
197
|
if (explicit)
|
|
198
198
|
this.registerFont(explicit);
|
|
199
199
|
let selections = this.selections;
|
|
@@ -203,10 +203,13 @@ export class PdfFontResources {
|
|
|
203
203
|
if (!found)
|
|
204
204
|
this.explicitSelections.set(explicit, selections);
|
|
205
205
|
}
|
|
206
|
-
const
|
|
206
|
+
const fallback = standardForMissingFace && !explicit && this.fonts !== undefined &&
|
|
207
|
+
this.fonts[bold ? italic ? "boldItalic" : "bold" : italic ? "italic" : "regular"] === undefined;
|
|
208
|
+
const key = (bold ? 2 : 0) | (italic ? 1 : 0) | (fallback ? 4 : 0), existing = selections.get(key);
|
|
207
209
|
if (existing)
|
|
208
210
|
return existing;
|
|
209
|
-
const { font, syntheticBold, syntheticItalic } = explicit ? { font: explicit, syntheticBold: bold, syntheticItalic: italic } :
|
|
211
|
+
const { font, syntheticBold, syntheticItalic } = explicit ? { font: explicit, syntheticBold: bold, syntheticItalic: italic } :
|
|
212
|
+
selectFont(fallback ? undefined : this.fonts, bold, italic);
|
|
210
213
|
const shared = font ? this.programs.get(font) : undefined;
|
|
211
214
|
const resource = new PdfFontResource(this.resources.length + 1, bold, italic, font, this.objects, syntheticBold, syntheticItalic, shared, this.signal);
|
|
212
215
|
if (!shared) {
|
package/dist/pdf/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { writePdfDocument, writePdfDocumentTo, pdfTable } from "./document.js";
|
|
|
9
9
|
export type { PdfDocumentOptions, PdfDocumentBlock, PdfTableOptions, PdfTableBlock, PdfParagraphBlock, PdfParagraphStyle, PdfCaption, PdfListBlock, PdfListItem, PdfGroupBlock, PdfPageBreakBlock, PdfImageBlock, PdfRawImage, PdfJpegImage, PdfPngImage, PdfVectorBlock, PdfPathCommand } from "./document-types.js";
|
|
10
10
|
export type { PdfTextRun, PdfText } from "./inline-types.js";
|
|
11
11
|
export type { PdfTextDirection, PdfShapingRun, PdfShapedGlyph, PdfShapedRun, PdfShapeLineRequest, PdfTextShaper } from "./text-shaping-types.js";
|
|
12
|
-
export type { PdfDrawing, PdfDrawingBlock, PdfDrawingElement, PdfDrawingPath, PdfDrawingText, PdfDrawingGroup, PdfDrawingClip, PdfDrawingFont } from "./drawing-types.js";
|
|
12
|
+
export type { PdfDrawing, PdfDrawingBlock, PdfDrawingElement, PdfDrawingPath, PdfDrawingText, PdfDrawingImage, PdfDrawingGroup, PdfDrawingClip, PdfDrawingFont } from "./drawing-types.js";
|
|
13
13
|
export { PdfFont } from "./font.js";
|
|
14
14
|
export type { PdfFontPreparationOptions } from "./font.js";
|
|
15
15
|
export { preflightPdfText } from "./preflight.js";
|
package/dist/pdf/pages.js
CHANGED
|
@@ -47,6 +47,7 @@ export class PdfPages {
|
|
|
47
47
|
rectangleLefts;
|
|
48
48
|
rectangleColumns = [];
|
|
49
49
|
externalObjects = new Map();
|
|
50
|
+
opacityStates = new Map();
|
|
50
51
|
bandFlow;
|
|
51
52
|
bandCellBudget = false;
|
|
52
53
|
tableElement;
|
|
@@ -629,6 +630,20 @@ export class PdfPages {
|
|
|
629
630
|
}
|
|
630
631
|
async pageBreak() { await this.ensureStarted(); await this.finishPage(); await this.start(false); }
|
|
631
632
|
registerXObject(name, id) { this.externalObjects.set(name, id); }
|
|
633
|
+
/** One shared constant-opacity graphics state per serialized alpha value. */
|
|
634
|
+
opacityState(alpha) {
|
|
635
|
+
const value = pdfNumber(alpha);
|
|
636
|
+
let name = this.opacityStates.get(value);
|
|
637
|
+
if (!name) {
|
|
638
|
+
name = "GA" + (this.opacityStates.size + 1);
|
|
639
|
+
this.opacityStates.set(value, name);
|
|
640
|
+
}
|
|
641
|
+
return name;
|
|
642
|
+
}
|
|
643
|
+
graphicsStates() {
|
|
644
|
+
const entries = [...this.opacityStates].map(([alpha, name]) => "/" + name + " << /ca " + alpha + " /CA " + alpha + " >>");
|
|
645
|
+
return entries.length ? " /ExtGState << " + entries.join(" ") + " >>" : "";
|
|
646
|
+
}
|
|
632
647
|
/** Height after the existing fit-to-page graphic policy, used by heading keep constraints. */
|
|
633
648
|
graphicHeight(width, height) {
|
|
634
649
|
const { page, margins } = this.settings;
|
package/dist/pdf/png.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export interface PngShape {
|
|
2
|
+
readonly width: number;
|
|
3
|
+
readonly height: number;
|
|
4
|
+
readonly components: 3 | 4;
|
|
5
|
+
}
|
|
1
6
|
export interface PngPixels {
|
|
2
7
|
readonly width: number;
|
|
3
8
|
readonly height: number;
|
|
@@ -5,5 +10,9 @@ export interface PngPixels {
|
|
|
5
10
|
readonly data: Uint8Array;
|
|
6
11
|
readonly alpha?: Uint8Array;
|
|
7
12
|
}
|
|
8
|
-
/** Decode
|
|
9
|
-
export declare function pngPixels(
|
|
13
|
+
/** Decode an owned static unprofiled PNG without canvas or a second compression engine. */
|
|
14
|
+
export declare function pngPixels(source: Uint8Array<ArrayBuffer>, shape: PngShape, signal?: AbortSignal): Promise<PngPixels>;
|
|
15
|
+
/** Check the image profile for SVG placement without inflating pixels. Embedding still verifies CRCs and image data. */
|
|
16
|
+
export declare function pngEmbeddableSize(source: Uint8Array): PngShape;
|
|
17
|
+
/** Check source metadata synchronously, before capturing source bytes or allocating any image plane. */
|
|
18
|
+
export declare function pngShape(source: Uint8Array, maxPixels: number, maxWorkingBytes?: number): PngShape;
|
package/dist/pdf/png.js
CHANGED
|
@@ -3,15 +3,10 @@ import { checkAbort, pause, taskYieldDue, withAbort } from "../core/iteration.js
|
|
|
3
3
|
import { Crc32 } from "../internal/crc32.js";
|
|
4
4
|
const signature = [137, 80, 78, 71, 13, 10, 26, 10];
|
|
5
5
|
const unsupportedChunks = new Set(["PLTE", "tRNS", "iCCP", "sRGB", "gAMA", "cHRM", "cICP", "mDCV", "cLLI", "sBIT", "eXIf", "acTL", "fcTL", "fdAT"]);
|
|
6
|
-
/** Decode
|
|
7
|
-
export async function pngPixels(
|
|
6
|
+
/** Decode an owned static unprofiled PNG without canvas or a second compression engine. */
|
|
7
|
+
export async function pngPixels(source, shape, signal) {
|
|
8
8
|
checkAbort(signal);
|
|
9
|
-
const shape = pngShape(inputSource, maxPixels);
|
|
10
9
|
const imagePixels = shape.width * shape.height;
|
|
11
|
-
const workingBytes = inputSource.length + imagePixels * shape.components + (shape.components === 4 ? shape.width * 8 : 0);
|
|
12
|
-
if (maxWorkingBytes !== undefined && workingBytes > maxWorkingBytes)
|
|
13
|
-
throw new OfficeIMOError("RESOURCE_LIMIT", "maxImageWorkingBytes exceeded by PNG source, image planes and scanlines.");
|
|
14
|
-
const source = new Uint8Array(inputSource);
|
|
15
10
|
const header = await pngHeader(source, shape, signal);
|
|
16
11
|
checkAbort(signal);
|
|
17
12
|
let stream;
|
|
@@ -25,9 +20,6 @@ export async function pngPixels(inputSource, maxPixels, signal, maxWorkingBytes)
|
|
|
25
20
|
}
|
|
26
21
|
const { width, height, components } = header, rowBytes = width * components;
|
|
27
22
|
const expected = (rowBytes + 1) * height;
|
|
28
|
-
// All dimensions and the exact filtered length are bounded before allocating decoded pixels.
|
|
29
|
-
if (!Number.isSafeInteger(expected) || expected > 0x7fffffff)
|
|
30
|
-
throw new OfficeIMOError("RESOURCE_LIMIT", "PNG filtered data exceeds the supported decoded byte length.");
|
|
31
23
|
// RGBA is reconstructed one scanline at a time directly into PDF RGB/alpha planes.
|
|
32
24
|
// It never retains an additional full interleaved RGBA image.
|
|
33
25
|
const pixels = new Uint8Array(width * height * 3), alpha = components === 4 ? new Uint8Array(imagePixels) : undefined;
|
|
@@ -175,20 +167,55 @@ async function verifyPngZlibEnd(source, header, expected, signal) {
|
|
|
175
167
|
reader.releaseLock();
|
|
176
168
|
}
|
|
177
169
|
}
|
|
170
|
+
function pngChunk(source, view, offset) {
|
|
171
|
+
if (offset + 12 > source.length)
|
|
172
|
+
throw new TypeError("Truncated PNG chunk.");
|
|
173
|
+
const length = view.getUint32(offset), end = offset + 12 + length;
|
|
174
|
+
if (length > 0x7fffffff || end > source.length)
|
|
175
|
+
throw new TypeError("Truncated or oversized PNG chunk.");
|
|
176
|
+
const type = String.fromCharCode(...source.subarray(offset + 4, offset + 8));
|
|
177
|
+
if (!/^[A-Za-z]{2}[A-Z][A-Za-z]$/.test(type))
|
|
178
|
+
throw new TypeError("Invalid PNG chunk type.");
|
|
179
|
+
return { length, end, type };
|
|
180
|
+
}
|
|
181
|
+
function checkAncillaryChunk(type) {
|
|
182
|
+
if (unsupportedChunks.has(type))
|
|
183
|
+
throw new NotSupportedError("PNG chunk " + type + "; normalize color, orientation, transparency or animation first");
|
|
184
|
+
if (type.charCodeAt(0) < 97)
|
|
185
|
+
throw new NotSupportedError("Required PNG chunk " + type);
|
|
186
|
+
}
|
|
187
|
+
/** Check the image profile for SVG placement without inflating pixels. Embedding still verifies CRCs and image data. */
|
|
188
|
+
export function pngEmbeddableSize(source) {
|
|
189
|
+
const shape = pngShape(source, Infinity);
|
|
190
|
+
const view = new DataView(source.buffer, source.byteOffset, source.byteLength);
|
|
191
|
+
let hasData = false, dataClosed = false;
|
|
192
|
+
for (let offset = 33; offset < source.length;) {
|
|
193
|
+
const { length, end, type } = pngChunk(source, view, offset);
|
|
194
|
+
if (type === "IEND") {
|
|
195
|
+
if (length === 0 && hasData && end === source.length)
|
|
196
|
+
return shape;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
if (type === "IDAT") {
|
|
200
|
+
if (dataClosed)
|
|
201
|
+
throw new TypeError("PNG IDAT chunks must be consecutive.");
|
|
202
|
+
hasData = true;
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
checkAncillaryChunk(type);
|
|
206
|
+
dataClosed ||= hasData;
|
|
207
|
+
}
|
|
208
|
+
offset = end;
|
|
209
|
+
}
|
|
210
|
+
throw new TypeError("PNG requires a final empty IEND after IDAT.");
|
|
211
|
+
}
|
|
178
212
|
/** Verify the complete source and critical chunk order before any decompressed image allocation. */
|
|
179
213
|
async function pngHeader(source, shape, signal) {
|
|
180
214
|
const view = new DataView(source.buffer, source.byteOffset, source.byteLength);
|
|
181
215
|
let firstData = 0, dataEnd = 0, lastDataByte = -1, dataClosed = false;
|
|
182
216
|
for (let offset = 8; offset < source.length;) {
|
|
183
217
|
checkAbort(signal);
|
|
184
|
-
|
|
185
|
-
throw new TypeError("Truncated PNG chunk.");
|
|
186
|
-
const length = view.getUint32(offset), end = offset + 12 + length;
|
|
187
|
-
if (length > 0x7fffffff || end > source.length)
|
|
188
|
-
throw new TypeError("Truncated or oversized PNG chunk.");
|
|
189
|
-
const type = String.fromCharCode(...source.subarray(offset + 4, offset + 8));
|
|
190
|
-
if (!/^[A-Za-z]{2}[A-Z][A-Za-z]$/.test(type))
|
|
191
|
-
throw new TypeError("Invalid PNG chunk type.");
|
|
218
|
+
const { length, end, type } = pngChunk(source, view, offset);
|
|
192
219
|
const crc = new Crc32();
|
|
193
220
|
for (let p = offset + 4; p < end - 4; p += 65536) {
|
|
194
221
|
crc.update(source.subarray(p, Math.min(end - 4, p + 65536)));
|
|
@@ -220,17 +247,14 @@ async function pngHeader(source, shape, signal) {
|
|
|
220
247
|
throw new TypeError("PNG requires a final empty IEND after IDAT.");
|
|
221
248
|
return { ...shape, firstData, dataEnd, lastDataByte };
|
|
222
249
|
}
|
|
223
|
-
|
|
224
|
-
throw new NotSupportedError("PNG chunk " + type + "; normalize color, orientation, transparency or animation first");
|
|
225
|
-
if ((source[offset + 4] & 32) === 0)
|
|
226
|
-
throw new NotSupportedError("Required PNG chunk " + type);
|
|
250
|
+
checkAncillaryChunk(type);
|
|
227
251
|
}
|
|
228
252
|
offset = end;
|
|
229
253
|
}
|
|
230
254
|
throw new TypeError("PNG requires a complete final IEND chunk.");
|
|
231
255
|
}
|
|
232
256
|
/** Check source metadata synchronously, before capturing source bytes or allocating any image plane. */
|
|
233
|
-
function pngShape(source, maxPixels) {
|
|
257
|
+
export function pngShape(source, maxPixels, maxWorkingBytes) {
|
|
234
258
|
if (source.length < 33 || signature.some((value, index) => source[index] !== value))
|
|
235
259
|
throw new TypeError("Invalid PNG signature or truncated IHDR.");
|
|
236
260
|
const view = new DataView(source.buffer, source.byteOffset, source.byteLength);
|
|
@@ -250,6 +274,9 @@ function pngShape(source, maxPixels) {
|
|
|
250
274
|
const components = source[25] === 6 ? 4 : 3;
|
|
251
275
|
if (!Number.isSafeInteger((width * components + 1) * height) || (width * components + 1) * height > 0x7fffffff)
|
|
252
276
|
throw new OfficeIMOError("RESOURCE_LIMIT", "PNG filtered data exceeds the supported decoded byte length.");
|
|
277
|
+
const workingBytes = source.length + width * height * components + (components === 4 ? width * 8 : 0);
|
|
278
|
+
if (maxWorkingBytes !== undefined && workingBytes > maxWorkingBytes)
|
|
279
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "maxImageWorkingBytes exceeded by PNG source, image planes and scanlines.");
|
|
253
280
|
return { width, height, components };
|
|
254
281
|
}
|
|
255
282
|
function paeth(left, up, upperLeft) {
|
package/dist/pdf/session.js
CHANGED
|
@@ -43,13 +43,14 @@ export class PdfWriteSession {
|
|
|
43
43
|
await pages.finish();
|
|
44
44
|
for (const font of fonts.resources)
|
|
45
45
|
await font.write(objects, options.compression !== false);
|
|
46
|
-
await objects.object(this.resources, "<< /Font " + fonts.dictionary() + pages.xobjects() + " >>");
|
|
46
|
+
await objects.object(this.resources, "<< /Font " + fonts.dictionary() + pages.xobjects() + pages.graphicsStates() + " >>");
|
|
47
47
|
await objects.object(this.parent, "<< /Type /Pages /Count " + pages.references.length + " /Kids [" + pages.references.map(id => id + " 0 R").join(" ") + "] >>");
|
|
48
48
|
if (this.structure)
|
|
49
49
|
await this.structure.finish();
|
|
50
50
|
await this.outlines.finish();
|
|
51
51
|
await objects.object(this.root, "<< /Type /Catalog /Pages " + this.parent + " 0 R" + (this.structure?.catalogDictionary ?? "") + this.outlines.catalogDictionary + " >>");
|
|
52
|
-
|
|
52
|
+
const title = options.metadataTitle ?? options.title;
|
|
53
|
+
await objects.object(this.info, "<< /Producer (OfficeIMO.js)" + (title === undefined ? "" : " /Title <feff" + unicodeHex(title) + ">") + " >>");
|
|
53
54
|
await objects.finish(this.root, this.info);
|
|
54
55
|
}
|
|
55
56
|
}
|
package/dist/pdf/settings.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { PdfOptions, PdfMargins, PdfPageSize, PdfLimits } from "./types.js"
|
|
|
3
3
|
import type { PdfDocumentOptions, PdfParagraphStyle } from "./document-types.js";
|
|
4
4
|
export { positive, color, presentation } from "./presentation-settings.js";
|
|
5
5
|
export interface PdfSettings {
|
|
6
|
-
readonly options: PdfOptions & Pick<PdfDocumentOptions, "paragraphStyles">;
|
|
6
|
+
readonly options: PdfOptions & Pick<PdfDocumentOptions, "metadataTitle" | "paragraphStyles">;
|
|
7
7
|
readonly paragraphStyles: Readonly<Record<string, Readonly<PdfParagraphStyle>>>;
|
|
8
8
|
readonly page: PdfPageSize;
|
|
9
9
|
readonly margins: PdfMargins;
|
|
@@ -14,4 +14,4 @@ export interface PdfSettings {
|
|
|
14
14
|
/** Captured identities resolved once to selected table positions, shared by layout and band planning. */
|
|
15
15
|
readonly repeatedColumns: readonly number[];
|
|
16
16
|
}
|
|
17
|
-
export declare function settings(input: PdfOptions & Pick<PdfDocumentOptions, "paragraphStyles">, document?: boolean): PdfSettings;
|
|
17
|
+
export declare function settings(input: PdfOptions & Pick<PdfDocumentOptions, "metadataTitle" | "paragraphStyles">, document?: boolean): PdfSettings;
|
package/dist/pdf/settings.js
CHANGED
|
@@ -14,12 +14,16 @@ const sizes = {
|
|
|
14
14
|
};
|
|
15
15
|
/** @internal Shared capture schema for thin format adapters and the grouped writer. */
|
|
16
16
|
export const pdfOptionFields = ["columns", "signal", "onProgress", "limits", "textShaper", "textDirection", "pageSize", "orientation", "margins", "fonts", "tagged", "fontSize",
|
|
17
|
-
"title", "messageTop", "messageBottom", "includeHeader", "headerRows", "footer", "headerPresentation", "footerPresentation", "alternateRowColor", "padding",
|
|
17
|
+
"title", "metadataTitle", "messageTop", "messageBottom", "includeHeader", "headerRows", "footer", "headerPresentation", "footerPresentation", "alternateRowColor", "padding",
|
|
18
18
|
"columnWidths", "wideTable", "pageHeader", "pageFooter", "pageNumbers", "pageNumberLabels", "booleanText", "formatValue", "formatRuns", "compression", "paragraphStyles"];
|
|
19
19
|
/** @internal Complete PDF limit schema used when a host combines format and shared limits. */
|
|
20
20
|
export const pdfLimitFields = ["maxRows", "maxCells", "maxTextCharacters", "maxOutputBytes", "maxPages", "maxColumns", "maxTableBands", "maxTableWindowRows", "maxCellCharacters", "maxTextRuns", "maxGroupBlocks", "maxRowLines",
|
|
21
21
|
"maxFontBytes", "maxPageBytes", "maxHyperlinks", "maxImageBytes", "maxImagePixels", "maxImageWorkingBytes", "maxVectorCommands", "maxDrawingElements", "maxStructureElements",
|
|
22
22
|
"maxMarkedContentReferences", "maxSections", "maxBookmarks", "maxListItems", "maxParagraphStyles"];
|
|
23
|
+
/** @internal Default ceilings shared by the drawing writer and its producers. */
|
|
24
|
+
export const pdfDrawingLimits = Object.freeze({ maxVectorCommands: 100000, maxDrawingElements: 100000 });
|
|
25
|
+
/** @internal Maximum number of retained drawing levels including the leaf. */
|
|
26
|
+
export const pdfDrawingMaxDepth = 32;
|
|
23
27
|
/** @internal Capture supported structural properties once, including class-based options with prototype accessors. */
|
|
24
28
|
export function capturePdfOptions(input) {
|
|
25
29
|
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
@@ -130,7 +134,7 @@ export function settings(input, document = false) {
|
|
|
130
134
|
footerPresentation: Object.freeze({ background: "eef2f6", bold: true, ...presentation(configuration.footerPresentation) }) };
|
|
131
135
|
const budget = new ExportBudget(options.limits);
|
|
132
136
|
const limits = { maxPages: 10000, maxColumns: 1024, maxTableBands: 64, maxTableWindowRows: 256, maxCellCharacters: 1000000, maxTextRuns: 10000, maxGroupBlocks: 256, maxRowLines: 100000, maxFontBytes: 16 * 1024 * 1024, maxPageBytes: 8 * 1024 * 1024, maxHyperlinks: 100000,
|
|
133
|
-
maxImageBytes: 32 * 1024 * 1024, maxImagePixels: 16 * 1024 * 1024,
|
|
137
|
+
maxImageBytes: 32 * 1024 * 1024, maxImagePixels: 16 * 1024 * 1024, ...pdfDrawingLimits,
|
|
134
138
|
maxStructureElements: 1000000, maxMarkedContentReferences: 2000000,
|
|
135
139
|
maxListItems: 100000, maxParagraphStyles: 256, maxSections: 1000, maxBookmarks: 10000 };
|
|
136
140
|
for (const key of Object.keys(limits)) {
|
|
@@ -158,7 +162,7 @@ export function settings(input, document = false) {
|
|
|
158
162
|
const fontSize = positive(options.fontSize ?? 9, "Font size", 144), padding = options.padding ?? 4;
|
|
159
163
|
if (!Number.isFinite(padding) || padding < 0 || padding > 72)
|
|
160
164
|
throw new RangeError("PDF padding must be from 0 through 72 points.");
|
|
161
|
-
for (const key of ["title", "messageTop", "messageBottom"])
|
|
165
|
+
for (const key of ["title", "metadataTitle", "messageTop", "messageBottom"])
|
|
162
166
|
if (options[key] !== undefined && typeof options[key] !== "string")
|
|
163
167
|
throw new TypeError(key + " must be text.");
|
|
164
168
|
for (const key of ["pageHeader", "pageFooter"])
|
package/dist/xlsx/options.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { captureFields } from "../internal/capture.js";
|
|
2
2
|
/** @internal The workbook owner captures these settings before validation or adapter merging. */
|
|
3
|
-
export const workbookOptionFields = ["signal", "onProgress", "limits", "sink", "dateMode", "compression", "invalidCharacterPolicy", "appProperties", "cellValueWriters", "oversizedText", "creator", "title", "subject", "description", "created", "modified"];
|
|
3
|
+
export const workbookOptionFields = ["signal", "onProgress", "limits", "sink", "dateMode", "compression", "invalidCharacterPolicy", "appProperties", "cellValueWriters", "oversizedText", "hyperlinkOverflow", "onHyperlinkOverflow", "creator", "title", "subject", "description", "created", "modified"];
|
|
4
4
|
/** @internal Worksheet settings also used by the portable sheet owner. */
|
|
5
|
-
export const sheetOptionFields = ["columns", "includeHeader", "headerRows", "freezeHeader", "autoFilter", "boldHeader", "headerFill", "headerStyle", "alternatingRowStyle", "rowStyle", "cellStyle", "rowOutline", "maxOutlineLevel", "outlineSummaryBelow", "outlineSummaryRight", "columnOutlines", "rowHeight", "headerHeight", "defaultColumnWidth", "freezeColumns", "table", "autoSize", "footer", "print", "title", "mergedCells", "hyperlinks", "conditionalFormats", "dataValidation"];
|
|
5
|
+
export const sheetOptionFields = ["columns", "includeHeader", "headerRows", "freezeHeader", "autoFilter", "boldHeader", "headerFill", "headerBorder", "headerWrap", "headerStyle", "alternatingRowStyle", "rowStyle", "cellStyle", "rowOutline", "maxOutlineLevel", "outlineSummaryBelow", "outlineSummaryRight", "columnOutlines", "rowHeight", "headerHeight", "defaultColumnWidth", "freezeColumns", "table", "autoSize", "footer", "print", "title", "mergedCells", "hyperlinks", "conditionalFormats", "dataValidation"];
|
|
6
6
|
/** @internal Includes inherited format-specific ceilings before a wrapper combines stream settings. */
|
|
7
7
|
export const workbookLimitFields = ["maxRows", "maxCells", "maxTextCharacters", "maxOutputBytes", "maxStyles", "maxSheets", "maxOverflowCharacters", "maxHyperlinks", "maxImageBytes", "maxBufferedCells", "maxBufferedCharacters", "maxMergedRanges", "maxConditionalFormats", "maxDifferentialStyles", "maxCharts", "maxChartPoints", "maxChartTextCharacters", "maxFormulaCharacters", "maxDataValidations", "maxValidationTextCharacters"];
|
|
8
8
|
/** @internal Capture the workbook's known ceilings without dropping supported prototype fields. */
|
package/dist/xlsx/portable.js
CHANGED
|
@@ -16,7 +16,7 @@ function value(result) {
|
|
|
16
16
|
export function portableSheet(options = {}) {
|
|
17
17
|
options = captureFields(options, sheetOptionFields);
|
|
18
18
|
if (options.headerStyle !== undefined)
|
|
19
|
-
throw new TypeError("Workbook-local header styles require the advanced Workbook API; use boldHeader and
|
|
19
|
+
throw new TypeError("Workbook-local header styles require the advanced Workbook API; use boldHeader, headerFill, headerBorder and headerWrap.");
|
|
20
20
|
style(options.alternatingRowStyle);
|
|
21
21
|
style(options.title?.style);
|
|
22
22
|
style(options.footer?.style);
|