@cj-tech-master/excelts 6.2.0 → 7.0.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/README.md +45 -17
- package/README_zh.md +43 -15
- package/dist/browser/index.browser.d.ts +1 -1
- package/dist/browser/index.browser.js +1 -1
- package/dist/browser/index.d.ts +2 -2
- package/dist/browser/index.js +1 -1
- package/dist/browser/modules/excel/stream/workbook-writer.browser.d.ts +0 -2
- package/dist/browser/modules/excel/stream/workbook-writer.d.ts +2 -2
- package/dist/browser/modules/excel/types.d.ts +0 -2
- package/dist/browser/modules/pdf/excel-bridge.d.ts +29 -0
- package/dist/browser/modules/pdf/excel-bridge.js +423 -0
- package/dist/browser/modules/pdf/index.d.ts +22 -24
- package/dist/browser/modules/pdf/index.js +22 -25
- package/dist/browser/modules/pdf/pdf.d.ts +121 -0
- package/dist/browser/modules/pdf/pdf.js +255 -0
- package/dist/browser/modules/pdf/render/layout-engine.d.ts +10 -8
- package/dist/browser/modules/pdf/render/layout-engine.js +115 -209
- package/dist/browser/modules/pdf/render/pdf-exporter.d.ts +9 -62
- package/dist/browser/modules/pdf/render/pdf-exporter.js +38 -78
- package/dist/browser/modules/pdf/render/style-converter.d.ts +20 -18
- package/dist/browser/modules/pdf/render/style-converter.js +24 -23
- package/dist/browser/modules/pdf/types.d.ts +193 -11
- package/dist/browser/modules/pdf/types.js +22 -1
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/modules/pdf/excel-bridge.js +426 -0
- package/dist/cjs/modules/pdf/index.js +25 -28
- package/dist/cjs/modules/pdf/pdf.js +258 -0
- package/dist/cjs/modules/pdf/render/layout-engine.js +116 -210
- package/dist/cjs/modules/pdf/render/pdf-exporter.js +37 -79
- package/dist/cjs/modules/pdf/render/style-converter.js +24 -23
- package/dist/cjs/modules/pdf/types.js +23 -2
- package/dist/esm/index.browser.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/modules/pdf/excel-bridge.js +423 -0
- package/dist/esm/modules/pdf/index.js +22 -25
- package/dist/esm/modules/pdf/pdf.js +255 -0
- package/dist/esm/modules/pdf/render/layout-engine.js +115 -209
- package/dist/esm/modules/pdf/render/pdf-exporter.js +38 -78
- package/dist/esm/modules/pdf/render/style-converter.js +24 -23
- package/dist/esm/modules/pdf/types.js +22 -1
- package/dist/iife/excelts.iife.js +728 -251
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +34 -34
- package/dist/types/index.browser.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/modules/excel/stream/workbook-writer.browser.d.ts +0 -2
- package/dist/types/modules/excel/stream/workbook-writer.d.ts +2 -2
- package/dist/types/modules/excel/types.d.ts +0 -2
- package/dist/types/modules/pdf/excel-bridge.d.ts +29 -0
- package/dist/types/modules/pdf/index.d.ts +22 -24
- package/dist/types/modules/pdf/pdf.d.ts +121 -0
- package/dist/types/modules/pdf/render/layout-engine.d.ts +10 -8
- package/dist/types/modules/pdf/render/pdf-exporter.d.ts +9 -62
- package/dist/types/modules/pdf/render/style-converter.d.ts +20 -18
- package/dist/types/modules/pdf/types.d.ts +193 -11
- package/package.json +1 -1
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PDF Exporter - Main orchestrator for
|
|
2
|
+
* PDF Exporter - Main orchestrator for PDF document generation.
|
|
3
3
|
*
|
|
4
4
|
* Coordinates the layout engine, page renderer, font manager, and PDF writer
|
|
5
|
-
* to produce a complete PDF document from
|
|
5
|
+
* to produce a complete PDF document from a PdfWorkbook data structure.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* import { Workbook, PdfExporter } from "excelts";
|
|
10
|
-
*
|
|
11
|
-
* const workbook = new Workbook();
|
|
12
|
-
* // ... populate workbook ...
|
|
13
|
-
*
|
|
14
|
-
* const exporter = new PdfExporter(workbook);
|
|
15
|
-
* const pdfBuffer = exporter.export({ fitToPage: true });
|
|
16
|
-
* ```
|
|
7
|
+
* This module is fully independent of the Excel module.
|
|
8
|
+
* It is used internally by the public `pdf()` and `excelToPdf()` APIs.
|
|
17
9
|
*/
|
|
18
10
|
import { PdfWriter } from "../core/pdf-writer.js";
|
|
19
11
|
import { PdfDict, pdfRef, pdfNumber, pdfString as pdfStr } from "../core/pdf-object.js";
|
|
20
12
|
import { FontManager, resolvePdfFontName } from "../font/font-manager.js";
|
|
21
13
|
import { parseTtf } from "../font/ttf-parser.js";
|
|
22
14
|
import { initEncryption } from "../core/encryption.js";
|
|
23
|
-
import {
|
|
15
|
+
import { layoutSheet } from "./layout-engine.js";
|
|
24
16
|
import { renderPage, alphaGsName } from "./page-renderer.js";
|
|
25
17
|
import { decodePng } from "./png-decoder.js";
|
|
26
18
|
import { PdfError, PdfRenderError } from "../errors.js";
|
|
@@ -30,22 +22,17 @@ import { argbToPdfColor } from "./style-converter.js";
|
|
|
30
22
|
// Public API
|
|
31
23
|
// =============================================================================
|
|
32
24
|
/**
|
|
33
|
-
* Export a
|
|
25
|
+
* Export a PdfWorkbook to PDF format.
|
|
34
26
|
*
|
|
35
|
-
* @param workbook - The workbook to export
|
|
27
|
+
* @param workbook - The workbook data to export
|
|
36
28
|
* @param options - Export options controlling layout, pagination, and appearance
|
|
37
29
|
* @returns PDF file as a Uint8Array
|
|
38
|
-
* @throws {PdfError} If the workbook has no
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```typescript
|
|
42
|
-
* const pdf = exportPdf(workbook, { fitToPage: true, showGridLines: true });
|
|
43
|
-
* ```
|
|
30
|
+
* @throws {PdfError} If the workbook has no sheets or export fails
|
|
44
31
|
*/
|
|
45
32
|
export function exportPdf(workbook, options) {
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
throw new PdfError("No
|
|
33
|
+
const sheets = selectSheets(workbook, options?.sheets);
|
|
34
|
+
if (sheets.length === 0) {
|
|
35
|
+
throw new PdfError("No sheets to export. The workbook is empty or no sheets matched.");
|
|
49
36
|
}
|
|
50
37
|
const fontManager = new FontManager();
|
|
51
38
|
const writer = new PdfWriter();
|
|
@@ -59,19 +46,19 @@ export function exportPdf(workbook, options) {
|
|
|
59
46
|
throw new PdfRenderError("Failed to parse TrueType font", { cause: err });
|
|
60
47
|
}
|
|
61
48
|
}
|
|
62
|
-
// --- Step 1: Layout all
|
|
49
|
+
// --- Step 1: Layout all sheets ---
|
|
63
50
|
const allPages = [];
|
|
64
|
-
for (const
|
|
51
|
+
for (const sheet of sheets) {
|
|
65
52
|
try {
|
|
66
|
-
const resolved = resolveOptions(options,
|
|
67
|
-
const pages =
|
|
53
|
+
const resolved = resolveOptions(options, sheet);
|
|
54
|
+
const pages = layoutSheet(sheet, resolved, fontManager);
|
|
68
55
|
allPages.push(...pages);
|
|
69
56
|
}
|
|
70
57
|
catch (err) {
|
|
71
|
-
throw new PdfRenderError(`Failed to layout
|
|
58
|
+
throw new PdfRenderError(`Failed to layout sheet "${sheet.name}"`, { cause: err });
|
|
72
59
|
}
|
|
73
60
|
}
|
|
74
|
-
const documentOptions = resolveOptions(options,
|
|
61
|
+
const documentOptions = resolveOptions(options, sheets[0]);
|
|
75
62
|
if (allPages.length === 0) {
|
|
76
63
|
// Create at least one empty page
|
|
77
64
|
allPages.push({
|
|
@@ -80,17 +67,17 @@ export function exportPdf(workbook, options) {
|
|
|
80
67
|
cells: [],
|
|
81
68
|
width: documentOptions.pageSize.width,
|
|
82
69
|
height: documentOptions.pageSize.height,
|
|
83
|
-
sheetName:
|
|
84
|
-
|
|
70
|
+
sheetName: sheets[0]?.name ?? "Sheet1",
|
|
71
|
+
sheetCols: [],
|
|
85
72
|
columnOffsets: [],
|
|
86
73
|
columnWidths: [],
|
|
87
|
-
|
|
74
|
+
sheetRows: [],
|
|
88
75
|
rowYPositions: [],
|
|
89
76
|
rowHeights: [],
|
|
90
77
|
images: []
|
|
91
78
|
});
|
|
92
79
|
}
|
|
93
|
-
// Fix page numbers (they may be off after combining multiple
|
|
80
|
+
// Fix page numbers (they may be off after combining multiple sheets)
|
|
94
81
|
for (let i = 0; i < allPages.length; i++) {
|
|
95
82
|
allPages[i].pageNumber = i + 1;
|
|
96
83
|
}
|
|
@@ -222,7 +209,7 @@ export function exportPdf(workbook, options) {
|
|
|
222
209
|
}
|
|
223
210
|
// --- Step 6: Build catalog ---
|
|
224
211
|
writer.addCatalog(pagesTreeObjNum, outlinesRef);
|
|
225
|
-
// --- Step
|
|
212
|
+
// --- Step 7: Add document info ---
|
|
226
213
|
writer.addInfoDict({
|
|
227
214
|
title: documentOptions.title || workbook.title || undefined,
|
|
228
215
|
author: documentOptions.author || workbook.creator || undefined,
|
|
@@ -237,40 +224,16 @@ export function exportPdf(workbook, options) {
|
|
|
237
224
|
// --- Step 9: Build the PDF ---
|
|
238
225
|
return writer.build();
|
|
239
226
|
}
|
|
240
|
-
/**
|
|
241
|
-
* Class-based API for PDF export (wraps {@link exportPdf}).
|
|
242
|
-
*
|
|
243
|
-
* @example
|
|
244
|
-
* ```typescript
|
|
245
|
-
* const exporter = new PdfExporter(workbook);
|
|
246
|
-
* const pdfBuffer = exporter.export({ fitToPage: true });
|
|
247
|
-
* ```
|
|
248
|
-
*/
|
|
249
|
-
export class PdfExporter {
|
|
250
|
-
constructor(workbook) {
|
|
251
|
-
this.workbook = workbook;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Export the workbook as a PDF document.
|
|
255
|
-
*
|
|
256
|
-
* @param options - Export options controlling layout, pagination, and appearance
|
|
257
|
-
* @returns PDF file as a Uint8Array
|
|
258
|
-
* @throws {PdfError} If the workbook has no worksheets or export fails
|
|
259
|
-
*/
|
|
260
|
-
export(options) {
|
|
261
|
-
return exportPdf(this.workbook, options);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
227
|
// =============================================================================
|
|
265
|
-
//
|
|
228
|
+
// Sheet Selection
|
|
266
229
|
// =============================================================================
|
|
267
230
|
/**
|
|
268
|
-
* Select which
|
|
231
|
+
* Select which sheets to export based on the options.
|
|
269
232
|
*/
|
|
270
|
-
function
|
|
271
|
-
const allSheets = workbook.
|
|
233
|
+
function selectSheets(workbook, sheets) {
|
|
234
|
+
const allSheets = workbook.sheets;
|
|
272
235
|
if (!sheets || sheets.length === 0) {
|
|
273
|
-
// Export all visible
|
|
236
|
+
// Export all visible sheets
|
|
274
237
|
return allSheets.filter(ws => ws.state !== "hidden" && ws.state !== "veryHidden");
|
|
275
238
|
}
|
|
276
239
|
const result = [];
|
|
@@ -282,7 +245,7 @@ function selectWorksheets(workbook, sheets) {
|
|
|
282
245
|
}
|
|
283
246
|
}
|
|
284
247
|
else if (typeof selector === "number") {
|
|
285
|
-
// 1-based position in the
|
|
248
|
+
// 1-based position in the sheets array
|
|
286
249
|
const ws = allSheets[selector - 1];
|
|
287
250
|
if (ws) {
|
|
288
251
|
result.push(ws);
|
|
@@ -297,9 +260,9 @@ function selectWorksheets(workbook, sheets) {
|
|
|
297
260
|
/**
|
|
298
261
|
* Resolve user options with defaults.
|
|
299
262
|
*/
|
|
300
|
-
function resolveOptions(options,
|
|
301
|
-
// Use
|
|
302
|
-
const ps =
|
|
263
|
+
function resolveOptions(options, sheet) {
|
|
264
|
+
// Use sheet's pageSetup as fallback for unspecified options
|
|
265
|
+
const ps = sheet?.pageSetup;
|
|
303
266
|
const pageSize = resolvePageSize(options?.pageSize, ps?.paperSize);
|
|
304
267
|
const orientation = options?.orientation ?? (ps?.orientation === "landscape" ? "landscape" : "portrait");
|
|
305
268
|
const margins = resolveMargins(options?.margins, ps?.margins);
|
|
@@ -309,7 +272,7 @@ function resolveOptions(options, worksheet) {
|
|
|
309
272
|
g: 0.816,
|
|
310
273
|
b: 0.816
|
|
311
274
|
};
|
|
312
|
-
// Use
|
|
275
|
+
// Use sheet's printTitlesRow as fallback for repeatRows
|
|
313
276
|
let repeatRows = options?.repeatRows ?? false;
|
|
314
277
|
if (repeatRows === false && ps?.printTitlesRow) {
|
|
315
278
|
// printTitlesRow format: "1:3" (repeat rows 1-3) or "1" (repeat row 1)
|
|
@@ -337,10 +300,7 @@ function resolveOptions(options, worksheet) {
|
|
|
337
300
|
creator: options?.creator ?? "excelts"
|
|
338
301
|
};
|
|
339
302
|
}
|
|
340
|
-
/**
|
|
341
|
-
* Resolve the page size from options.
|
|
342
|
-
*/
|
|
343
|
-
/** Map Excel PaperSize enum values to PDF page sizes. */
|
|
303
|
+
/** Map PaperSize enum values to PDF page sizes. */
|
|
344
304
|
const PAPER_SIZE_MAP = {
|
|
345
305
|
1: PageSizes.LETTER,
|
|
346
306
|
5: PageSizes.LEGAL,
|
|
@@ -356,19 +316,19 @@ function resolvePageSize(size, paperSize) {
|
|
|
356
316
|
}
|
|
357
317
|
return size;
|
|
358
318
|
}
|
|
359
|
-
// Fallback to
|
|
319
|
+
// Fallback to sheet paperSize
|
|
360
320
|
if (paperSize !== undefined) {
|
|
361
321
|
return PAPER_SIZE_MAP[paperSize] ?? PageSizes.A4;
|
|
362
322
|
}
|
|
363
323
|
return PageSizes.A4;
|
|
364
324
|
}
|
|
365
325
|
/**
|
|
366
|
-
* Resolve margins with defaults.
|
|
367
|
-
* When partial PDF margins are specified, unset sides fall back to
|
|
326
|
+
* Resolve margins with defaults. Sheet margins are in inches, convert to points (×72).
|
|
327
|
+
* When partial PDF margins are specified, unset sides fall back to sheet margins,
|
|
368
328
|
* then to the default 72pt (1 inch).
|
|
369
329
|
*/
|
|
370
330
|
function resolveMargins(margins, wsMargins) {
|
|
371
|
-
// Build a base from
|
|
331
|
+
// Build a base from sheet pageSetup margins (inches → points), or default 72pt
|
|
372
332
|
const base = wsMargins
|
|
373
333
|
? {
|
|
374
334
|
top: wsMargins.top * 72,
|
|
@@ -392,7 +352,7 @@ function resolveMargins(margins, wsMargins) {
|
|
|
392
352
|
// =============================================================================
|
|
393
353
|
/**
|
|
394
354
|
* Build a PDF outlines tree for sheet-level navigation.
|
|
395
|
-
* Creates one bookmark entry per
|
|
355
|
+
* Creates one bookmark entry per sheet, pointing to the first page.
|
|
396
356
|
*/
|
|
397
357
|
function buildOutlines(writer, sheetFirstPage, pageObjNums) {
|
|
398
358
|
const outlinesObjNum = writer.allocObject();
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Converts
|
|
2
|
+
* Converts input styles to PDF rendering parameters.
|
|
3
3
|
*
|
|
4
|
-
* Maps
|
|
4
|
+
* Maps font, color, border, fill, and alignment properties
|
|
5
5
|
* to their PDF equivalents for the layout engine and page renderer.
|
|
6
|
+
*
|
|
7
|
+
* This module is fully independent of the Excel module — it works with
|
|
8
|
+
* the PDF module's own style interfaces (PdfFontStyle, PdfFillData, etc.).
|
|
6
9
|
*/
|
|
7
10
|
// =============================================================================
|
|
8
11
|
// Color Conversion
|
|
9
12
|
// =============================================================================
|
|
10
13
|
/**
|
|
11
|
-
* Convert an
|
|
12
|
-
*
|
|
14
|
+
* Convert an ARGB color string to PDF RGB color.
|
|
15
|
+
* Handles "AARRGGBB" (8-char) and "RRGGBB" (6-char) formats.
|
|
13
16
|
* PDF uses 0-1 floats for each component.
|
|
14
17
|
*/
|
|
15
18
|
export function argbToPdfColor(argb) {
|
|
@@ -46,7 +49,7 @@ export function argbToPdfColor(argb) {
|
|
|
46
49
|
};
|
|
47
50
|
}
|
|
48
51
|
/**
|
|
49
|
-
* Convert
|
|
52
|
+
* Convert a color data object to PDF color.
|
|
50
53
|
* Handles both ARGB and theme-based colors.
|
|
51
54
|
*/
|
|
52
55
|
export function excelColorToPdf(color) {
|
|
@@ -63,7 +66,6 @@ export function excelColorToPdf(color) {
|
|
|
63
66
|
if (!base) {
|
|
64
67
|
return null;
|
|
65
68
|
}
|
|
66
|
-
// Apply tint if present (tint field exists at runtime from XLSX layer)
|
|
67
69
|
const tint = color.tint;
|
|
68
70
|
if (tint !== undefined && tint !== 0) {
|
|
69
71
|
return applyTint(base, tint);
|
|
@@ -73,7 +75,7 @@ export function excelColorToPdf(color) {
|
|
|
73
75
|
return null;
|
|
74
76
|
}
|
|
75
77
|
/**
|
|
76
|
-
* Map
|
|
78
|
+
* Map theme color indices to PDF colors.
|
|
77
79
|
* These are the default Office theme colors.
|
|
78
80
|
*/
|
|
79
81
|
function themeColorToPdf(themeIndex) {
|
|
@@ -127,7 +129,7 @@ export const DEFAULT_COLORS = {
|
|
|
127
129
|
// Font Conversion
|
|
128
130
|
// =============================================================================
|
|
129
131
|
/**
|
|
130
|
-
* Extract font properties
|
|
132
|
+
* Extract font properties for PDF rendering.
|
|
131
133
|
*/
|
|
132
134
|
export function extractFontProperties(font, defaultFamily, defaultSize) {
|
|
133
135
|
const fontFamily = font?.name ?? defaultFamily;
|
|
@@ -143,7 +145,7 @@ export function extractFontProperties(font, defaultFamily, defaultSize) {
|
|
|
143
145
|
// Fill Conversion
|
|
144
146
|
// =============================================================================
|
|
145
147
|
/**
|
|
146
|
-
* Convert
|
|
148
|
+
* Convert a fill to a PDF background color.
|
|
147
149
|
* Only pattern fills with "solid" pattern are supported as PDF backgrounds.
|
|
148
150
|
* Other patterns are approximated or ignored.
|
|
149
151
|
*/
|
|
@@ -152,21 +154,20 @@ export function excelFillToPdfColor(fill) {
|
|
|
152
154
|
return null;
|
|
153
155
|
}
|
|
154
156
|
if (fill.type === "pattern") {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return excelColorToPdf(patternFill.fgColor);
|
|
157
|
+
if (fill.pattern === "solid" && fill.fgColor) {
|
|
158
|
+
return excelColorToPdf(fill.fgColor);
|
|
158
159
|
}
|
|
159
|
-
if (
|
|
160
|
+
if (fill.pattern === "none") {
|
|
160
161
|
return null;
|
|
161
162
|
}
|
|
162
163
|
// For other patterns, use fgColor as approximation
|
|
163
|
-
if (
|
|
164
|
-
return excelColorToPdf(
|
|
164
|
+
if (fill.fgColor) {
|
|
165
|
+
return excelColorToPdf(fill.fgColor);
|
|
165
166
|
}
|
|
166
167
|
}
|
|
167
168
|
if (fill.type === "gradient") {
|
|
168
169
|
// For gradient fills, use the first stop color as approximation
|
|
169
|
-
if (
|
|
170
|
+
if (fill.stops && fill.stops.length > 0) {
|
|
170
171
|
return excelColorToPdf(fill.stops[0].color);
|
|
171
172
|
}
|
|
172
173
|
}
|
|
@@ -176,7 +177,7 @@ export function excelFillToPdfColor(fill) {
|
|
|
176
177
|
// Border Conversion
|
|
177
178
|
// =============================================================================
|
|
178
179
|
/**
|
|
179
|
-
* Map
|
|
180
|
+
* Map border styles to PDF line widths.
|
|
180
181
|
*/
|
|
181
182
|
function borderStyleToLineWidth(style) {
|
|
182
183
|
switch (style) {
|
|
@@ -211,7 +212,7 @@ function borderStyleToLineWidth(style) {
|
|
|
211
212
|
}
|
|
212
213
|
}
|
|
213
214
|
/**
|
|
214
|
-
* Map
|
|
215
|
+
* Map border styles to PDF dash patterns.
|
|
215
216
|
* An empty array means a solid line.
|
|
216
217
|
*/
|
|
217
218
|
function borderStyleToDashPattern(style) {
|
|
@@ -236,7 +237,7 @@ function borderStyleToDashPattern(style) {
|
|
|
236
237
|
}
|
|
237
238
|
}
|
|
238
239
|
/**
|
|
239
|
-
* Convert a single
|
|
240
|
+
* Convert a single border side to a PDF LayoutBorder.
|
|
240
241
|
*/
|
|
241
242
|
function convertBorder(border) {
|
|
242
243
|
if (!border || !border.style) {
|
|
@@ -249,7 +250,7 @@ function convertBorder(border) {
|
|
|
249
250
|
};
|
|
250
251
|
}
|
|
251
252
|
/**
|
|
252
|
-
* Convert
|
|
253
|
+
* Convert border data to PDF LayoutBorders.
|
|
253
254
|
*/
|
|
254
255
|
export function excelBordersToPdf(borders) {
|
|
255
256
|
if (!borders) {
|
|
@@ -266,7 +267,7 @@ export function excelBordersToPdf(borders) {
|
|
|
266
267
|
// Alignment Conversion
|
|
267
268
|
// =============================================================================
|
|
268
269
|
/**
|
|
269
|
-
* Convert
|
|
270
|
+
* Convert horizontal alignment to PDF alignment.
|
|
270
271
|
*/
|
|
271
272
|
export function excelHAlignToPdf(alignment) {
|
|
272
273
|
if (!alignment?.horizontal) {
|
|
@@ -287,11 +288,11 @@ export function excelHAlignToPdf(alignment) {
|
|
|
287
288
|
}
|
|
288
289
|
}
|
|
289
290
|
/**
|
|
290
|
-
* Convert
|
|
291
|
+
* Convert vertical alignment to PDF alignment.
|
|
291
292
|
*/
|
|
292
293
|
export function excelVAlignToPdf(alignment) {
|
|
293
294
|
if (!alignment?.vertical) {
|
|
294
|
-
return "bottom"; //
|
|
295
|
+
return "bottom"; // Default is bottom
|
|
295
296
|
}
|
|
296
297
|
switch (alignment.vertical) {
|
|
297
298
|
case "top":
|
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type definitions for the PDF module.
|
|
3
|
-
* Covers export options, page layout, and internal rendering models.
|
|
3
|
+
* Covers input data models, export options, page layout, and internal rendering models.
|
|
4
|
+
*
|
|
5
|
+
* The input data models (PdfWorkbook, PdfSheetData, etc.) are fully independent of
|
|
6
|
+
* the Excel module, allowing the PDF engine to be used standalone.
|
|
4
7
|
*/
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// PDF Input Data Model (Excel-independent)
|
|
10
|
+
// =============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Cell value type discriminator for the PDF engine.
|
|
13
|
+
*/
|
|
14
|
+
export const PdfCellType = {
|
|
15
|
+
Empty: 0,
|
|
16
|
+
String: 1,
|
|
17
|
+
Number: 2,
|
|
18
|
+
Boolean: 3,
|
|
19
|
+
Date: 4,
|
|
20
|
+
RichText: 5,
|
|
21
|
+
Error: 6,
|
|
22
|
+
Formula: 7,
|
|
23
|
+
Hyperlink: 8,
|
|
24
|
+
Merge: 9
|
|
25
|
+
};
|
|
5
26
|
/**
|
|
6
27
|
* Predefined page sizes.
|
|
7
28
|
*/
|