@pdfme/schemas 6.2.0 → 6.2.1-dev.13
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/dist/barcodes/helper.d.ts +10 -1
- package/dist/{builtins-C-2wyB_3.js → builtins-BEweDprE.js} +40 -26
- package/dist/builtins-BEweDprE.js.map +1 -0
- package/dist/builtins.js +1 -1
- package/dist/index.js +45 -13
- package/dist/index.js.map +1 -1
- package/dist/text/richTextPdfRender.d.ts +1 -0
- package/dist/{utils-CPYF2FY_.js → utils-BhkbT1F9.js} +22 -12
- package/dist/utils-BhkbT1F9.js.map +1 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +2 -2
- package/package.json +1 -1
- package/dist/builtins-C-2wyB_3.js.map +0 -1
- package/dist/utils-CPYF2FY_.js.map +0 -1
|
@@ -6,9 +6,18 @@ export declare const validateBarcodeInput: (type: BarcodeTypes, input: string) =
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const barCodeType2Bcid: (type: BarcodeTypes) => "code128" | "code39" | "ean13" | "ean8" | "gs1datamatrix" | "itf14" | "japanpost" | "pdf417" | "qrcode" | "rationalizedCodabar" | "upca" | "upce";
|
|
8
8
|
/**
|
|
9
|
-
* Strip hash from the beginning of HTML hex color codes for the bwip.js lib
|
|
9
|
+
* Strip hash from the beginning of HTML hex color codes for the bwip.js lib.
|
|
10
|
+
* Any '#RGBA'/'#RRGGBBAA' alpha channel is dropped first (rendered opaque, like
|
|
11
|
+
* AcroForm colors): bwip-js has no alpha support — it reads 8-digit hex as CMYK
|
|
12
|
+
* and throws on 4-digit hex. Hash-less colors pass through untouched because
|
|
13
|
+
* bwip-js natively treats those as RRGGBB/CCMMYYKK.
|
|
10
14
|
*/
|
|
11
15
|
export declare const mapHexColorForBwipJsLib: (color: string | undefined, fallback?: string) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Barcode colors historically accept bwip-js style hex without a leading '#';
|
|
18
|
+
* CSS and pdfme's color utils require the '#', so add it when missing.
|
|
19
|
+
*/
|
|
20
|
+
export declare const ensureHexColorHash: (color: string | undefined) => string | undefined;
|
|
12
21
|
export type BarcodeRenderRuntime = 'document-canvas' | 'offscreencanvas' | 'node-buffer';
|
|
13
22
|
/**
|
|
14
23
|
* Pick a barcode renderer from capabilities, not `typeof window`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { $ as TEXT_FORMAT_INLINE_MARKDOWN, B as DEFAULT_DYNAMIC_FIT, C as getLineAlignment, D as getBoxContentArea, E as createBoxDimension, G as DYNAMIC_FIT_HORIZONTAL, H as DEFAULT_FONT_VARIANT_FALLBACK, I as ALIGN_RIGHT, J as FONT_VARIANT_FALLBACK_PLAIN, K as DYNAMIC_FIT_VERTICAL, L as CODE_BACKGROUND_COLOR, M as hasBoxDimension, N as ALIGN_CENTER, O as getBoxDimensionPropPanelSchema, P as ALIGN_JUSTIFY, Q as SYNTHETIC_BOLD_OFFSET_RATIO, R as CODE_HORIZONTAL_PADDING, S as wrapTextToSize, T as splitGraphemes, U as DEFAULT_TEXT_FORMAT, V as DEFAULT_FONT_COLOR, W as DEFAULT_TEXT_OVERFLOW, X as PLACEHOLDER_FONT_COLOR, Y as FONT_VARIANT_FALLBACK_SYNTHETIC, Z as SYNTHETIC_BOLD_CSS_TEXT_SHADOW, b as splitTextToSize, d as calculateDynamicFontSize, et as TEXT_FORMAT_PLAIN, f as fetchRemoteFontData, g as getFontKitFont, h as getFontDescentInPt, it as VERTICAL_ALIGN_MIDDLE, k as getBoxInsets, m as getBrowserVerticalFontAdjustments, nt as TEXT_OVERFLOW_VISIBLE, q as FONT_VARIANT_FALLBACK_ERROR, rt as VERTICAL_ALIGN_BOTTOM, tt as TEXT_OVERFLOW_EXPAND, u as getTextLineRange, v as heightOfFontAtSize, x as widthOfTextAtSize, y as isFirefox, z as DEFAULT_ALIGNMENT } from "./splitRange-B6311Noc.js";
|
|
2
2
|
import { d as layoutRichTextLines, g as stripInlineMarkdown, h as parseInlineMarkdown, l as calculateDynamicRichTextFontSize, p as resolveRichTextRuns, s as plainTextLinesToValue, t as applyTextLineRange, u as isInlineMarkdownTextSchema } from "./measure-BarlRI1L.js";
|
|
3
3
|
import { c as HEX_COLOR_PATTERN } from "./dynamicTemplate-DkTVIMNr.js";
|
|
4
|
-
import {
|
|
4
|
+
import { a as createSvgStr, f as rotatePoint, l as isEditable, n as applyAlphaToOpacity, p as splitHexAlpha, r as convertForPdfLayoutProps, s as hex2PrintingColor } from "./utils-BhkbT1F9.js";
|
|
5
5
|
import { DEFAULT_FONT_NAME, getDefaultFont, getFallbackFontName, getInternalLinkTarget, isBlankPdf, mm2pt, normalizeLinkHref, normalizeSafeLinkUri, registerInternalLinkAnnotation } from "@pdfme/common";
|
|
6
6
|
import { PDFName, PDFString } from "@pdfme/pdf-lib";
|
|
7
7
|
import { AlignCenter, AlignJustify, AlignLeft, AlignRight, ArrowDownToLine, ArrowUpToLine, Strikethrough, TextCursorInput, Underline } from "lucide";
|
|
@@ -115,7 +115,7 @@ var getLinkAnnotationRect = (arg) => {
|
|
|
115
115
|
});
|
|
116
116
|
};
|
|
117
117
|
var drawRun = (arg) => {
|
|
118
|
-
const { page, pdfLib, run, pdfFont, x, y, rotate, pivotPoint, fontSize, lineHeight, color, opacity, colorType, characterSpacing, strikethrough, underline } = arg;
|
|
118
|
+
const { page, pdfLib, run, pdfFont, x, y, rotate, pivotPoint, fontSize, lineHeight, color, opacity, textOpacity, colorType, characterSpacing, strikethrough, underline } = arg;
|
|
119
119
|
const runWidth = getRunWidth(run, fontSize, characterSpacing);
|
|
120
120
|
const codePadding = run.code ? CODE_HORIZONTAL_PADDING : 0;
|
|
121
121
|
const textX = x + codePadding;
|
|
@@ -150,7 +150,7 @@ var drawRun = (arg) => {
|
|
|
150
150
|
pivotPoint,
|
|
151
151
|
fontSize,
|
|
152
152
|
color,
|
|
153
|
-
opacity
|
|
153
|
+
opacity: textOpacity
|
|
154
154
|
});
|
|
155
155
|
if (underline && runWidth > 0) drawDecorationLine({
|
|
156
156
|
page,
|
|
@@ -161,7 +161,7 @@ var drawRun = (arg) => {
|
|
|
161
161
|
pivotPoint,
|
|
162
162
|
fontSize,
|
|
163
163
|
color,
|
|
164
|
-
opacity
|
|
164
|
+
opacity: textOpacity
|
|
165
165
|
});
|
|
166
166
|
const drawAt = (drawX) => {
|
|
167
167
|
const point = rotate.angle === 0 ? {
|
|
@@ -179,7 +179,7 @@ var drawRun = (arg) => {
|
|
|
179
179
|
color,
|
|
180
180
|
lineHeight: lineHeight * fontSize,
|
|
181
181
|
font: pdfFont,
|
|
182
|
-
opacity,
|
|
182
|
+
opacity: textOpacity,
|
|
183
183
|
...run.syntheticItalic ? { ySkew: pdfLib.degrees(12) } : {}
|
|
184
184
|
});
|
|
185
185
|
};
|
|
@@ -190,7 +190,8 @@ var drawRun = (arg) => {
|
|
|
190
190
|
}
|
|
191
191
|
};
|
|
192
192
|
var renderInlineMarkdownText = async (arg) => {
|
|
193
|
-
const { value, schema, font, embedPdfFont, fontKitFont, pdfDoc, page, pdfLib, _cache, colorType, fontSize, color, alignment, verticalAlignment, lineHeight, characterSpacing, x, y, width, height, pivotPoint, rotate, opacity } = arg;
|
|
193
|
+
const { value, schema, font, embedPdfFont, fontKitFont, pdfDoc, page, pdfLib, _cache, colorType, fontSize, color, alignment, verticalAlignment, lineHeight, characterSpacing, x, y, width, height, pivotPoint, rotate, opacity, colorAlpha } = arg;
|
|
194
|
+
const textOpacity = applyAlphaToOpacity(opacity, colorAlpha);
|
|
194
195
|
const richTextRuns = parseInlineMarkdown(value);
|
|
195
196
|
const resolvedRuns = await resolveRichTextRuns({
|
|
196
197
|
runs: richTextRuns,
|
|
@@ -240,7 +241,7 @@ var renderInlineMarkdownText = async (arg) => {
|
|
|
240
241
|
pivotPoint,
|
|
241
242
|
fontSize,
|
|
242
243
|
color,
|
|
243
|
-
opacity
|
|
244
|
+
opacity: textOpacity
|
|
244
245
|
});
|
|
245
246
|
if (schema.underline) drawDecorationLine({
|
|
246
247
|
page,
|
|
@@ -251,7 +252,7 @@ var renderInlineMarkdownText = async (arg) => {
|
|
|
251
252
|
pivotPoint,
|
|
252
253
|
fontSize,
|
|
253
254
|
color,
|
|
254
|
-
opacity
|
|
255
|
+
opacity: textOpacity
|
|
255
256
|
});
|
|
256
257
|
}
|
|
257
258
|
line.runs.reduce((currentX, run, runIndex) => {
|
|
@@ -270,6 +271,7 @@ var renderInlineMarkdownText = async (arg) => {
|
|
|
270
271
|
lineHeight,
|
|
271
272
|
color,
|
|
272
273
|
opacity,
|
|
274
|
+
textOpacity,
|
|
273
275
|
colorType,
|
|
274
276
|
characterSpacing: spacing,
|
|
275
277
|
strikethrough: Boolean(run.strikethrough),
|
|
@@ -326,13 +328,14 @@ var embedAndGetFont = (arg) => {
|
|
|
326
328
|
const pdfFontCache = getPdfFontCache(_cache);
|
|
327
329
|
const cachedFont = pdfFontCache[fontName];
|
|
328
330
|
if (cachedFont) return cachedFont;
|
|
329
|
-
const fontValue = font[fontName];
|
|
330
|
-
if (!fontValue) return Promise.reject(/* @__PURE__ */ new Error(`[@pdfme/schemas] Font "${fontName}" is not found.`));
|
|
331
331
|
const pdfFontPromise = (async () => {
|
|
332
|
+
const fontValue = font[fontName];
|
|
333
|
+
if (!fontValue) throw new Error(`[@pdfme/schemas] Font "${fontName}" is not found.`);
|
|
332
334
|
let fontData = fontValue.data;
|
|
333
335
|
if (typeof fontData === "string" && fontData.startsWith("http")) fontData = await fetchRemoteFontData(fontData);
|
|
334
336
|
return pdfDoc.embedFont(fontData, { subset: typeof fontValue.subset === "undefined" ? true : fontValue.subset });
|
|
335
337
|
})();
|
|
338
|
+
pdfFontPromise.catch(() => {});
|
|
336
339
|
pdfFontCache[fontName] = pdfFontPromise;
|
|
337
340
|
return pdfFontPromise;
|
|
338
341
|
};
|
|
@@ -344,14 +347,16 @@ var getFontProp = ({ value, fontKitFont, schema, basePdf, colorType, fontSize: r
|
|
|
344
347
|
fontKitFont,
|
|
345
348
|
value
|
|
346
349
|
}) : schema.fontSize ?? 13);
|
|
347
|
-
const color =
|
|
350
|
+
const { color: fontColorHex, alpha: colorAlpha } = splitHexAlpha(schema.fontColor || "#000000");
|
|
351
|
+
const color = hex2PrintingColor(fontColorHex, colorType);
|
|
348
352
|
return {
|
|
349
353
|
alignment: schema.alignment ?? "left",
|
|
350
354
|
verticalAlignment: schema.verticalAlignment ?? "top",
|
|
351
355
|
lineHeight: schema.lineHeight ?? 1,
|
|
352
356
|
characterSpacing: schema.characterSpacing ?? 0,
|
|
353
357
|
fontSize,
|
|
354
|
-
color
|
|
358
|
+
color,
|
|
359
|
+
colorAlpha
|
|
355
360
|
};
|
|
356
361
|
};
|
|
357
362
|
var pdfRender = async (arg) => {
|
|
@@ -393,7 +398,7 @@ var pdfRender = async (arg) => {
|
|
|
393
398
|
_cache
|
|
394
399
|
});
|
|
395
400
|
const fontKitFont = await getFontKitFont(schema.fontName, font, _cache);
|
|
396
|
-
const { fontSize, color, alignment, verticalAlignment, lineHeight, characterSpacing } = getFontProp({
|
|
401
|
+
const { fontSize, color, colorAlpha, alignment, verticalAlignment, lineHeight, characterSpacing } = getFontProp({
|
|
397
402
|
value: enableInlineMarkdown ? stripInlineMarkdown(value) : value,
|
|
398
403
|
fontKitFont,
|
|
399
404
|
schema,
|
|
@@ -406,6 +411,7 @@ var pdfRender = async (arg) => {
|
|
|
406
411
|
_cache
|
|
407
412
|
}) : void 0
|
|
408
413
|
});
|
|
414
|
+
const textOpacity = applyAlphaToOpacity(opacity, colorAlpha);
|
|
409
415
|
if (enableInlineMarkdown) {
|
|
410
416
|
await renderInlineMarkdownText({
|
|
411
417
|
value,
|
|
@@ -435,7 +441,8 @@ var pdfRender = async (arg) => {
|
|
|
435
441
|
height: contentHeight,
|
|
436
442
|
pivotPoint,
|
|
437
443
|
rotate,
|
|
438
|
-
opacity
|
|
444
|
+
opacity,
|
|
445
|
+
colorAlpha
|
|
439
446
|
});
|
|
440
447
|
return;
|
|
441
448
|
}
|
|
@@ -487,7 +494,7 @@ var pdfRender = async (arg) => {
|
|
|
487
494
|
}, pivotPoint, rotate.angle),
|
|
488
495
|
thickness: 1 / 12 * fontSize,
|
|
489
496
|
color,
|
|
490
|
-
opacity
|
|
497
|
+
opacity: textOpacity
|
|
491
498
|
});
|
|
492
499
|
}
|
|
493
500
|
if (schema.underline && textWidth > 0) {
|
|
@@ -504,7 +511,7 @@ var pdfRender = async (arg) => {
|
|
|
504
511
|
}, pivotPoint, rotate.angle),
|
|
505
512
|
thickness: 1 / 12 * fontSize,
|
|
506
513
|
color,
|
|
507
|
-
opacity
|
|
514
|
+
opacity: textOpacity
|
|
508
515
|
});
|
|
509
516
|
}
|
|
510
517
|
if (rotate.angle !== 0) {
|
|
@@ -524,7 +531,7 @@ var pdfRender = async (arg) => {
|
|
|
524
531
|
color,
|
|
525
532
|
lineHeight: lineHeight * fontSize,
|
|
526
533
|
font: pdfFontValue,
|
|
527
|
-
opacity
|
|
534
|
+
opacity: textOpacity
|
|
528
535
|
});
|
|
529
536
|
});
|
|
530
537
|
};
|
|
@@ -548,21 +555,24 @@ var drawTextBoxDecoration = (arg) => {
|
|
|
548
555
|
height: rect.height,
|
|
549
556
|
rotate,
|
|
550
557
|
color: rect.color,
|
|
551
|
-
opacity
|
|
558
|
+
opacity: opacity * rect.alpha
|
|
552
559
|
});
|
|
553
560
|
};
|
|
554
561
|
if (schema.backgroundColor) {
|
|
555
|
-
const color =
|
|
562
|
+
const { color: bgHex, alpha } = splitHexAlpha(schema.backgroundColor);
|
|
563
|
+
const color = hex2PrintingColor(bgHex, colorType);
|
|
556
564
|
if (color) drawRectangle({
|
|
557
565
|
x,
|
|
558
566
|
y,
|
|
559
567
|
width,
|
|
560
568
|
height,
|
|
561
|
-
color
|
|
569
|
+
color,
|
|
570
|
+
alpha
|
|
562
571
|
});
|
|
563
572
|
}
|
|
564
573
|
if (!schema.borderColor || !hasBoxDimension(schema.borderWidth)) return;
|
|
565
|
-
const color =
|
|
574
|
+
const { color: borderHex, alpha } = splitHexAlpha(schema.borderColor);
|
|
575
|
+
const color = hex2PrintingColor(borderHex, colorType);
|
|
566
576
|
if (!color) return;
|
|
567
577
|
const top = mm2pt(borderWidth.top);
|
|
568
578
|
const right = mm2pt(borderWidth.right);
|
|
@@ -573,28 +583,32 @@ var drawTextBoxDecoration = (arg) => {
|
|
|
573
583
|
y: y + height - top,
|
|
574
584
|
width,
|
|
575
585
|
height: top,
|
|
576
|
-
color
|
|
586
|
+
color,
|
|
587
|
+
alpha
|
|
577
588
|
});
|
|
578
589
|
drawRectangle({
|
|
579
590
|
x: x + width - right,
|
|
580
591
|
y,
|
|
581
592
|
width: right,
|
|
582
593
|
height,
|
|
583
|
-
color
|
|
594
|
+
color,
|
|
595
|
+
alpha
|
|
584
596
|
});
|
|
585
597
|
drawRectangle({
|
|
586
598
|
x,
|
|
587
599
|
y,
|
|
588
600
|
width,
|
|
589
601
|
height: bottom,
|
|
590
|
-
color
|
|
602
|
+
color,
|
|
603
|
+
alpha
|
|
591
604
|
});
|
|
592
605
|
drawRectangle({
|
|
593
606
|
x,
|
|
594
607
|
y,
|
|
595
608
|
width: left,
|
|
596
609
|
height,
|
|
597
|
-
color
|
|
610
|
+
color,
|
|
611
|
+
alpha
|
|
598
612
|
});
|
|
599
613
|
};
|
|
600
614
|
//#endregion
|
|
@@ -1386,4 +1400,4 @@ var builtInPlugins = { Text: textSchema };
|
|
|
1386
1400
|
//#endregion
|
|
1387
1401
|
export { mapVerticalAlignToFlex as a, Formatter as c, embedAndGetFont as d, makeElementPlainTextContentEditable as i, getExtraFormatterSchema as l, textSchema as n, uiRender as o, buildStyledTextContainer as r, propPanel as s, builtInPlugins as t, pdfRender as u };
|
|
1388
1402
|
|
|
1389
|
-
//# sourceMappingURL=builtins-
|
|
1403
|
+
//# sourceMappingURL=builtins-BEweDprE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins-BEweDprE.js","names":[],"sources":["../src/text/linkAnnotation.ts","../src/text/richTextPdfRender.ts","../src/text/overflow.ts","../src/pdfFont.ts","../src/text/pdfRender.ts","../src/text/icons/index.ts","../src/text/extraFormatter.ts","../src/text/propPanel.ts","../src/text/uiRender.ts","../src/text/index.ts","../src/builtins.ts"],"sourcesContent":["import { normalizeSafeLinkUri } from '@pdfme/common';\nimport type { PDFDocument, PDFPage } from '@pdfme/pdf-lib';\nimport { PDFName, PDFString } from '@pdfme/pdf-lib';\n\nexport type LinkAnnotationRect = {\n x: number;\n y: number;\n width: number;\n height: number;\n};\n\nexport const addUriLinkAnnotation = (arg: {\n pdfDoc: PDFDocument;\n page: PDFPage;\n uri: string;\n rect: LinkAnnotationRect;\n borderWidth?: number;\n}) => {\n const { pdfDoc, page, uri, rect, borderWidth = 0 } = arg;\n const safeUri = normalizeSafeLinkUri(uri);\n if (!safeUri || rect.width <= 0 || rect.height <= 0) return;\n\n const annotationRef = pdfDoc.context.register(\n pdfDoc.context.obj({\n Type: PDFName.of('Annot'),\n Subtype: PDFName.of('Link'),\n Rect: [rect.x, rect.y, rect.x + rect.width, rect.y + rect.height],\n Border: [0, 0, borderWidth],\n A: {\n Type: PDFName.of('Action'),\n S: PDFName.of('URI'),\n URI: PDFString.of(safeUri),\n },\n }),\n );\n\n page.node.addAnnot(annotationRef);\n};\n","import type { PDFFont, Rotation } from '@pdfme/pdf-lib';\nimport type { ColorType, Font, PDFRenderProps } from '@pdfme/common';\nimport { getInternalLinkTarget, registerInternalLinkAnnotation } from '@pdfme/common';\nimport type { Font as FontKitFont } from 'fontkit';\nimport {\n CODE_BACKGROUND_COLOR,\n CODE_HORIZONTAL_PADDING,\n SYNTHETIC_BOLD_PDF_EXTRA_DRAWS,\n SYNTHETIC_BOLD_OFFSET_RATIO,\n SYNTHETIC_ITALIC_SKEW_DEGREES,\n VERTICAL_ALIGN_BOTTOM,\n VERTICAL_ALIGN_MIDDLE,\n VERTICAL_ALIGN_TOP,\n} from './constants.js';\nimport { getFontDescentInPt, heightOfFontAtSize, widthOfTextAtSize } from './helper.js';\nimport { addUriLinkAnnotation, type LinkAnnotationRect } from './linkAnnotation.js';\nimport { parseInlineMarkdown } from './inlineMarkdown.js';\nimport { applyTextLineRange } from './measure.js';\nimport { layoutRichTextLines, resolveRichTextRuns, type RichTextLineRun } from './richText.js';\nimport { getLineAlignment } from './wrap.js';\nimport type { TextSchema } from './types.js';\nimport { hex2PrintingColor, rotatePoint, applyAlphaToOpacity } from '../utils.js';\nimport { getTextLineRange } from '../splitRange.js';\n\ntype TextColor = ReturnType<typeof hex2PrintingColor>;\n\nconst getSyntheticBoldWidth = (run: RichTextLineRun, fontSize: number) =>\n run.syntheticBold ? fontSize * SYNTHETIC_BOLD_OFFSET_RATIO * SYNTHETIC_BOLD_PDF_EXTRA_DRAWS : 0;\n\nconst getSyntheticItalicWidth = (run: RichTextLineRun, fontSize: number) =>\n run.syntheticItalic\n ? heightOfFontAtSize(run.fontKitFont, fontSize) *\n Math.tan((SYNTHETIC_ITALIC_SKEW_DEGREES * Math.PI) / 180)\n : 0;\n\nconst getRunWidth = (run: RichTextLineRun, fontSize: number, characterSpacing: number) =>\n widthOfTextAtSize(run.text, run.fontKitFont, fontSize, characterSpacing) +\n getSyntheticBoldWidth(run, fontSize) +\n getSyntheticItalicWidth(run, fontSize) +\n (run.code ? CODE_HORIZONTAL_PADDING * 2 : 0);\n\nconst getPdfFontFromObj = (run: RichTextLineRun, pdfFontObj: Record<string, PDFFont>) => {\n const pdfFont = pdfFontObj[run.fontName];\n if (!pdfFont) {\n throw new Error(`[@pdfme/schemas] Missing embedded font \"${run.fontName}\".`);\n }\n return pdfFont;\n};\n\nconst embedFontsForRuns = async (\n runs: RichTextLineRun[],\n embedPdfFont: (fontName: string) => Promise<PDFFont>,\n) => {\n const fontNames = Array.from(new Set(runs.map((run) => run.fontName)));\n const pdfFonts = await Promise.all(\n fontNames.map(async (fontName) => [fontName, await embedPdfFont(fontName)] as const),\n );\n return Object.fromEntries(pdfFonts);\n};\n\nconst drawDecorationLine = (arg: {\n page: PDFRenderProps<TextSchema>['page'];\n x: number;\n y: number;\n width: number;\n rotate: Rotation;\n pivotPoint: { x: number; y: number };\n fontSize: number;\n color: TextColor;\n opacity: number | undefined;\n}) => {\n const { page, x, y, width, rotate, pivotPoint, fontSize, color, opacity } = arg;\n if (width <= 0) return;\n\n page.drawLine({\n start: rotatePoint({ x, y }, pivotPoint, rotate.angle),\n end: rotatePoint({ x: x + width, y }, pivotPoint, rotate.angle),\n thickness: (1 / 12) * fontSize,\n color,\n opacity,\n });\n};\n\nconst getAxisAlignedRect = (arg: {\n x: number;\n y: number;\n width: number;\n height: number;\n rotate: Rotation;\n pivotPoint: { x: number; y: number };\n}): LinkAnnotationRect => {\n const { x, y, width, height, rotate, pivotPoint } = arg;\n if (rotate.angle === 0) return { x, y, width, height };\n\n const points = [\n { x, y },\n { x: x + width, y },\n { x: x + width, y: y + height },\n { x, y: y + height },\n ].map((point) => rotatePoint(point, pivotPoint, rotate.angle));\n const xs = points.map((point) => point.x);\n const ys = points.map((point) => point.y);\n const minX = Math.min(...xs);\n const minY = Math.min(...ys);\n\n return {\n x: minX,\n y: minY,\n width: Math.max(...xs) - minX,\n height: Math.max(...ys) - minY,\n };\n};\n\nconst getLinkAnnotationRect = (arg: {\n run: RichTextLineRun;\n x: number;\n y: number;\n width: number;\n rotate: Rotation;\n pivotPoint: { x: number; y: number };\n fontSize: number;\n}): LinkAnnotationRect => {\n const { run, x, y, width, rotate, pivotPoint, fontSize } = arg;\n const textHeight = heightOfFontAtSize(run.fontKitFont, fontSize);\n const descent = getFontDescentInPt(run.fontKitFont, fontSize);\n const rectY = y + descent;\n const rectHeight = textHeight - descent;\n\n return getAxisAlignedRect({\n x,\n y: rectY,\n width,\n height: rectHeight,\n rotate,\n pivotPoint,\n });\n};\n\nconst drawRun = (arg: {\n page: PDFRenderProps<TextSchema>['page'];\n pdfLib: PDFRenderProps<TextSchema>['pdfLib'];\n run: RichTextLineRun;\n pdfFont: PDFFont;\n x: number;\n y: number;\n rotate: Rotation;\n pivotPoint: { x: number; y: number };\n fontSize: number;\n lineHeight: number;\n color: TextColor;\n opacity: number | undefined;\n textOpacity: number | undefined;\n colorType: ColorType;\n characterSpacing: number;\n strikethrough: boolean;\n underline: boolean;\n}) => {\n const {\n page,\n pdfLib,\n run,\n pdfFont,\n x,\n y,\n rotate,\n pivotPoint,\n fontSize,\n lineHeight,\n color,\n opacity,\n textOpacity,\n colorType,\n characterSpacing,\n strikethrough,\n underline,\n } = arg;\n const runWidth = getRunWidth(run, fontSize, characterSpacing);\n const codePadding = run.code ? CODE_HORIZONTAL_PADDING : 0;\n const textX = x + codePadding;\n const textWidth = runWidth - codePadding * 2;\n const textHeight = heightOfFontAtSize(run.fontKitFont, fontSize);\n\n if (run.code) {\n const bgX = x;\n const bgY = y - textHeight * 0.2;\n const bgPoint =\n rotate.angle === 0\n ? { x: bgX, y: bgY }\n : rotatePoint({ x: bgX, y: bgY }, pivotPoint, rotate.angle);\n page.drawRectangle({\n x: bgPoint.x,\n y: bgPoint.y,\n width: runWidth,\n height: textHeight * 1.2,\n rotate,\n color: hex2PrintingColor(CODE_BACKGROUND_COLOR, colorType),\n opacity,\n });\n }\n\n if (strikethrough && runWidth > 0) {\n drawDecorationLine({\n page,\n x: textX,\n y: y + textHeight / 3,\n width: textWidth,\n rotate,\n pivotPoint,\n fontSize,\n color,\n opacity: textOpacity,\n });\n }\n\n if (underline && runWidth > 0) {\n drawDecorationLine({\n page,\n x: textX,\n y: y - textHeight / 12,\n width: textWidth,\n rotate,\n pivotPoint,\n fontSize,\n color,\n opacity: textOpacity,\n });\n }\n\n const drawAt = (drawX: number) => {\n const point =\n rotate.angle === 0 ? { x: drawX, y } : rotatePoint({ x: drawX, y }, pivotPoint, rotate.angle);\n page.drawText(run.text, {\n x: point.x,\n y: point.y,\n rotate,\n size: fontSize,\n color,\n lineHeight: lineHeight * fontSize,\n font: pdfFont,\n opacity: textOpacity,\n ...(run.syntheticItalic ? { ySkew: pdfLib.degrees(SYNTHETIC_ITALIC_SKEW_DEGREES) } : {}),\n });\n };\n\n drawAt(textX);\n if (run.syntheticBold) {\n const offset = fontSize * SYNTHETIC_BOLD_OFFSET_RATIO;\n for (let i = 1; i <= SYNTHETIC_BOLD_PDF_EXTRA_DRAWS; i++) {\n drawAt(textX + offset * i);\n }\n }\n};\n\nexport const renderInlineMarkdownText = async (arg: {\n value: string;\n schema: TextSchema;\n font: Font;\n embedPdfFont: (fontName: string) => Promise<PDFFont>;\n fontKitFont: FontKitFont;\n pdfDoc: PDFRenderProps<TextSchema>['pdfDoc'];\n page: PDFRenderProps<TextSchema>['page'];\n pdfLib: PDFRenderProps<TextSchema>['pdfLib'];\n _cache: Map<string | number, unknown>;\n colorType: ColorType;\n fontSize: number;\n color: TextColor;\n alignment: string;\n verticalAlignment: string;\n lineHeight: number;\n characterSpacing: number;\n x: number;\n y: number;\n width: number;\n height: number;\n pivotPoint: { x: number; y: number };\n rotate: Rotation;\n opacity: number | undefined;\n colorAlpha: number;\n}) => {\n const {\n value,\n schema,\n font,\n embedPdfFont,\n fontKitFont,\n pdfDoc,\n page,\n pdfLib,\n _cache,\n colorType,\n fontSize,\n color,\n alignment,\n verticalAlignment,\n lineHeight,\n characterSpacing,\n x,\n y,\n width,\n height,\n pivotPoint,\n rotate,\n opacity,\n colorAlpha,\n } = arg;\n // The font color's alpha applies to text and its decorations, not to the code background.\n const textOpacity = applyAlphaToOpacity(opacity, colorAlpha);\n const richTextRuns = parseInlineMarkdown(value);\n const resolvedRuns = await resolveRichTextRuns({ runs: richTextRuns, schema, font, _cache });\n const allLines = layoutRichTextLines({\n runs: resolvedRuns,\n fontSize,\n characterSpacing,\n boxWidthInPt: width,\n });\n const lineRange = getTextLineRange(schema);\n const lines = applyTextLineRange(allLines, lineRange);\n const pdfFontObj = await embedFontsForRuns(\n lines.flatMap((line) => line.runs),\n embedPdfFont,\n );\n\n const firstLineTextHeight = heightOfFontAtSize(fontKitFont, fontSize);\n const descent = getFontDescentInPt(fontKitFont, fontSize);\n const halfLineHeightAdjustment = lineHeight === 0 ? 0 : ((lineHeight - 1) * fontSize) / 2;\n\n let yOffset = 0;\n if (verticalAlignment === VERTICAL_ALIGN_TOP) {\n yOffset = firstLineTextHeight + halfLineHeightAdjustment;\n } else {\n const otherLinesHeight = lineHeight * fontSize * (lines.length - 1);\n\n if (verticalAlignment === VERTICAL_ALIGN_BOTTOM) {\n yOffset = height - otherLinesHeight + descent - halfLineHeightAdjustment;\n } else if (verticalAlignment === VERTICAL_ALIGN_MIDDLE) {\n yOffset =\n (height - otherLinesHeight - firstLineTextHeight + descent) / 2 + firstLineTextHeight;\n }\n }\n\n lines.forEach((line, rowIndex) => {\n if (line.runs.length === 0) return;\n\n const alignmentMetrics = getLineAlignment(\n {\n text: line.runs.map((run) => run.text).join(''),\n width: line.width,\n hardBreak: line.hardBreak,\n },\n width,\n alignment,\n );\n const textWidth = alignmentMetrics.usedWidth;\n const spacing = characterSpacing + alignmentMetrics.extraLetterSpacing;\n const xLine = x + alignmentMetrics.x;\n\n const yLine = y + height - yOffset - lineHeight * fontSize * rowIndex;\n page.pushOperators(pdfLib.setCharacterSpacing(spacing));\n\n if (schema.strikethrough || schema.underline) {\n const textHeight = Math.max(\n ...line.runs.map((run) => heightOfFontAtSize(run.fontKitFont, fontSize)),\n );\n if (schema.strikethrough) {\n drawDecorationLine({\n page,\n x: xLine,\n y: yLine + textHeight / 3,\n width: textWidth,\n rotate,\n pivotPoint,\n fontSize,\n color,\n opacity: textOpacity,\n });\n }\n if (schema.underline) {\n drawDecorationLine({\n page,\n x: xLine,\n y: yLine - textHeight / 12,\n width: textWidth,\n rotate,\n pivotPoint,\n fontSize,\n color,\n opacity: textOpacity,\n });\n }\n }\n\n line.runs.reduce((currentX, run, runIndex) => {\n const runWidth = getRunWidth(run, fontSize, spacing);\n const pdfFont = getPdfFontFromObj(run, pdfFontObj);\n drawRun({\n page,\n pdfLib,\n run,\n pdfFont,\n x: currentX,\n y: yLine,\n rotate,\n pivotPoint,\n fontSize,\n lineHeight,\n color,\n opacity,\n textOpacity,\n colorType,\n characterSpacing: spacing,\n strikethrough: Boolean(run.strikethrough),\n underline: Boolean(run.href) && !schema.underline,\n });\n if (run.href) {\n const rect = getLinkAnnotationRect({\n run,\n x: currentX,\n y: yLine,\n width: runWidth,\n rotate,\n pivotPoint,\n fontSize,\n });\n const targetName = getInternalLinkTarget(run.href);\n if (targetName) {\n registerInternalLinkAnnotation({ _cache, page, targetName, rect });\n } else {\n addUriLinkAnnotation({ pdfDoc, page, uri: run.href, rect });\n }\n }\n\n return currentX + runWidth + (runIndex === line.runs.length - 1 ? 0 : spacing);\n }, xLine);\n });\n};\n","import { isBlankPdf, type BasePdf } from '@pdfme/common';\nimport { TEXT_OVERFLOW_EXPAND } from './constants.js';\nimport type { TextSchema } from './types.js';\n\nconst TEXT_OVERFLOW_EXPAND_SCHEMA_TYPES = new Set(['text', 'multiVariableText']);\n\ntype TextOverflowSchema = Pick<TextSchema, 'overflow'> & Partial<Pick<TextSchema, 'type'>>;\n\nconst isTextOverflowExpandSchema = (schema: Partial<Pick<TextSchema, 'type'>>) =>\n schema.type === undefined || TEXT_OVERFLOW_EXPAND_SCHEMA_TYPES.has(schema.type);\n\nexport const canUseTextOverflowExpand = (\n schema: Partial<Pick<TextSchema, 'type'>>,\n basePdf?: BasePdf,\n) => !isTextOverflowExpandSchema(schema) || basePdf === undefined || isBlankPdf(basePdf);\n\nexport const isTextOverflowExpand = (schema: TextOverflowSchema, basePdf?: BasePdf) =>\n canUseTextOverflowExpand(schema, basePdf) && schema.overflow === TEXT_OVERFLOW_EXPAND;\n\nexport const shouldUseDynamicFontSize = (\n schema: Pick<TextSchema, 'dynamicFontSize' | 'overflow'> & Partial<Pick<TextSchema, 'type'>>,\n basePdf?: BasePdf,\n) => Boolean(schema.dynamicFontSize) && !isTextOverflowExpand(schema, basePdf);\n","import { PDFFont, PDFDocument } from '@pdfme/pdf-lib';\nimport { Font } from '@pdfme/common';\nimport { fetchRemoteFontData } from './text/helper.js';\n\ntype PdfFontCache = Record<string, Promise<PDFFont>>;\n\nconst PDF_FONT_CACHE_KEY = 'schemas-pdf-font-cache';\n\nconst getPdfFontCache = (_cache: Map<string | number, unknown>): PdfFontCache => {\n let pdfFontCache = _cache.get(PDF_FONT_CACHE_KEY) as PdfFontCache | undefined;\n if (!pdfFontCache) {\n pdfFontCache = {};\n _cache.set(PDF_FONT_CACHE_KEY, pdfFontCache);\n }\n\n return pdfFontCache;\n};\n\nexport const embedAndGetFont = (arg: {\n pdfDoc: PDFDocument;\n font: Font;\n fontName: string;\n _cache: Map<string | number, unknown>;\n}) => {\n const { pdfDoc, font, fontName, _cache } = arg;\n const pdfFontCache = getPdfFontCache(_cache);\n const cachedFont = pdfFontCache[fontName];\n if (cachedFont) {\n return cachedFont;\n }\n\n const pdfFontPromise = (async () => {\n const fontValue = font[fontName];\n if (!fontValue) {\n throw new Error(`[@pdfme/schemas] Font \"${fontName}\" is not found.`);\n }\n\n let fontData = fontValue.data;\n if (typeof fontData === 'string' && fontData.startsWith('http')) {\n fontData = await fetchRemoteFontData(fontData);\n }\n return pdfDoc.embedFont(fontData, {\n subset: typeof fontValue.subset === 'undefined' ? true : fontValue.subset,\n });\n })();\n\n // Attach a no-op rejection handler so that if a caller creates this promise but\n // unwinds before awaiting it (e.g. an earlier await throws for the same broken\n // font data), the rejection doesn't escape as an unhandledRejection and crash\n // the process (#1636). Callers that await the promise still receive the error.\n pdfFontPromise.catch(() => {});\n pdfFontCache[fontName] = pdfFontPromise;\n return pdfFontPromise;\n};\n","import type { Font as FontKitFont } from 'fontkit';\nimport type { TextSchema } from './types.js';\nimport {\n PDFRenderProps,\n ColorType,\n getDefaultFont,\n getFallbackFontName,\n mm2pt,\n} from '@pdfme/common';\nimport {\n VERTICAL_ALIGN_TOP,\n VERTICAL_ALIGN_MIDDLE,\n VERTICAL_ALIGN_BOTTOM,\n DEFAULT_FONT_SIZE,\n DEFAULT_ALIGNMENT,\n DEFAULT_VERTICAL_ALIGNMENT,\n DEFAULT_LINE_HEIGHT,\n DEFAULT_CHARACTER_SPACING,\n DEFAULT_FONT_COLOR,\n} from './constants.js';\nimport {\n calculateDynamicFontSize,\n heightOfFontAtSize,\n getFontDescentInPt,\n getFontKitFont,\n widthOfTextAtSize,\n wrapTextToSize,\n} from './helper.js';\nimport { getLineAlignment } from './wrap.js';\nimport { stripInlineMarkdown } from './inlineMarkdown.js';\nimport { applyTextLineRange } from './measure.js';\nimport { calculateDynamicRichTextFontSize, isInlineMarkdownTextSchema } from './richText.js';\nimport { renderInlineMarkdownText } from './richTextPdfRender.js';\nimport { shouldUseDynamicFontSize } from './overflow.js';\nimport {\n convertForPdfLayoutProps,\n rotatePoint,\n hex2PrintingColor,\n splitHexAlpha,\n applyAlphaToOpacity,\n} from '../utils.js';\nimport { getTextLineRange } from '../splitRange.js';\nimport { getBoxContentArea, getBoxInsets, hasBoxDimension } from '../box.js';\nimport { embedAndGetFont } from '../pdfFont.js';\n\nconst getFontProp = ({\n value,\n fontKitFont,\n schema,\n basePdf,\n colorType,\n fontSize: resolvedFontSize,\n}: {\n value: string;\n fontKitFont: FontKitFont;\n colorType?: ColorType;\n schema: TextSchema;\n basePdf: PDFRenderProps<TextSchema>['basePdf'];\n fontSize?: number;\n}) => {\n const fontSize =\n resolvedFontSize ??\n (shouldUseDynamicFontSize(schema, basePdf)\n ? calculateDynamicFontSize({ textSchema: schema, fontKitFont, value })\n : (schema.fontSize ?? DEFAULT_FONT_SIZE));\n const { color: fontColorHex, alpha: colorAlpha } = splitHexAlpha(\n schema.fontColor || DEFAULT_FONT_COLOR,\n );\n const color = hex2PrintingColor(fontColorHex, colorType);\n\n return {\n alignment: schema.alignment ?? DEFAULT_ALIGNMENT,\n verticalAlignment: schema.verticalAlignment ?? DEFAULT_VERTICAL_ALIGNMENT,\n lineHeight: schema.lineHeight ?? DEFAULT_LINE_HEIGHT,\n characterSpacing: schema.characterSpacing ?? DEFAULT_CHARACTER_SPACING,\n fontSize,\n color,\n colorAlpha,\n };\n};\n\nexport const pdfRender = async (arg: PDFRenderProps<TextSchema>) => {\n const { value, pdfDoc, pdfLib, page, options, schema, basePdf, _cache } = arg;\n const { font = getDefaultFont(), colorType } = options;\n\n const pageHeight = page.getHeight();\n const {\n width,\n height,\n rotate,\n position: { x, y },\n opacity,\n } = convertForPdfLayoutProps({ schema, pageHeight, applyRotateTranslate: false });\n\n const pivotPoint = { x: x + width / 2, y: pageHeight - mm2pt(schema.position.y) - height / 2 };\n\n if (!value) return;\n drawTextBoxDecoration({ page, schema, colorType, x, y, width, height, rotate, pivotPoint });\n\n const fontName = schema.fontName ? schema.fontName : getFallbackFontName(font);\n const enableInlineMarkdown = isInlineMarkdownTextSchema(schema);\n const contentArea = getBoxContentArea(schema);\n const contentX = x + mm2pt(contentArea.leftInset);\n const contentY = y + mm2pt(contentArea.bottomInset);\n const contentWidth = mm2pt(contentArea.width);\n const contentHeight = mm2pt(contentArea.height);\n\n const pdfFontValuePromise = enableInlineMarkdown\n ? undefined\n : embedAndGetFont({\n pdfDoc,\n font,\n fontName,\n _cache,\n });\n const fontKitFont = await getFontKitFont(\n schema.fontName,\n font,\n _cache as Map<string, FontKitFont>,\n );\n const displayValue = enableInlineMarkdown ? stripInlineMarkdown(value) : value;\n const dynamicRichTextFontSize =\n enableInlineMarkdown && shouldUseDynamicFontSize(schema, basePdf)\n ? await calculateDynamicRichTextFontSize({ value, schema, font, _cache })\n : undefined;\n const fontProp = getFontProp({\n value: displayValue,\n fontKitFont,\n schema,\n basePdf,\n colorType,\n fontSize: dynamicRichTextFontSize,\n });\n\n const {\n fontSize,\n color,\n colorAlpha,\n alignment,\n verticalAlignment,\n lineHeight,\n characterSpacing,\n } = fontProp;\n const textOpacity = applyAlphaToOpacity(opacity, colorAlpha);\n\n if (enableInlineMarkdown) {\n await renderInlineMarkdownText({\n value,\n schema,\n font,\n embedPdfFont: (fontName) => embedAndGetFont({ pdfDoc, font, fontName, _cache }),\n fontKitFont,\n pdfDoc,\n page,\n pdfLib,\n _cache,\n colorType,\n fontSize,\n color,\n alignment,\n verticalAlignment,\n lineHeight,\n characterSpacing,\n x: contentX,\n y: contentY,\n width: contentWidth,\n height: contentHeight,\n pivotPoint,\n rotate,\n opacity,\n colorAlpha,\n });\n return;\n }\n if (!pdfFontValuePromise) {\n throw new Error('[@pdfme/schemas] Failed to prepare PDF font for text rendering.');\n }\n const pdfFontValue = await pdfFontValuePromise;\n\n const firstLineTextHeight = heightOfFontAtSize(fontKitFont, fontSize);\n const descent = getFontDescentInPt(fontKitFont, fontSize);\n const halfLineHeightAdjustment = lineHeight === 0 ? 0 : ((lineHeight - 1) * fontSize) / 2;\n\n const lines = applyTextLineRange(\n wrapTextToSize({\n value,\n characterSpacing,\n fontSize,\n fontKitFont,\n boxWidthInPt: contentWidth,\n }),\n getTextLineRange(schema),\n );\n const needsTextWidth = alignment !== 'left' || Boolean(schema.strikethrough || schema.underline);\n const needsTextHeight = Boolean(schema.strikethrough || schema.underline);\n\n // Text lines are rendered from the bottom upwards, we need to adjust the position down\n let yOffset = 0;\n if (verticalAlignment === VERTICAL_ALIGN_TOP) {\n yOffset = firstLineTextHeight + halfLineHeightAdjustment;\n } else {\n const otherLinesHeight = lineHeight * fontSize * (lines.length - 1);\n\n if (verticalAlignment === VERTICAL_ALIGN_BOTTOM) {\n yOffset = contentHeight - otherLinesHeight + descent - halfLineHeightAdjustment;\n } else if (verticalAlignment === VERTICAL_ALIGN_MIDDLE) {\n yOffset =\n (contentHeight - otherLinesHeight - firstLineTextHeight + descent) / 2 +\n firstLineTextHeight;\n }\n }\n\n lines.forEach((line, rowIndex) => {\n const trimmed = line.text;\n const textWidth = needsTextWidth\n ? widthOfTextAtSize(trimmed, fontKitFont, fontSize, characterSpacing)\n : 0;\n const textHeight = needsTextHeight ? heightOfFontAtSize(fontKitFont, fontSize) : 0;\n const rowYOffset = lineHeight * fontSize * rowIndex;\n const alignmentMetrics = getLineAlignment(\n { text: trimmed, width: textWidth, hardBreak: line.hardBreak },\n contentWidth,\n alignment,\n );\n\n // Adobe Acrobat Reader shows an error if `drawText` is called with an empty text\n const drawText = trimmed === '' ? '\\r\\n' : trimmed;\n\n let xLine = contentX + alignmentMetrics.x;\n let yLine = contentY + contentHeight - yOffset - rowYOffset;\n\n // draw strikethrough\n if (schema.strikethrough && textWidth > 0) {\n const _x = xLine + textWidth + 1;\n const _y = yLine + textHeight / 3;\n page.drawLine({\n start: rotatePoint({ x: xLine, y: _y }, pivotPoint, rotate.angle),\n end: rotatePoint({ x: _x, y: _y }, pivotPoint, rotate.angle),\n thickness: (1 / 12) * fontSize,\n color: color,\n opacity: textOpacity,\n });\n }\n\n // draw underline\n if (schema.underline && textWidth > 0) {\n const _x = xLine + textWidth + 1;\n const _y = yLine - textHeight / 12;\n page.drawLine({\n start: rotatePoint({ x: xLine, y: _y }, pivotPoint, rotate.angle),\n end: rotatePoint({ x: _x, y: _y }, pivotPoint, rotate.angle),\n thickness: (1 / 12) * fontSize,\n color: color,\n opacity: textOpacity,\n });\n }\n\n if (rotate.angle !== 0) {\n // As we draw each line individually from different points, we must translate each lines position\n // relative to the UI rotation pivot point. see comments in convertForPdfLayoutProps() for more info.\n const rotatedPoint = rotatePoint({ x: xLine, y: yLine }, pivotPoint, rotate.angle);\n xLine = rotatedPoint.x;\n yLine = rotatedPoint.y;\n }\n\n page.pushOperators(\n pdfLib.setCharacterSpacing(characterSpacing + alignmentMetrics.extraLetterSpacing),\n );\n\n page.drawText(drawText, {\n x: xLine,\n y: yLine,\n rotate,\n size: fontSize,\n color,\n lineHeight: lineHeight * fontSize,\n font: pdfFontValue,\n opacity: textOpacity,\n });\n });\n};\n\nconst drawTextBoxDecoration = (arg: {\n page: PDFRenderProps<TextSchema>['page'];\n schema: TextSchema;\n colorType?: ColorType;\n x: number;\n y: number;\n width: number;\n height: number;\n rotate: ReturnType<typeof convertForPdfLayoutProps>['rotate'];\n pivotPoint: { x: number; y: number };\n}) => {\n const { page, schema, colorType, x, y, width, height, rotate, pivotPoint } = arg;\n const { borderWidth } = getBoxInsets(schema);\n const opacity = schema.opacity ?? 1;\n\n const drawRectangle = (rect: {\n x: number;\n y: number;\n width: number;\n height: number;\n color: NonNullable<ReturnType<typeof hex2PrintingColor>>;\n alpha: number;\n }) => {\n if (rect.width <= 0 || rect.height <= 0) return;\n const point =\n rotate.angle === 0\n ? { x: rect.x, y: rect.y }\n : rotatePoint({ x: rect.x, y: rect.y }, pivotPoint, rotate.angle);\n page.drawRectangle({\n x: point.x,\n y: point.y,\n width: rect.width,\n height: rect.height,\n rotate,\n color: rect.color,\n opacity: opacity * rect.alpha,\n });\n };\n\n if (schema.backgroundColor) {\n const { color: bgHex, alpha } = splitHexAlpha(schema.backgroundColor);\n const color = hex2PrintingColor(bgHex, colorType);\n if (color) drawRectangle({ x, y, width, height, color, alpha });\n }\n\n if (!schema.borderColor || !hasBoxDimension(schema.borderWidth)) return;\n\n const { color: borderHex, alpha } = splitHexAlpha(schema.borderColor);\n const color = hex2PrintingColor(borderHex, colorType);\n if (!color) return;\n\n const top = mm2pt(borderWidth.top);\n const right = mm2pt(borderWidth.right);\n const bottom = mm2pt(borderWidth.bottom);\n const left = mm2pt(borderWidth.left);\n\n drawRectangle({ x, y: y + height - top, width, height: top, color, alpha });\n drawRectangle({ x: x + width - right, y, width: right, height, color, alpha });\n drawRectangle({ x, y, width, height: bottom, color, alpha });\n drawRectangle({ x, y, width: left, height, color, alpha });\n};\n","import {\n Strikethrough,\n Underline,\n AlignLeft,\n AlignCenter,\n AlignRight,\n ArrowUpToLine,\n ArrowDownToLine,\n AlignJustify,\n} from 'lucide';\nimport { createSvgStr } from '../../utils.js';\n\nexport const TextStrikethroughIcon = createSvgStr(Strikethrough);\n\nexport const TextUnderlineIcon = createSvgStr(Underline);\n\nexport const TextAlignLeftIcon = createSvgStr(AlignLeft);\n\nexport const TextAlignCenterIcon = createSvgStr(AlignCenter);\n\nexport const TextAlignRightIcon = createSvgStr(AlignRight);\n\nexport const TextAlignJustifyIcon = createSvgStr(AlignJustify);\n\nexport const TextVerticalAlignTopIcon = createSvgStr(ArrowUpToLine);\n\n// svg icons are material icons from https://www.xicons.org\nexport const TextVerticalAlignMiddleIcon = `<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 24 24\"><path d=\"M8 19h3v4h2v-4h3l-4-4l-4 4zm8-14h-3V1h-2v4H8l4 4l4-4zM4 11v2h16v-2H4z\" fill=\"currentColor\"></path></svg>`;\n\nexport const TextVerticalAlignBottomIcon = createSvgStr(ArrowDownToLine);\n","// No imports needed from @pdfme/common\nimport {\n TextAlignCenterIcon,\n TextAlignLeftIcon,\n TextAlignRightIcon,\n TextAlignJustifyIcon,\n TextStrikethroughIcon,\n TextUnderlineIcon,\n TextVerticalAlignBottomIcon,\n TextVerticalAlignMiddleIcon,\n TextVerticalAlignTopIcon,\n} from './icons/index.js';\nimport {\n ALIGN_CENTER,\n ALIGN_RIGHT,\n DEFAULT_ALIGNMENT,\n DEFAULT_VERTICAL_ALIGNMENT,\n VERTICAL_ALIGN_BOTTOM,\n VERTICAL_ALIGN_MIDDLE,\n ALIGN_JUSTIFY,\n} from './constants.js';\n\nexport enum Formatter {\n STRIKETHROUGH = 'strikethrough',\n UNDERLINE = 'underline',\n ALIGNMENT = 'alignment',\n VERTICAL_ALIGNMENT = 'verticalAlignment',\n}\n\ninterface GroupButtonBoolean {\n key: Formatter;\n icon: string;\n type: 'boolean';\n}\n\ninterface GroupButtonString {\n key: Formatter;\n icon: string;\n type: 'select';\n value: string;\n}\n\ntype GroupButton = GroupButtonBoolean | GroupButtonString;\n\nexport function getExtraFormatterSchema(i18n: (key: string) => string): {\n title: string;\n widget: string;\n buttons: GroupButton[];\n span: number;\n} {\n const buttons: GroupButton[] = [\n { key: Formatter.STRIKETHROUGH, icon: TextStrikethroughIcon, type: 'boolean' },\n { key: Formatter.UNDERLINE, icon: TextUnderlineIcon, type: 'boolean' },\n { key: Formatter.ALIGNMENT, icon: TextAlignLeftIcon, type: 'select', value: DEFAULT_ALIGNMENT },\n { key: Formatter.ALIGNMENT, icon: TextAlignCenterIcon, type: 'select', value: ALIGN_CENTER },\n { key: Formatter.ALIGNMENT, icon: TextAlignRightIcon, type: 'select', value: ALIGN_RIGHT },\n { key: Formatter.ALIGNMENT, icon: TextAlignJustifyIcon, type: 'select', value: ALIGN_JUSTIFY },\n {\n key: Formatter.VERTICAL_ALIGNMENT,\n icon: TextVerticalAlignTopIcon,\n type: 'select',\n value: DEFAULT_VERTICAL_ALIGNMENT,\n },\n {\n key: Formatter.VERTICAL_ALIGNMENT,\n icon: TextVerticalAlignMiddleIcon,\n type: 'select',\n value: VERTICAL_ALIGN_MIDDLE,\n },\n {\n key: Formatter.VERTICAL_ALIGNMENT,\n icon: TextVerticalAlignBottomIcon,\n type: 'select',\n value: VERTICAL_ALIGN_BOTTOM,\n },\n ];\n return {\n title: i18n('schemas.text.format'),\n widget: 'ButtonGroup',\n buttons,\n span: 24,\n };\n}\n","import {\n DEFAULT_FONT_NAME,\n PropPanel,\n PropPanelWidgetProps,\n PropPanelSchema,\n getFallbackFontName,\n} from '@pdfme/common';\nimport type { TextSchema } from './types.js';\nimport {\n DEFAULT_FONT_SIZE,\n DEFAULT_ALIGNMENT,\n DEFAULT_VERTICAL_ALIGNMENT,\n DEFAULT_CHARACTER_SPACING,\n DEFAULT_LINE_HEIGHT,\n DEFAULT_FONT_COLOR,\n DYNAMIC_FIT_VERTICAL,\n DYNAMIC_FIT_HORIZONTAL,\n DEFAULT_DYNAMIC_FIT,\n DEFAULT_DYNAMIC_MIN_FONT_SIZE,\n DEFAULT_DYNAMIC_MAX_FONT_SIZE,\n DEFAULT_TEXT_FORMAT,\n TEXT_FORMAT_INLINE_MARKDOWN,\n TEXT_FORMAT_PLAIN,\n TEXT_OVERFLOW_EXPAND,\n TEXT_OVERFLOW_VISIBLE,\n DEFAULT_TEXT_OVERFLOW,\n DEFAULT_FONT_VARIANT_FALLBACK,\n FONT_VARIANT_FALLBACK_ERROR,\n FONT_VARIANT_FALLBACK_PLAIN,\n FONT_VARIANT_FALLBACK_SYNTHETIC,\n} from './constants.js';\nimport { DEFAULT_OPACITY, HEX_COLOR_PATTERN } from '../constants.js';\nimport { getExtraFormatterSchema } from './extraFormatter.js';\nimport { canUseTextOverflowExpand, isTextOverflowExpand } from './overflow.js';\nimport { createBoxDimension, getBoxDimensionPropPanelSchema } from '../box.js';\n\nconst UseDynamicFontSize = (props: PropPanelWidgetProps) => {\n const { rootElement, changeSchemas, activeSchema, i18n, basePdf } = props;\n const isExpand = isTextOverflowExpand(activeSchema as unknown as TextSchema, basePdf);\n\n const checkbox = document.createElement('input');\n checkbox.type = 'checkbox';\n checkbox.checked =\n !isExpand && Boolean((activeSchema as { dynamicFontSize?: unknown })?.dynamicFontSize);\n checkbox.disabled = isExpand;\n checkbox.onchange = (e: Event) => {\n const val = (e.target as HTMLInputElement).checked\n ? {\n min: DEFAULT_DYNAMIC_MIN_FONT_SIZE,\n max: DEFAULT_DYNAMIC_MAX_FONT_SIZE,\n fit: DEFAULT_DYNAMIC_FIT,\n }\n : undefined;\n changeSchemas([{ key: 'dynamicFontSize', value: val, schemaId: activeSchema.id }]);\n };\n const label = document.createElement('label');\n const span = document.createElement('span');\n span.innerText = i18n('schemas.text.dynamicFontSize') || '';\n span.style.cssText = 'margin-left: 0.5rem';\n label.style.cssText = 'display: flex; width: 100%;';\n label.style.opacity = isExpand ? '0.5' : '1';\n label.appendChild(checkbox);\n label.appendChild(span);\n rootElement.appendChild(label);\n};\n\nconst UseInlineMarkdown = (props: PropPanelWidgetProps) => {\n const { rootElement, changeSchemas, activeSchema, i18n } = props;\n\n const checkbox = document.createElement('input');\n checkbox.type = 'checkbox';\n checkbox.checked =\n (activeSchema as { textFormat?: unknown })?.textFormat === TEXT_FORMAT_INLINE_MARKDOWN;\n checkbox.onchange = (e: Event) => {\n const value = (e.target as HTMLInputElement).checked\n ? TEXT_FORMAT_INLINE_MARKDOWN\n : TEXT_FORMAT_PLAIN;\n changeSchemas([{ key: 'textFormat', value, schemaId: activeSchema.id }]);\n };\n const label = document.createElement('label');\n const span = document.createElement('span');\n span.innerText = i18n('schemas.text.inlineMarkdown') || '';\n span.style.cssText = 'margin-left: 0.5rem';\n label.style.cssText = 'display: flex; width: 100%;';\n label.appendChild(checkbox);\n label.appendChild(span);\n rootElement.appendChild(label);\n};\n\nexport const propPanel: PropPanel<TextSchema> = {\n schema: ({ options, activeSchema, i18n, basePdf }) => {\n const font = options.font || { [DEFAULT_FONT_NAME]: { data: '', fallback: true } };\n const fontNames = Object.keys(font);\n const fallbackFontName = getFallbackFontName(font);\n\n const activeTextSchema = activeSchema as unknown as TextSchema;\n const canExpandOverflow = canUseTextOverflowExpand(activeTextSchema, basePdf);\n const isExpand = isTextOverflowExpand(activeTextSchema, basePdf);\n const enableDynamicFont =\n !isExpand && Boolean((activeSchema as { dynamicFontSize?: unknown })?.dynamicFontSize);\n const hideTextFormat = activeTextSchema.type === 'text' && activeTextSchema.readOnly !== true;\n const enableInlineMarkdown =\n activeTextSchema.textFormat === TEXT_FORMAT_INLINE_MARKDOWN && !hideTextFormat;\n const baseFontName =\n activeTextSchema.fontName && font[activeTextSchema.fontName]\n ? activeTextSchema.fontName\n : fallbackFontName;\n const optionalFontNames = [\n { label: baseFontName, value: '' },\n ...fontNames\n .filter((name) => name !== baseFontName)\n .map((name) => ({ label: name, value: name })),\n ];\n const overflowOptions = [\n { label: i18n('schemas.text.overflowVisible'), value: TEXT_OVERFLOW_VISIBLE },\n ...(canExpandOverflow\n ? [{ label: i18n('schemas.text.overflowExpand'), value: TEXT_OVERFLOW_EXPAND }]\n : []),\n ];\n\n const textSchema: Record<string, PropPanelSchema> = {\n fontName: {\n title: i18n('schemas.text.fontName'),\n type: 'string',\n widget: 'select',\n default: fallbackFontName,\n placeholder: fallbackFontName,\n props: { options: fontNames.map((name) => ({ label: name, value: name })) },\n span: 12,\n },\n fontSize: {\n title: i18n('schemas.text.size'),\n type: 'number',\n widget: 'inputNumber',\n span: 6,\n disabled: enableDynamicFont,\n props: { min: 0 },\n },\n characterSpacing: {\n title: i18n('schemas.text.spacing'),\n type: 'number',\n widget: 'inputNumber',\n span: 6,\n props: { min: 0 },\n },\n formatter: getExtraFormatterSchema(i18n),\n lineHeight: {\n title: i18n('schemas.text.lineHeight'),\n type: 'number',\n widget: 'inputNumber',\n props: { step: 0.1, min: 0 },\n span: 8,\n },\n overflow: {\n title: i18n('schemas.text.overflow'),\n type: 'string',\n widget: 'select',\n default: DEFAULT_TEXT_OVERFLOW,\n props: {\n options: overflowOptions,\n },\n span: 8,\n },\n useDynamicFontSize: { type: 'boolean', widget: 'UseDynamicFontSize', bind: false, span: 16 },\n dynamicFontSize: {\n type: 'object',\n widget: 'card',\n column: 3,\n properties: {\n min: {\n title: i18n('schemas.text.min'),\n type: 'number',\n widget: 'inputNumber',\n hidden: !enableDynamicFont,\n props: { min: 0 },\n },\n max: {\n title: i18n('schemas.text.max'),\n type: 'number',\n widget: 'inputNumber',\n hidden: !enableDynamicFont,\n props: { min: 0 },\n },\n fit: {\n title: i18n('schemas.text.fit'),\n type: 'string',\n widget: 'select',\n hidden: !enableDynamicFont,\n props: {\n options: [\n { label: i18n('schemas.horizontal'), value: DYNAMIC_FIT_HORIZONTAL },\n { label: i18n('schemas.vertical'), value: DYNAMIC_FIT_VERTICAL },\n ],\n },\n },\n },\n },\n fontColor: {\n title: i18n('schemas.textColor'),\n type: 'string',\n widget: 'color',\n props: {\n disabledAlpha: true,\n },\n rules: [\n {\n pattern: HEX_COLOR_PATTERN,\n message: i18n('validation.hexColor'),\n },\n ],\n },\n backgroundColor: {\n title: i18n('schemas.bgColor'),\n type: 'string',\n widget: 'color',\n props: {\n disabledAlpha: true,\n },\n rules: [\n {\n pattern: HEX_COLOR_PATTERN,\n message: i18n('validation.hexColor'),\n },\n ],\n },\n borderColor: {\n title: i18n('schemas.borderColor'),\n type: 'string',\n widget: 'color',\n props: {\n disabledAlpha: true,\n },\n rules: [\n {\n pattern: HEX_COLOR_PATTERN,\n message: i18n('validation.hexColor'),\n },\n ],\n },\n borderWidth: {\n title: i18n('schemas.borderWidth'),\n type: 'object',\n widget: 'lineTitle',\n span: 24,\n properties: getBoxDimensionPropPanelSchema(0.1),\n },\n padding: {\n title: i18n('schemas.padding'),\n type: 'object',\n widget: 'lineTitle',\n span: 24,\n properties: getBoxDimensionPropPanelSchema(),\n },\n useInlineMarkdown: {\n type: 'boolean',\n widget: 'UseInlineMarkdown',\n bind: false,\n hidden: hideTextFormat,\n span: enableInlineMarkdown ? 12 : 24,\n },\n fontVariantFallback: {\n title: i18n('schemas.text.variantFallback'),\n type: 'string',\n widget: 'select',\n default: DEFAULT_FONT_VARIANT_FALLBACK,\n hidden: !enableInlineMarkdown,\n props: {\n options: [\n { label: i18n('schemas.text.synthetic'), value: FONT_VARIANT_FALLBACK_SYNTHETIC },\n { label: i18n('schemas.text.plain'), value: FONT_VARIANT_FALLBACK_PLAIN },\n { label: i18n('schemas.text.error'), value: FONT_VARIANT_FALLBACK_ERROR },\n ],\n },\n span: 12,\n },\n fontVariants: {\n title: i18n('schemas.text.markdownFonts'),\n type: 'object',\n widget: 'card',\n column: 2,\n hidden: !enableInlineMarkdown,\n properties: {\n bold: {\n title: i18n('schemas.text.boldFont'),\n type: 'string',\n widget: 'select',\n props: { options: optionalFontNames },\n },\n italic: {\n title: i18n('schemas.text.italicFont'),\n type: 'string',\n widget: 'select',\n props: { options: optionalFontNames },\n },\n boldItalic: {\n title: i18n('schemas.text.boldItalicFont'),\n type: 'string',\n widget: 'select',\n props: { options: optionalFontNames },\n },\n code: {\n title: i18n('schemas.text.codeFont'),\n type: 'string',\n widget: 'select',\n props: { options: optionalFontNames },\n },\n },\n },\n };\n\n return textSchema;\n },\n widgets: { UseDynamicFontSize, UseInlineMarkdown },\n defaultSchema: {\n name: '',\n type: 'text',\n content: 'Type Something...',\n position: { x: 0, y: 0 },\n width: 45,\n height: 10,\n // If the value of \"rotate\" is set to undefined or not set at all, rotation will be disabled in the UI.\n // Check this document: https://pdfme.com//docs/custom-schemas#learning-how-to-create-from-pdfmeschemas-code\n rotate: 0,\n alignment: DEFAULT_ALIGNMENT,\n verticalAlignment: DEFAULT_VERTICAL_ALIGNMENT,\n fontSize: DEFAULT_FONT_SIZE,\n textFormat: DEFAULT_TEXT_FORMAT,\n overflow: DEFAULT_TEXT_OVERFLOW,\n fontVariantFallback: DEFAULT_FONT_VARIANT_FALLBACK,\n lineHeight: DEFAULT_LINE_HEIGHT,\n characterSpacing: DEFAULT_CHARACTER_SPACING,\n dynamicFontSize: undefined,\n fontColor: DEFAULT_FONT_COLOR,\n fontName: undefined,\n backgroundColor: '',\n borderColor: '#000000',\n borderWidth: createBoxDimension(0),\n padding: createBoxDimension(0),\n opacity: DEFAULT_OPACITY,\n strikethrough: false,\n underline: false,\n },\n};\n","import type * as CSS from 'csstype';\nimport type { Font as FontKitFont } from 'fontkit';\nimport {\n UIRenderProps,\n getDefaultFont,\n getInternalLinkTarget,\n mm2pt,\n normalizeLinkHref,\n} from '@pdfme/common';\nimport type { TextSchema } from './types.js';\nimport {\n DEFAULT_FONT_SIZE,\n DEFAULT_ALIGNMENT,\n VERTICAL_ALIGN_TOP,\n VERTICAL_ALIGN_MIDDLE,\n VERTICAL_ALIGN_BOTTOM,\n DEFAULT_VERTICAL_ALIGNMENT,\n DEFAULT_LINE_HEIGHT,\n DEFAULT_CHARACTER_SPACING,\n DEFAULT_FONT_COLOR,\n PLACEHOLDER_FONT_COLOR,\n CODE_BACKGROUND_COLOR,\n CODE_HORIZONTAL_PADDING,\n SYNTHETIC_BOLD_CSS_TEXT_SHADOW,\n TEXT_FORMAT_INLINE_MARKDOWN,\n ALIGN_JUSTIFY,\n} from './constants.js';\nimport {\n calculateDynamicFontSize,\n getFontKitFont,\n getBrowserVerticalFontAdjustments,\n isFirefox,\n splitTextToSize,\n wrapTextToSize,\n widthOfTextAtSize,\n} from './helper.js';\nimport { getLineAlignment, splitGraphemes, type WrapLine } from './wrap.js';\nimport { parseInlineMarkdown, stripInlineMarkdown } from './inlineMarkdown.js';\nimport { applyTextLineRange, plainTextLinesToValue } from './measure.js';\nimport { shouldUseDynamicFontSize } from './overflow.js';\nimport {\n calculateDynamicRichTextFontSize,\n isInlineMarkdownTextSchema,\n layoutRichTextLines,\n resolveRichTextRuns,\n} from './richText.js';\nimport { isEditable } from '../utils.js';\nimport { getTextLineRange } from '../splitRange.js';\nimport { getBoxContentArea, getBoxInsets, hasBoxDimension } from '../box.js';\n\nconst replaceUnsupportedChars = (text: string, fontKitFont: FontKitFont): string => {\n const charSupportCache: { [char: string]: boolean } = {};\n\n const isCharSupported = (char: string): boolean => {\n if (char in charSupportCache) {\n return charSupportCache[char];\n }\n const isSupported = fontKitFont.hasGlyphForCodePoint(char.codePointAt(0) || 0);\n charSupportCache[char] = isSupported;\n return isSupported;\n };\n\n const segments = text.split(/(\\r\\n|\\n|\\r)/);\n\n return segments\n .map((segment) => {\n if (/\\r\\n|\\n|\\r/.test(segment)) {\n return segment;\n }\n\n return Array.from(segment)\n .map((char) => {\n if (/\\s/.test(char) || char.charCodeAt(0) < 32) {\n return char;\n }\n\n return isCharSupported(char) ? char : '〿';\n })\n .join('');\n })\n .join('');\n};\n\nexport const uiRender = async (arg: UIRenderProps<TextSchema>) => {\n const {\n value,\n schema,\n basePdf,\n mode,\n onChange,\n stopEditing,\n tabIndex,\n placeholder,\n options,\n _cache,\n } = arg;\n const hasInlineMarkdownFormat = schema.textFormat === TEXT_FORMAT_INLINE_MARKDOWN;\n const enableInlineMarkdown = isInlineMarkdownTextSchema(schema);\n const isReadOnlySplitInlineMarkdownFormChunk =\n mode === 'form' && Boolean(getTextLineRange(schema)) && hasInlineMarkdownFormat;\n const renderInlineMarkdownReadOnlyChunk =\n enableInlineMarkdown || isReadOnlySplitInlineMarkdownFormChunk;\n const editable = isEditable(mode, schema) && !isReadOnlySplitInlineMarkdownFormChunk;\n const usePlaceholder = editable && placeholder && !value;\n const getText = (element: HTMLDivElement) => {\n let text = element.innerText;\n if (text.endsWith('\\n')) {\n // contenteditable adds additional newline char retrieved with innerText\n text = text.slice(0, -1);\n }\n return text;\n };\n const font = options?.font || getDefaultFont();\n const fontKitFont = await getFontKitFont(\n schema.fontName,\n font,\n _cache as Map<string, import('fontkit').Font>,\n );\n const enableDynamicFontSize = shouldUseDynamicFontSize(schema, basePdf);\n const displayValue = enableInlineMarkdown ? stripInlineMarkdown(value) : value;\n const dynamicRichTextFontSize =\n enableInlineMarkdown && enableDynamicFontSize\n ? await calculateDynamicRichTextFontSize({\n value: usePlaceholder ? (placeholder as string) : value,\n schema,\n font,\n _cache,\n })\n : undefined;\n const resolvedPlainFontSize =\n !enableInlineMarkdown && enableDynamicFontSize && (usePlaceholder ? placeholder : displayValue)\n ? calculateDynamicFontSize({\n textSchema: schema,\n fontKitFont,\n value: usePlaceholder ? (placeholder as string) : displayValue,\n })\n : (schema.fontSize ?? DEFAULT_FONT_SIZE);\n const useComputedWrapLines = !editable;\n const textBlock = buildStyledTextContainer(\n isReadOnlySplitInlineMarkdownFormChunk ? { ...arg, mode: 'viewer' } : arg,\n fontKitFont,\n usePlaceholder ? placeholder : displayValue,\n dynamicRichTextFontSize ?? resolvedPlainFontSize,\n { useComputedWrapLines },\n );\n\n const processedText = replaceUnsupportedChars(\n getRangedPlainTextValue({\n value,\n schema,\n fontKitFont,\n fontSize: dynamicRichTextFontSize ?? resolvedPlainFontSize,\n }),\n fontKitFont,\n );\n\n if (!editable) {\n if (renderInlineMarkdownReadOnlyChunk) {\n await renderInlineMarkdownReadOnly({\n textBlock,\n value,\n schema,\n font,\n _cache,\n fontSize: dynamicRichTextFontSize ?? resolvedPlainFontSize,\n });\n return;\n }\n\n renderReadOnlyPlainLines({\n textBlock,\n lines: applyTextLineRange(\n wrapTextToSize({\n value,\n characterSpacing: schema.characterSpacing ?? DEFAULT_CHARACTER_SPACING,\n fontSize: dynamicRichTextFontSize ?? resolvedPlainFontSize,\n fontKitFont,\n boxWidthInPt: mm2pt(getBoxContentArea(schema).width),\n }),\n getTextLineRange(schema),\n ),\n fontKitFont,\n fontSize: dynamicRichTextFontSize ?? resolvedPlainFontSize,\n characterSpacing: schema.characterSpacing ?? DEFAULT_CHARACTER_SPACING,\n alignment: schema.alignment ?? DEFAULT_ALIGNMENT,\n boxWidthInPt: mm2pt(getBoxContentArea(schema).width),\n });\n return;\n }\n\n makeElementPlainTextContentEditable(textBlock);\n textBlock.tabIndex = tabIndex || 0;\n textBlock.innerText = mode === 'designer' ? value : processedText;\n textBlock.addEventListener('blur', (e: Event) => {\n if (onChange) onChange({ key: 'content', value: getText(e.target as HTMLDivElement) });\n if (stopEditing) stopEditing();\n });\n\n if (enableDynamicFontSize) {\n let dynamicFontSize: undefined | number = undefined;\n\n textBlock.addEventListener('keyup', () => {\n setTimeout(() => {\n // Use a regular function instead of an async one since we don't need await\n (() => {\n if (!textBlock.textContent) return;\n dynamicFontSize = calculateDynamicFontSize({\n textSchema: schema,\n fontKitFont,\n value: isInlineMarkdownTextSchema(schema)\n ? stripInlineMarkdown(getText(textBlock))\n : getText(textBlock),\n startingFontSize: dynamicFontSize,\n });\n textBlock.style.fontSize = `${dynamicFontSize}pt`;\n\n const { topAdj: newTopAdj, bottomAdj: newBottomAdj } = getBrowserVerticalFontAdjustments(\n fontKitFont,\n dynamicFontSize ?? schema.fontSize ?? DEFAULT_FONT_SIZE,\n schema.lineHeight ?? DEFAULT_LINE_HEIGHT,\n schema.verticalAlignment ?? DEFAULT_VERTICAL_ALIGNMENT,\n );\n textBlock.style.paddingTop = `${newTopAdj}px`;\n textBlock.style.marginBottom = `${newBottomAdj}px`;\n })();\n }, 0);\n });\n }\n\n if (usePlaceholder) {\n textBlock.style.color = PLACEHOLDER_FONT_COLOR;\n textBlock.addEventListener('focus', () => {\n if (textBlock.innerText === placeholder) {\n textBlock.innerText = '';\n textBlock.style.color = schema.fontColor ?? DEFAULT_FONT_COLOR;\n }\n });\n }\n\n if (mode === 'designer') {\n setTimeout(() => {\n textBlock.focus();\n // Set the focus to the end of the editable element when you focus, as we would for a textarea\n const selection = window.getSelection();\n const range = document.createRange();\n if (selection && range) {\n range.selectNodeContents(textBlock);\n range.collapse(false); // Collapse range to the end\n selection?.removeAllRanges();\n selection?.addRange(range);\n }\n });\n }\n};\n\nconst renderInlineMarkdownReadOnly = async (arg: {\n textBlock: HTMLDivElement;\n value: string;\n schema: TextSchema;\n font: NonNullable<UIRenderProps<TextSchema>['options']['font']>;\n _cache: Map<string | number, unknown>;\n fontSize: number;\n}) => {\n const { textBlock, value, schema, font, _cache, fontSize } = arg;\n const characterSpacing = schema.characterSpacing ?? DEFAULT_CHARACTER_SPACING;\n const alignment = schema.alignment ?? DEFAULT_ALIGNMENT;\n const boxWidthInPt = mm2pt(getBoxContentArea(schema).width);\n const runs = await resolveRichTextRuns({\n runs: parseInlineMarkdown(value),\n schema,\n font,\n _cache,\n });\n const lines = applyTextLineRange(\n layoutRichTextLines({\n runs,\n fontSize,\n characterSpacing,\n boxWidthInPt,\n }),\n getTextLineRange(schema),\n );\n\n textBlock.innerHTML = '';\n lines.forEach((line, lineIndex) => {\n const lineEl = document.createElement('span');\n lineEl.dataset.pdfmeWrapLine = '';\n lineEl.style.whiteSpace = 'pre';\n const stripTrailingLetterSpacing = applySharedWrapLineSpacing(\n lineEl,\n {\n text: line.runs.map((run) => run.text).join(''),\n width: line.width,\n hardBreak: line.hardBreak,\n },\n alignment,\n boxWidthInPt,\n characterSpacing,\n );\n\n line.runs.forEach((run) => {\n appendInlineMarkdownRun({ parent: lineEl, run, schema, font });\n });\n if (stripTrailingLetterSpacing) {\n stripLineEndLetterSpacing(lineEl);\n }\n\n textBlock.appendChild(lineEl);\n if (lineIndex < lines.length - 1) {\n textBlock.appendChild(document.createTextNode('\\n'));\n }\n });\n};\n\nconst appendInlineMarkdownRun = (arg: {\n parent: HTMLElement;\n run: Awaited<ReturnType<typeof resolveRichTextRuns>>[number];\n schema: TextSchema;\n font: NonNullable<UIRenderProps<TextSchema>['options']['font']>;\n}) => {\n const { parent, run, schema, font } = arg;\n const href = run.href ? normalizeLinkHref(run.href) : undefined;\n const span = href ? document.createElement('a') : document.createElement('span');\n const processedText = replaceUnsupportedChars(run.text, run.fontKitFont);\n const textDecorations: string[] = [];\n\n span.textContent = processedText;\n if (href) {\n const anchor = span as HTMLAnchorElement;\n anchor.href = href;\n if (!getInternalLinkTarget(href)) {\n anchor.target = '_blank';\n anchor.rel = 'noopener noreferrer';\n }\n textDecorations.push('underline');\n }\n if (run.fontName) {\n span.style.fontFamily = `'${run.fontName}'`;\n }\n if (run.syntheticBold) {\n span.style.fontWeight = '800';\n span.style.textShadow = SYNTHETIC_BOLD_CSS_TEXT_SHADOW;\n }\n if (run.syntheticItalic) {\n span.style.fontStyle = 'italic';\n }\n if (run.strikethrough) {\n textDecorations.push('line-through');\n }\n if (textDecorations.length > 0) {\n span.style.textDecoration = textDecorations.join(' ');\n }\n if (run.code) {\n span.style.backgroundColor = CODE_BACKGROUND_COLOR;\n span.style.borderRadius = '2px';\n span.style.padding = `0 ${CODE_HORIZONTAL_PADDING}pt`;\n if (!schema.fontVariants?.code || !font[schema.fontVariants.code]) {\n span.style.fontFamily = run.fontName ? `'${run.fontName}', monospace` : 'monospace';\n }\n }\n parent.appendChild(span);\n};\n\nconst applySharedWrapLineSpacing = (\n lineEl: HTMLElement,\n line: { text: string; width: number; hardBreak: boolean },\n alignment: string,\n boxWidthInPt: number,\n characterSpacing: number,\n) => {\n const { extraLetterSpacing } = getLineAlignment(line, boxWidthInPt, alignment);\n const stripTrailingLetterSpacing = !(alignment === ALIGN_JUSTIFY && !line.hardBreak);\n if (!stripTrailingLetterSpacing && extraLetterSpacing !== 0) {\n lineEl.style.letterSpacing = `${characterSpacing + extraLetterSpacing}pt`;\n }\n return stripTrailingLetterSpacing;\n};\n\nconst stripLineEndLetterSpacing = (lineEl: HTMLElement) => {\n let node: ChildNode | null = lineEl.lastChild;\n while (node && (node.nodeType !== Node.ELEMENT_NODE || !node.textContent)) {\n node = node.previousSibling;\n }\n if (!node || node.nodeType !== Node.ELEMENT_NODE) return;\n\n const el = node as HTMLElement;\n const graphemes = splitGraphemes(el.textContent ?? '');\n if (graphemes.length === 0) return;\n if (graphemes.length === 1) {\n el.style.letterSpacing = '0';\n return;\n }\n\n el.textContent = graphemes.slice(0, -1).join('');\n const tail = document.createElement('span');\n tail.textContent = graphemes[graphemes.length - 1];\n tail.style.letterSpacing = '0';\n el.appendChild(tail);\n};\n\nconst renderReadOnlyPlainLines = (arg: {\n textBlock: HTMLDivElement;\n lines: WrapLine[];\n fontKitFont: FontKitFont;\n fontSize: number;\n characterSpacing: number;\n alignment: string;\n boxWidthInPt: number;\n}) => {\n const { textBlock, lines, fontKitFont, fontSize, characterSpacing, alignment, boxWidthInPt } =\n arg;\n textBlock.innerHTML = '';\n\n lines.forEach((line, lineIndex) => {\n const lineEl = document.createElement('span');\n lineEl.dataset.pdfmeWrapLine = '';\n lineEl.style.whiteSpace = 'pre';\n const displayText = replaceUnsupportedChars(line.text, fontKitFont);\n\n const textWidth = widthOfTextAtSize(line.text, fontKitFont, fontSize, characterSpacing);\n const stripTrailingLetterSpacing = applySharedWrapLineSpacing(\n lineEl,\n { text: line.text, width: textWidth, hardBreak: line.hardBreak },\n alignment,\n boxWidthInPt,\n characterSpacing,\n );\n\n const graphemes = splitGraphemes(displayText);\n graphemes.forEach((grapheme, index) => {\n const span = document.createElement('span');\n span.textContent = grapheme;\n // PDF `setCharacterSpacing` applies Tc after every grapheme, including\n // the last. Zeroing the last glyph is only for ordinary characterSpacing\n // so browsers do not count a trailing gap when wrapping.\n if (index === graphemes.length - 1 && stripTrailingLetterSpacing) {\n span.style.letterSpacing = '0';\n }\n lineEl.appendChild(span);\n });\n\n textBlock.appendChild(lineEl);\n // Join with a real newline so `pre` paints one visual line per wrap line\n // and `textContent` keeps paragraph breaks. Do not suffix facade `\\n`\n // characters — that would add an extra blank line after each paragraph.\n if (lineIndex < lines.length - 1) {\n textBlock.appendChild(document.createTextNode('\\n'));\n }\n });\n};\n\nconst getRangedPlainTextValue = (arg: {\n value: string;\n schema: TextSchema;\n fontKitFont: FontKitFont;\n fontSize: number;\n}) => {\n const { value, schema, fontKitFont, fontSize } = arg;\n const lineRange = getTextLineRange(schema);\n if (!lineRange) return value;\n\n const lines = applyTextLineRange(\n splitTextToSize({\n value,\n characterSpacing: schema.characterSpacing ?? DEFAULT_CHARACTER_SPACING,\n fontSize,\n fontKitFont,\n boxWidthInPt: mm2pt(getBoxContentArea(schema).width),\n }),\n lineRange,\n );\n return plainTextLinesToValue(lines);\n};\n\nexport const buildStyledTextContainer = (\n arg: UIRenderProps<TextSchema>,\n fontKitFont: FontKitFont,\n value: string,\n resolvedDynamicFontSize?: number,\n display?: { useComputedWrapLines?: boolean },\n) => {\n const { schema, rootElement, mode } = arg;\n\n let dynamicFontSize: undefined | number = resolvedDynamicFontSize;\n const characterSpacing = schema.characterSpacing ?? DEFAULT_CHARACTER_SPACING;\n const editable = isEditable(mode, schema);\n // `pre` + left-for-justify is for read-only displays whose wrap-engine\n // lines are already computed (plain text and inline Markdown). Live Form /\n // Designer editing keeps `pre-wrap` so caret / IME stay native.\n const useComputedWrapLines = display?.useComputedWrapLines ?? !editable;\n\n if (dynamicFontSize === undefined && shouldUseDynamicFontSize(schema, arg.basePdf) && value) {\n dynamicFontSize = calculateDynamicFontSize({\n textSchema: schema,\n fontKitFont,\n value,\n startingFontSize: dynamicFontSize,\n });\n }\n\n // Depending on vertical alignment, we need to move the top or bottom of the font to keep\n // it within it's defined box and align it with the generated pdf.\n const { topAdj, bottomAdj } = getBrowserVerticalFontAdjustments(\n fontKitFont,\n dynamicFontSize ?? schema.fontSize ?? DEFAULT_FONT_SIZE,\n schema.lineHeight ?? DEFAULT_LINE_HEIGHT,\n schema.verticalAlignment ?? DEFAULT_VERTICAL_ALIGNMENT,\n );\n\n const topAdjustment = topAdj.toString();\n const bottomAdjustment = bottomAdj.toString();\n const verticalAlignment = schema.verticalAlignment ?? DEFAULT_VERTICAL_ALIGNMENT;\n const isTopAligned = verticalAlignment === VERTICAL_ALIGN_TOP;\n\n const container = document.createElement('div');\n const { borderWidth, padding } = getBoxInsets(schema);\n const hasPadding = hasBoxDimension(schema.padding);\n const hasBorder = Boolean(schema.borderColor && hasBoxDimension(schema.borderWidth));\n\n const containerStyle: CSS.Properties = {\n padding: hasPadding\n ? `${padding.top}mm ${padding.right}mm ${padding.bottom}mm ${padding.left}mm`\n : 0,\n resize: 'none',\n backgroundColor: getBackgroundColor(schema),\n border: hasBorder ? undefined : 'none',\n ...(hasBorder\n ? {\n borderTopWidth: `${borderWidth.top}mm`,\n borderRightWidth: `${borderWidth.right}mm`,\n borderBottomWidth: `${borderWidth.bottom}mm`,\n borderLeftWidth: `${borderWidth.left}mm`,\n borderStyle: 'solid',\n borderColor: schema.borderColor,\n }\n : {}),\n ...(hasPadding || hasBorder ? { boxSizing: 'border-box' } : {}),\n display: 'flex',\n flexDirection: 'column',\n justifyContent: mapVerticalAlignToFlex(verticalAlignment),\n width: '100%',\n height: '100%',\n cursor: editable ? 'text' : 'default',\n };\n Object.assign(container.style, containerStyle);\n rootElement.innerHTML = '';\n rootElement.appendChild(container);\n\n // text decoration\n const textDecorations = [];\n if (schema.strikethrough) textDecorations.push('line-through');\n if (schema.underline) textDecorations.push('underline');\n\n const alignment = schema.alignment ?? DEFAULT_ALIGNMENT;\n const textBlockStyle: CSS.Properties = {\n // Font formatting styles\n fontFamily: schema.fontName ? `'${schema.fontName}'` : 'inherit',\n color: schema.fontColor ? schema.fontColor : DEFAULT_FONT_COLOR,\n fontSize: `${dynamicFontSize ?? schema.fontSize ?? DEFAULT_FONT_SIZE}pt`,\n letterSpacing: `${characterSpacing}pt`,\n lineHeight: `${schema.lineHeight ?? DEFAULT_LINE_HEIGHT}em`,\n // Read-only Viewer paints wrap-engine lines with `pre`. CSS justify would\n // fight the PDF grapheme-count letter-spacing applied per soft line.\n textAlign: useComputedWrapLines && alignment === ALIGN_JUSTIFY ? 'left' : alignment,\n whiteSpace: useComputedWrapLines ? 'pre' : 'pre-wrap',\n wordBreak: useComputedWrapLines ? 'normal' : 'break-word',\n // Block layout styles\n resize: 'none',\n border: 'none',\n outline: 'none',\n marginBottom: `${bottomAdjustment}px`,\n paddingTop: `${topAdjustment}px`,\n backgroundColor: 'transparent',\n textDecoration: textDecorations.join(' '),\n // Browsers include the final letter-spacing in editable text wrapping, unlike PDF rendering.\n ...(editable && characterSpacing > 0 ? { width: `calc(100% + ${characterSpacing}pt)` } : {}),\n ...(isTopAligned ? { height: '100%' } : {}),\n };\n\n const textBlock = document.createElement('div');\n textBlock.id = 'text-' + String(schema.id);\n Object.assign(textBlock.style, textBlockStyle);\n\n container.appendChild(textBlock);\n\n return textBlock;\n};\n\n/**\n * Firefox doesn't support 'plaintext-only' contentEditable mode, which we want to avoid mark-up.\n * This function adds a workaround for Firefox to make the contentEditable element behave like 'plaintext-only'.\n */\nexport const makeElementPlainTextContentEditable = (element: HTMLElement) => {\n if (!isFirefox()) {\n element.contentEditable = 'plaintext-only';\n return;\n }\n\n element.contentEditable = 'true';\n element.addEventListener('keydown', (e: KeyboardEvent) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n document.execCommand('insertLineBreak', false, undefined);\n }\n });\n\n element.addEventListener('paste', (e: ClipboardEvent) => {\n e.preventDefault();\n const paste = e.clipboardData?.getData('text');\n const selection = window.getSelection();\n if (!selection?.rangeCount) return;\n selection.deleteFromDocument();\n selection.getRangeAt(0).insertNode(document.createTextNode(paste || ''));\n selection.collapseToEnd();\n });\n};\n\nexport const mapVerticalAlignToFlex = (verticalAlignmentValue: string | undefined) => {\n switch (verticalAlignmentValue) {\n case VERTICAL_ALIGN_TOP:\n return 'flex-start';\n case VERTICAL_ALIGN_MIDDLE:\n return 'center';\n case VERTICAL_ALIGN_BOTTOM:\n return 'flex-end';\n }\n return 'flex-start';\n};\n\nconst getBackgroundColor = (schema: { backgroundColor?: string }) => {\n if (!schema.backgroundColor) return 'transparent';\n return schema.backgroundColor;\n};\n","import type { Plugin } from '@pdfme/common';\nimport { pdfRender } from './pdfRender.js';\nimport { propPanel } from './propPanel.js';\nimport { uiRender } from './uiRender.js';\nimport type { TextSchema } from './types.js';\nimport { TextCursorInput } from 'lucide';\nimport { createSvgStr } from '../utils.js';\n\nconst textSchema: Plugin<TextSchema> = {\n pdf: pdfRender,\n ui: uiRender,\n propPanel,\n icon: createSvgStr(TextCursorInput),\n};\n\nexport default textSchema;\n","import text from './text/index.js';\n\n// The default built-in plugin surface is intentionally limited to text.\n// Generator/UI consumers that need image, barcode, table, or other schema types\n// must import and pass those plugins explicitly from `@pdfme/schemas`.\nconst builtInPlugins = { Text: text };\n\nexport { builtInPlugins };\n"],"mappings":";;;;;;;;AAWA,IAAa,wBAAwB,QAM/B;CACJ,MAAM,EAAE,QAAQ,MAAM,KAAK,MAAM,cAAc,MAAM;CACrD,MAAM,UAAU,qBAAqB,GAAG;CACxC,IAAI,CAAC,WAAW,KAAK,SAAS,KAAK,KAAK,UAAU,GAAG;CAErD,MAAM,gBAAgB,OAAO,QAAQ,SACnC,OAAO,QAAQ,IAAI;EACjB,MAAM,QAAQ,GAAG,OAAO;EACxB,SAAS,QAAQ,GAAG,MAAM;EAC1B,MAAM;GAAC,KAAK;GAAG,KAAK;GAAG,KAAK,IAAI,KAAK;GAAO,KAAK,IAAI,KAAK;EAAM;EAChE,QAAQ;GAAC;GAAG;GAAG;EAAW;EAC1B,GAAG;GACD,MAAM,QAAQ,GAAG,QAAQ;GACzB,GAAG,QAAQ,GAAG,KAAK;GACnB,KAAK,UAAU,GAAG,OAAO;EAC3B;CACF,CAAC,CACH;CAEA,KAAK,KAAK,SAAS,aAAa;AAClC;;;ACXA,IAAM,yBAAyB,KAAsB,aACnD,IAAI,gBAAgB,WAAW,8BAAA,IAA+D;AAEhG,IAAM,2BAA2B,KAAs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AAE;CACzC,OAAO,OAAO,UAAU,OAAO,cAAc;CAE7C,UAAU,YAAY,SAAS;CAE/B,OAAO;AACT;;;;;AAMA,IAAa,uCAAuC,YAAyB;CAC3E,IAAI,CAAC,UAAU,GAAG;EAChB,QAAQ,kBAAkB;EAC1B;CACF;CAEA,QAAQ,kBAAkB;CAC1B,QAAQ,iBAAiB,YAAY,MAAqB;EACxD,IAAI,EAAE,QAAQ,WAAW,CAAC,EAAE,UAAU;GACpC,EAAE,eAAe;GACjB,SAAS,YAAY,mBAAmB,OAAO,KAAA,CAAS;EAC1D;CACF,CAAC;CAED,QAAQ,iBAAiB,UAAU,MAAsB;EACvD,EAAE,eAAe;EACjB,MAAM,QAAQ,EAAE,eAAe,QAAQ,MAAM;EAC7C,MAAM,YAAY,OAAO,aAAa;EACtC,IAAI,CAAC,WAAW,YAAY;EAC5B,UAAU,mBAAmB;EAC7B,UAAU,WAAW,CAAC,CAAC,CAAC,WAAW,SAAS,eAAe,SAAS,EAAE,CAAC;EACvE,UAAU,cAAc;CAC1B,CAAC;AACH;AAEA,IAAa,0BAA0B,2BAA+C;CACpF,QAAQ,wBAAR;EACE,KAAA,OACE,OAAO;EACT,KAAK,uBACH,OAAO;EACT,KAAK,uBACH,OAAO;CACX;CACA,OAAO;AACT;AAEA,IAAM,sBAAsB,WAAyC;CACnE,IAAI,CAAC,OAAO,iBAAiB,OAAO;CACpC,OAAO,OAAO;AAChB;;;AChnBA,IAAM,aAAiC;CACrC,KAAK;CACL,IAAI;CACJ;CACA,MAAM,aAAa,eAAe;AACpC;;;ACRA,IAAM,iBAAiB,EAAE,MAAM,WAAK"}
|
package/dist/builtins.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as builtInPlugins } from "./builtins-
|
|
1
|
+
import { t as builtInPlugins } from "./builtins-BEweDprE.js";
|
|
2
2
|
export { builtInPlugins };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { D as getBoxContentArea, E as createBoxDimension, L as CODE_BACKGROUND_COLOR, V as DEFAULT_FONT_COLOR, X as PLACEHOLDER_FONT_COLOR, Z as SYNTHETIC_BOLD_CSS_TEXT_SHADOW, a as createListItemSplitRange, c as getListItemRange, g as getFontKitFont, i as TEXT_LINE_SPLIT_UNIT, it as VERTICAL_ALIGN_MIDDLE, l as getTableBodyRange, n as LIST_ITEM_SPLIT_UNIT, o as createTableBodySplitRange, r as TABLE_BODY_SPLIT_UNIT, s as createTextLineSplitRange, t as BUILT_IN_DYNAMIC_LAYOUT_SPLIT_UNITS, u as getTextLineRange, z as DEFAULT_ALIGNMENT } from "./splitRange-B6311Noc.js";
|
|
2
2
|
import { a as measureTextLines, f as resolveFontVariant, h as parseInlineMarkdown, u as isInlineMarkdownTextSchema } from "./measure-BarlRI1L.js";
|
|
3
|
-
import { a as mapVerticalAlignToFlex, c as Formatter, d as embedAndGetFont, i as makeElementPlainTextContentEditable, l as getExtraFormatterSchema, n as textSchema, o as uiRender$4, r as buildStyledTextContainer, s as propPanel$3, t as builtInPlugins, u as pdfRender$4 } from "./builtins-
|
|
3
|
+
import { a as mapVerticalAlignToFlex, c as Formatter, d as embedAndGetFont, i as makeElementPlainTextContentEditable, l as getExtraFormatterSchema, n as textSchema, o as uiRender$4, r as buildStyledTextContainer, s as propPanel$3, t as builtInPlugins, u as pdfRender$4 } from "./builtins-BEweDprE.js";
|
|
4
4
|
import { a as getCellPropPanelSchema, c as HEX_COLOR_PATTERN, i as getBodyWithSchemaRange, l as createSingleTable, n as getDynamicLayoutForTable, o as getColumnStylesPropPanelSchema, r as getBody, s as getDefaultCellStyles, t as getDynamicHeightsForTable } from "./dynamicTemplate-DkTVIMNr.js";
|
|
5
|
-
import {
|
|
5
|
+
import { a as createSvgStr, d as rgbColorToCmykColor, f as rotatePoint, g as visitVariables, h as getVariableNames, i as createErrorElm, l as isEditable, m as countUniqueVariableNames, n as applyAlphaToOpacity, p as splitHexAlpha, r as convertForPdfLayoutProps, s as hex2PrintingColor, t as addAlphaToHex, u as readFile } from "./utils-BhkbT1F9.js";
|
|
6
6
|
import { a as normalizeListItems, c as LIST_STYLE_BULLET, i as normalizeListItemEntries, l as LIST_STYLE_ORDERED, n as calculateListLayout, o as serializeListItems, s as DEFAULT_LIST_STYLE, t as getDynamicLayoutForList } from "./dynamicTemplate-CcnCXHfM.js";
|
|
7
7
|
import { i as validateVariables, n as substituteVariables, r as substituteVariablesAsInlineMarkdownLiterals, t as resolveReadOnlyMultiVariableText } from "./helper-BR4_UZA5.js";
|
|
8
8
|
import "./tables.js";
|
|
9
9
|
import "./lists.js";
|
|
10
|
-
import { DEFAULT_FONT_NAME, ZOOM, b64toUint8Array, getDefaultFont, getFallbackFontName, getInternalLinkTarget, mm2pt, normalizeLinkHref, px2mm } from "@pdfme/common";
|
|
10
|
+
import { DEFAULT_FONT_NAME, ZOOM, b64toUint8Array, getDefaultFont, getFallbackFontName, getInternalLinkTarget, isHexValid, mm2pt, normalizeLinkHref, px2mm } from "@pdfme/common";
|
|
11
11
|
import { Buffer as Buffer$1 } from "buffer";
|
|
12
12
|
import { popGraphicsState, pushGraphicsState, rotateDegrees, translate } from "@pdfme/pdf-lib";
|
|
13
13
|
import { Barcode, Calendar, CalendarClock, ChevronDown, Circle, CircleDot, Clock, Image, List, Minus, QrCode, Route, Square, SquareCheck, Table, Type } from "lucide";
|
|
@@ -674,13 +674,15 @@ var shape = {
|
|
|
674
674
|
applyRotateTranslate: false
|
|
675
675
|
});
|
|
676
676
|
const borderWidth = schema.borderWidth ? mm2pt(schema.borderWidth) : 0;
|
|
677
|
+
const { color: fillHex, alpha: fillAlpha } = splitHexAlpha(schema.color ?? "");
|
|
678
|
+
const { color: borderHex, alpha: borderAlpha } = splitHexAlpha(schema.borderColor ?? "");
|
|
677
679
|
const drawOptions = {
|
|
678
680
|
rotate,
|
|
679
681
|
borderWidth,
|
|
680
|
-
borderColor: hex2PrintingColor(
|
|
681
|
-
color: hex2PrintingColor(
|
|
682
|
-
opacity,
|
|
683
|
-
borderOpacity: opacity
|
|
682
|
+
borderColor: hex2PrintingColor(borderHex, colorType),
|
|
683
|
+
color: hex2PrintingColor(fillHex, colorType),
|
|
684
|
+
opacity: applyAlphaToOpacity(opacity, fillAlpha),
|
|
685
|
+
borderOpacity: applyAlphaToOpacity(opacity, borderAlpha)
|
|
684
686
|
};
|
|
685
687
|
if (schema.type === "ellipse") page.drawEllipse({
|
|
686
688
|
x: x4Ellipse + width / 2,
|
|
@@ -2455,9 +2457,21 @@ var validateBarcodeInput = (type, input) => {
|
|
|
2455
2457
|
*/
|
|
2456
2458
|
var barCodeType2Bcid = (type) => type === "nw7" ? "rationalizedCodabar" : type;
|
|
2457
2459
|
/**
|
|
2458
|
-
* Strip hash from the beginning of HTML hex color codes for the bwip.js lib
|
|
2460
|
+
* Strip hash from the beginning of HTML hex color codes for the bwip.js lib.
|
|
2461
|
+
* Any '#RGBA'/'#RRGGBBAA' alpha channel is dropped first (rendered opaque, like
|
|
2462
|
+
* AcroForm colors): bwip-js has no alpha support — it reads 8-digit hex as CMYK
|
|
2463
|
+
* and throws on 4-digit hex. Hash-less colors pass through untouched because
|
|
2464
|
+
* bwip-js natively treats those as RRGGBB/CCMMYYKK.
|
|
2459
2465
|
*/
|
|
2460
|
-
var mapHexColorForBwipJsLib = (color, fallback) =>
|
|
2466
|
+
var mapHexColorForBwipJsLib = (color, fallback) => {
|
|
2467
|
+
const hex = color || fallback;
|
|
2468
|
+
return hex ? splitHexAlpha(hex).color.replace("#", "") : "000000";
|
|
2469
|
+
};
|
|
2470
|
+
/**
|
|
2471
|
+
* Barcode colors historically accept bwip-js style hex without a leading '#';
|
|
2472
|
+
* CSS and pdfme's color utils require the '#', so add it when missing.
|
|
2473
|
+
*/
|
|
2474
|
+
var ensureHexColorHash = (color) => color && !color.startsWith("#") && isHexValid(`#${color}`) ? `#${color}` : color;
|
|
2461
2475
|
var getBwipJsRenderer = () => bwipjs;
|
|
2462
2476
|
var getDocument = () => globalThis.document;
|
|
2463
2477
|
var getOffscreenCanvasCtor = () => globalThis.OffscreenCanvas;
|
|
@@ -2532,7 +2546,7 @@ var createBarCode = async (arg) => {
|
|
|
2532
2546
|
//#endregion
|
|
2533
2547
|
//#region src/barcodes/pdfRender.ts
|
|
2534
2548
|
var getBarcodeCacheKey = (schema, value) => {
|
|
2535
|
-
return `svg:${schema.type}:${schema.width}:${schema.height}:${schema.
|
|
2549
|
+
return `svg:${schema.type}:${schema.width}:${schema.height}:${schema.barColor}:${schema.textColor}:${schema.includetext}:${value}`;
|
|
2536
2550
|
};
|
|
2537
2551
|
var addSvgOpacity = (svg, opacity) => {
|
|
2538
2552
|
return opacity === void 0 ? svg : svg.replace(/<svg\b/, `<svg opacity="${opacity}"`);
|
|
@@ -2551,9 +2565,11 @@ var pdfRender$1 = async (arg) => {
|
|
|
2551
2565
|
if (!svg) {
|
|
2552
2566
|
svg = createBarCodeSvg({
|
|
2553
2567
|
...schema,
|
|
2568
|
+
backgroundColor: void 0,
|
|
2554
2569
|
type: schema.type,
|
|
2555
2570
|
input: value
|
|
2556
2571
|
});
|
|
2572
|
+
svg = svg.replace(/<svg\b/, "<svg preserveAspectRatio=\"none\"");
|
|
2557
2573
|
_cache.set(inputBarcodeCacheKey, svg);
|
|
2558
2574
|
}
|
|
2559
2575
|
const pageHeight = page.getHeight();
|
|
@@ -2569,6 +2585,19 @@ var pdfRender$1 = async (arg) => {
|
|
|
2569
2585
|
const rotate = schema.rotate ? -schema.rotate : 0;
|
|
2570
2586
|
if (rotate) page.pushOperators(pushGraphicsState(), translate(pivot.x, pivot.y), rotateDegrees(rotate), translate(-pivot.x, -pivot.y));
|
|
2571
2587
|
try {
|
|
2588
|
+
const backgroundHex = ensureHexColorHash(schema.backgroundColor);
|
|
2589
|
+
if (backgroundHex) {
|
|
2590
|
+
const { color: backgroundColorHex, alpha } = splitHexAlpha(backgroundHex);
|
|
2591
|
+
const backgroundColor = alpha > 0 ? hex2PrintingColor(backgroundColorHex, options.colorType) : void 0;
|
|
2592
|
+
if (backgroundColor) page.drawRectangle({
|
|
2593
|
+
x,
|
|
2594
|
+
y,
|
|
2595
|
+
width,
|
|
2596
|
+
height,
|
|
2597
|
+
color: backgroundColor,
|
|
2598
|
+
opacity: applyAlphaToOpacity(opacity, alpha)
|
|
2599
|
+
});
|
|
2600
|
+
}
|
|
2572
2601
|
await page.drawSvg(addSvgOpacity(svg, opacity), {
|
|
2573
2602
|
x,
|
|
2574
2603
|
y: y + height,
|
|
@@ -2800,6 +2829,7 @@ var blobToDataURL = (blob) => new Promise((resolve, reject) => {
|
|
|
2800
2829
|
var createBarcodeImage = async (schema, value) => {
|
|
2801
2830
|
const imageBuf = await createBarCode({
|
|
2802
2831
|
...schema,
|
|
2832
|
+
backgroundColor: void 0,
|
|
2803
2833
|
input: value
|
|
2804
2834
|
});
|
|
2805
2835
|
return await blobToDataURL(new Blob([new Uint8Array(imageBuf)], { type: "image/png" }));
|
|
@@ -2823,7 +2853,8 @@ var uiRender$1 = async (arg) => {
|
|
|
2823
2853
|
display: "flex",
|
|
2824
2854
|
alignItems: "center",
|
|
2825
2855
|
justifyContent: "center",
|
|
2826
|
-
fontFamily: "'Open Sans', sans-serif"
|
|
2856
|
+
fontFamily: "'Open Sans', sans-serif",
|
|
2857
|
+
backgroundColor: ensureHexColorHash(schema.backgroundColor) || "transparent"
|
|
2827
2858
|
};
|
|
2828
2859
|
Object.assign(container.style, containerStyle);
|
|
2829
2860
|
rootElement.appendChild(container);
|
|
@@ -2898,6 +2929,7 @@ var lineSchema = {
|
|
|
2898
2929
|
x: x + width / 2,
|
|
2899
2930
|
y: y + height / 2
|
|
2900
2931
|
};
|
|
2932
|
+
const { color: lineHex, alpha } = splitHexAlpha(schema.color ?? DEFAULT_LINE_COLOR);
|
|
2901
2933
|
page.drawLine({
|
|
2902
2934
|
start: rotatePoint({
|
|
2903
2935
|
x,
|
|
@@ -2908,8 +2940,8 @@ var lineSchema = {
|
|
|
2908
2940
|
y: y + height / 2
|
|
2909
2941
|
}, pivot, rotate.angle),
|
|
2910
2942
|
thickness: height,
|
|
2911
|
-
color: hex2PrintingColor(
|
|
2912
|
-
opacity
|
|
2943
|
+
color: hex2PrintingColor(lineHex, colorType),
|
|
2944
|
+
opacity: applyAlphaToOpacity(opacity, alpha)
|
|
2913
2945
|
});
|
|
2914
2946
|
},
|
|
2915
2947
|
ui: (arg) => {
|