@embedpdf/models 1.0.12 → 1.0.14

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/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export * from './pdf';
13
13
  export * from './task';
14
14
  export * from './color';
15
15
  export * from './date';
16
+ export * from './helpers';
16
17
  /**
17
18
  * ignore will do nothing when called.
18
19
  *
package/dist/index.js CHANGED
@@ -106,6 +106,41 @@ function restorePosition(containerSize, position, rotation, scaleFactor) {
106
106
  1 / scaleFactor
107
107
  );
108
108
  }
109
+ function rectEquals(a, b) {
110
+ return a.origin.x === b.origin.x && a.origin.y === b.origin.y && a.size.width === b.size.width && a.size.height === b.size.height;
111
+ }
112
+ function rectFromPoints(positions) {
113
+ if (positions.length === 0) {
114
+ return { origin: { x: 0, y: 0 }, size: { width: 0, height: 0 } };
115
+ }
116
+ const xs = positions.map((p) => p.x);
117
+ const ys = positions.map((p) => p.y);
118
+ const minX = Math.min(...xs);
119
+ const minY = Math.min(...ys);
120
+ return {
121
+ origin: { x: minX, y: minY },
122
+ size: {
123
+ width: Math.max(...xs) - minX,
124
+ height: Math.max(...ys) - minY
125
+ }
126
+ };
127
+ }
128
+ function rotateAndTranslatePoint(pos, angleRad, translate) {
129
+ const cos = Math.cos(angleRad);
130
+ const sin = Math.sin(angleRad);
131
+ const newX = pos.x * cos - pos.y * sin;
132
+ const newY = pos.x * sin + pos.y * cos;
133
+ return {
134
+ x: newX + translate.x,
135
+ y: newY + translate.y
136
+ };
137
+ }
138
+ function expandRect(rect, padding) {
139
+ return {
140
+ origin: { x: rect.origin.x - padding, y: rect.origin.y - padding },
141
+ size: { width: rect.size.width + padding * 2, height: rect.size.height + padding * 2 }
142
+ };
143
+ }
109
144
  function rotateRect(containerSize, rect, rotation) {
110
145
  let x = rect.origin.x;
111
146
  let y = rect.origin.y;
@@ -733,6 +768,36 @@ var PdfZoomMode = /* @__PURE__ */ ((PdfZoomMode2) => {
733
768
  PdfZoomMode2[PdfZoomMode2["FitRectangle"] = 5] = "FitRectangle";
734
769
  return PdfZoomMode2;
735
770
  })(PdfZoomMode || {});
771
+ var PdfStandardFont = /* @__PURE__ */ ((PdfStandardFont2) => {
772
+ PdfStandardFont2[PdfStandardFont2["Unknown"] = -1] = "Unknown";
773
+ PdfStandardFont2[PdfStandardFont2["Courier"] = 0] = "Courier";
774
+ PdfStandardFont2[PdfStandardFont2["Courier_Bold"] = 1] = "Courier_Bold";
775
+ PdfStandardFont2[PdfStandardFont2["Courier_BoldOblique"] = 2] = "Courier_BoldOblique";
776
+ PdfStandardFont2[PdfStandardFont2["Courier_Oblique"] = 3] = "Courier_Oblique";
777
+ PdfStandardFont2[PdfStandardFont2["Helvetica"] = 4] = "Helvetica";
778
+ PdfStandardFont2[PdfStandardFont2["Helvetica_Bold"] = 5] = "Helvetica_Bold";
779
+ PdfStandardFont2[PdfStandardFont2["Helvetica_BoldOblique"] = 6] = "Helvetica_BoldOblique";
780
+ PdfStandardFont2[PdfStandardFont2["Helvetica_Oblique"] = 7] = "Helvetica_Oblique";
781
+ PdfStandardFont2[PdfStandardFont2["Times_Roman"] = 8] = "Times_Roman";
782
+ PdfStandardFont2[PdfStandardFont2["Times_Bold"] = 9] = "Times_Bold";
783
+ PdfStandardFont2[PdfStandardFont2["Times_BoldItalic"] = 10] = "Times_BoldItalic";
784
+ PdfStandardFont2[PdfStandardFont2["Times_Italic"] = 11] = "Times_Italic";
785
+ PdfStandardFont2[PdfStandardFont2["Symbol"] = 12] = "Symbol";
786
+ PdfStandardFont2[PdfStandardFont2["ZapfDingbats"] = 13] = "ZapfDingbats";
787
+ return PdfStandardFont2;
788
+ })(PdfStandardFont || {});
789
+ var PdfTextAlignment = /* @__PURE__ */ ((PdfTextAlignment2) => {
790
+ PdfTextAlignment2[PdfTextAlignment2["Left"] = 0] = "Left";
791
+ PdfTextAlignment2[PdfTextAlignment2["Center"] = 1] = "Center";
792
+ PdfTextAlignment2[PdfTextAlignment2["Right"] = 2] = "Right";
793
+ return PdfTextAlignment2;
794
+ })(PdfTextAlignment || {});
795
+ var PdfVerticalAlignment = /* @__PURE__ */ ((PdfVerticalAlignment2) => {
796
+ PdfVerticalAlignment2[PdfVerticalAlignment2["Top"] = 0] = "Top";
797
+ PdfVerticalAlignment2[PdfVerticalAlignment2["Middle"] = 1] = "Middle";
798
+ PdfVerticalAlignment2[PdfVerticalAlignment2["Bottom"] = 2] = "Bottom";
799
+ return PdfVerticalAlignment2;
800
+ })(PdfVerticalAlignment || {});
736
801
  var PdfBlendMode = /* @__PURE__ */ ((PdfBlendMode2) => {
737
802
  PdfBlendMode2[PdfBlendMode2["Normal"] = 0] = "Normal";
738
803
  PdfBlendMode2[PdfBlendMode2["Multiply"] = 1] = "Multiply";
@@ -752,66 +817,6 @@ var PdfBlendMode = /* @__PURE__ */ ((PdfBlendMode2) => {
752
817
  PdfBlendMode2[PdfBlendMode2["Luminosity"] = 15] = "Luminosity";
753
818
  return PdfBlendMode2;
754
819
  })(PdfBlendMode || {});
755
- const MixedBlendMode = Symbol("mixed");
756
- const BLEND_MODE_INFOS = Object.freeze([
757
- { id: 0, label: "Normal", css: "normal" },
758
- { id: 1, label: "Multiply", css: "multiply" },
759
- { id: 2, label: "Screen", css: "screen" },
760
- { id: 3, label: "Overlay", css: "overlay" },
761
- { id: 4, label: "Darken", css: "darken" },
762
- { id: 5, label: "Lighten", css: "lighten" },
763
- { id: 6, label: "Color Dodge", css: "color-dodge" },
764
- { id: 7, label: "Color Burn", css: "color-burn" },
765
- { id: 8, label: "Hard Light", css: "hard-light" },
766
- { id: 9, label: "Soft Light", css: "soft-light" },
767
- { id: 10, label: "Difference", css: "difference" },
768
- { id: 11, label: "Exclusion", css: "exclusion" },
769
- { id: 12, label: "Hue", css: "hue" },
770
- { id: 13, label: "Saturation", css: "saturation" },
771
- { id: 14, label: "Color", css: "color" },
772
- { id: 15, label: "Luminosity", css: "luminosity" }
773
- ]);
774
- const enumToInfo = BLEND_MODE_INFOS.reduce(
775
- (m, info) => {
776
- m[info.id] = info;
777
- return m;
778
- },
779
- {}
780
- );
781
- const cssToEnum = BLEND_MODE_INFOS.reduce(
782
- (m, info) => {
783
- m[info.css] = info.id;
784
- return m;
785
- },
786
- {}
787
- );
788
- function getBlendModeInfo(mode) {
789
- return enumToInfo[mode] ?? enumToInfo[
790
- 0
791
- /* Normal */
792
- ];
793
- }
794
- function blendModeToCss(mode) {
795
- return getBlendModeInfo(mode).css;
796
- }
797
- function cssToBlendMode(value) {
798
- return cssToEnum[value];
799
- }
800
- function blendModeLabel(mode) {
801
- return getBlendModeInfo(mode).label;
802
- }
803
- function reduceBlendModes(modes) {
804
- if (!modes.length) return 0;
805
- const first = modes[0];
806
- return modes.every((m) => m === first) ? first : MixedBlendMode;
807
- }
808
- const blendModeSelectOptions = BLEND_MODE_INFOS.map((info) => ({
809
- value: info.id,
810
- label: info.label
811
- }));
812
- function uiBlendModeDisplay(value) {
813
- return value === MixedBlendMode ? "(mixed)" : blendModeLabel(value);
814
- }
815
820
  var PdfActionType = /* @__PURE__ */ ((PdfActionType2) => {
816
821
  PdfActionType2[PdfActionType2["Unsupported"] = 0] = "Unsupported";
817
822
  PdfActionType2[PdfActionType2["Goto"] = 1] = "Goto";
@@ -996,6 +1001,20 @@ var PdfAnnotationStateModel = /* @__PURE__ */ ((PdfAnnotationStateModel2) => {
996
1001
  PdfAnnotationStateModel2["Reviewed"] = "Reviewed";
997
1002
  return PdfAnnotationStateModel2;
998
1003
  })(PdfAnnotationStateModel || {});
1004
+ var PdfAnnotationLineEnding = /* @__PURE__ */ ((PdfAnnotationLineEnding2) => {
1005
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["None"] = 0] = "None";
1006
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Square"] = 1] = "Square";
1007
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Circle"] = 2] = "Circle";
1008
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Diamond"] = 3] = "Diamond";
1009
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["OpenArrow"] = 4] = "OpenArrow";
1010
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["ClosedArrow"] = 5] = "ClosedArrow";
1011
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Butt"] = 6] = "Butt";
1012
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["ROpenArrow"] = 7] = "ROpenArrow";
1013
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["RClosedArrow"] = 8] = "RClosedArrow";
1014
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Slash"] = 9] = "Slash";
1015
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Unknown"] = 10] = "Unknown";
1016
+ return PdfAnnotationLineEnding2;
1017
+ })(PdfAnnotationLineEnding || {});
999
1018
  var PDF_FORM_FIELD_TYPE = /* @__PURE__ */ ((PDF_FORM_FIELD_TYPE2) => {
1000
1019
  PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["UNKNOWN"] = 0] = "UNKNOWN";
1001
1020
  PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["PUSHBUTTON"] = 1] = "PUSHBUTTON";
@@ -1257,28 +1276,54 @@ class PdfTaskHelper {
1257
1276
  return task;
1258
1277
  }
1259
1278
  }
1260
- function pdfAlphaColorToWebAlphaColor(c) {
1279
+ function pdfColorToWebColor(c) {
1261
1280
  const clamp = (n) => Math.max(0, Math.min(255, n));
1262
1281
  const toHex = (n) => clamp(n).toString(16).padStart(2, "0");
1263
- const color = `#${toHex(c.red)}${toHex(c.green)}${toHex(c.blue)}`;
1264
- const opacity = clamp(c.alpha) / 255;
1265
- return { color, opacity };
1282
+ return `#${toHex(c.red)}${toHex(c.green)}${toHex(c.blue)}`;
1266
1283
  }
1267
- function webAlphaColorToPdfAlphaColor({ color, opacity }) {
1284
+ function webColorToPdfColor(color) {
1268
1285
  if (/^#?[0-9a-f]{3}$/i.test(color)) {
1269
1286
  color = color.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i, "#$1$1$2$2$3$3").toLowerCase();
1270
1287
  }
1271
1288
  const [, r, g, b] = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color) ?? (() => {
1272
- throw new Error(`Invalid hex colour: “${color}”`);
1289
+ throw new Error(`Invalid hex colour: "${color}"`);
1273
1290
  })();
1274
- const clamp = (n, hi = 255) => Math.max(0, Math.min(hi, n));
1275
1291
  return {
1276
1292
  red: parseInt(r, 16),
1277
1293
  green: parseInt(g, 16),
1278
- blue: parseInt(b, 16),
1279
- alpha: clamp(Math.round(opacity * 255))
1294
+ blue: parseInt(b, 16)
1280
1295
  };
1281
1296
  }
1297
+ function pdfAlphaToWebOpacity(alpha) {
1298
+ const clamp = (n) => Math.max(0, Math.min(255, n));
1299
+ return clamp(alpha) / 255;
1300
+ }
1301
+ function webOpacityToPdfAlpha(opacity) {
1302
+ const clamp = (n, hi = 255) => Math.max(0, Math.min(hi, n));
1303
+ return clamp(Math.round(opacity * 255));
1304
+ }
1305
+ function extractPdfColor(c) {
1306
+ return { red: c.red, green: c.green, blue: c.blue };
1307
+ }
1308
+ function extractWebOpacity(c) {
1309
+ return pdfAlphaToWebOpacity(c.alpha);
1310
+ }
1311
+ function combinePdfColorWithAlpha(color, alpha) {
1312
+ return { ...color, alpha };
1313
+ }
1314
+ function combineWebColorWithOpacity(color, opacity) {
1315
+ return { color, opacity };
1316
+ }
1317
+ function pdfAlphaColorToWebAlphaColor(c) {
1318
+ const color = pdfColorToWebColor(extractPdfColor(c));
1319
+ const opacity = extractWebOpacity(c);
1320
+ return { color, opacity };
1321
+ }
1322
+ function webAlphaColorToPdfAlphaColor({ color, opacity }) {
1323
+ const pdfColor = webColorToPdfColor(color);
1324
+ const alpha = webOpacityToPdfAlpha(opacity);
1325
+ return combinePdfColorWithAlpha(pdfColor, alpha);
1326
+ }
1282
1327
  function pdfDateToDate(pdf) {
1283
1328
  if (!(pdf == null ? void 0 : pdf.startsWith("D:")) || pdf.length < 16) return;
1284
1329
  const y = +pdf.slice(2, 6);
@@ -1299,6 +1344,288 @@ function dateToPdfDate(date = /* @__PURE__ */ new Date()) {
1299
1344
  const SS = z(date.getUTCSeconds());
1300
1345
  return `D:${YYYY}${MM}${DD}${HH}${mm}${SS}`;
1301
1346
  }
1347
+ const MixedTextAlignment = Symbol("mixed");
1348
+ const TEXT_ALIGNMENT_INFOS = Object.freeze([
1349
+ { id: PdfTextAlignment.Left, label: "Left", css: "left" },
1350
+ { id: PdfTextAlignment.Center, label: "Center", css: "center" },
1351
+ { id: PdfTextAlignment.Right, label: "Right", css: "right" }
1352
+ ]);
1353
+ const enumToTextInfo = TEXT_ALIGNMENT_INFOS.reduce(
1354
+ (m, info) => {
1355
+ m[info.id] = info;
1356
+ return m;
1357
+ },
1358
+ {}
1359
+ );
1360
+ const cssToTextEnum = TEXT_ALIGNMENT_INFOS.reduce(
1361
+ (m, info) => {
1362
+ m[info.css] = info.id;
1363
+ return m;
1364
+ },
1365
+ {}
1366
+ );
1367
+ function getTextAlignmentInfo(alignment) {
1368
+ return enumToTextInfo[alignment] ?? enumToTextInfo[PdfTextAlignment.Left];
1369
+ }
1370
+ function textAlignmentToCss(alignment) {
1371
+ return getTextAlignmentInfo(alignment).css;
1372
+ }
1373
+ function cssToTextAlignment(value) {
1374
+ return cssToTextEnum[value];
1375
+ }
1376
+ function textAlignmentLabel(alignment) {
1377
+ return getTextAlignmentInfo(alignment).label;
1378
+ }
1379
+ function reduceTextAlignments(values) {
1380
+ if (!values.length) return PdfTextAlignment.Left;
1381
+ const first = values[0];
1382
+ return values.every((a) => a === first) ? first : MixedTextAlignment;
1383
+ }
1384
+ const textAlignmentSelectOptions = TEXT_ALIGNMENT_INFOS.map((info) => ({
1385
+ value: info.id,
1386
+ label: info.label
1387
+ }));
1388
+ var PdfStandardFontFamily = /* @__PURE__ */ ((PdfStandardFontFamily2) => {
1389
+ PdfStandardFontFamily2["Courier"] = "Courier";
1390
+ PdfStandardFontFamily2["Helvetica"] = "Helvetica";
1391
+ PdfStandardFontFamily2["Times"] = "Times";
1392
+ PdfStandardFontFamily2["Symbol"] = "Symbol";
1393
+ PdfStandardFontFamily2["ZapfDingbats"] = "ZapfDingbats";
1394
+ PdfStandardFontFamily2["Unknown"] = "Unknown";
1395
+ return PdfStandardFontFamily2;
1396
+ })(PdfStandardFontFamily || {});
1397
+ const DEFAULT_FALLBACK_FONT = PdfStandardFont.Helvetica;
1398
+ const MixedStandardFont = Symbol("mixed");
1399
+ const HELVETICA_DESC = {
1400
+ id: PdfStandardFont.Helvetica,
1401
+ family: "Helvetica",
1402
+ bold: false,
1403
+ italic: false,
1404
+ label: "Helvetica",
1405
+ css: "Helvetica, Arial, sans-serif"
1406
+ };
1407
+ const STANDARD_FONT_DESCRIPTORS = Object.freeze([
1408
+ {
1409
+ id: PdfStandardFont.Courier,
1410
+ family: "Courier",
1411
+ bold: false,
1412
+ italic: false,
1413
+ label: "Courier",
1414
+ css: "Courier, monospace"
1415
+ },
1416
+ {
1417
+ id: PdfStandardFont.Courier_Bold,
1418
+ family: "Courier",
1419
+ bold: true,
1420
+ italic: false,
1421
+ label: "Courier Bold",
1422
+ css: '"Courier-Bold", Courier, monospace'
1423
+ },
1424
+ {
1425
+ id: PdfStandardFont.Courier_BoldOblique,
1426
+ family: "Courier",
1427
+ bold: true,
1428
+ italic: true,
1429
+ label: "Courier Bold Oblique",
1430
+ css: '"Courier-BoldOblique", Courier, monospace'
1431
+ },
1432
+ {
1433
+ id: PdfStandardFont.Courier_Oblique,
1434
+ family: "Courier",
1435
+ bold: false,
1436
+ italic: true,
1437
+ label: "Courier Oblique",
1438
+ css: '"Courier-Oblique", Courier, monospace'
1439
+ },
1440
+ HELVETICA_DESC,
1441
+ {
1442
+ id: PdfStandardFont.Helvetica_Bold,
1443
+ family: "Helvetica",
1444
+ bold: true,
1445
+ italic: false,
1446
+ label: "Helvetica Bold",
1447
+ css: '"Helvetica-Bold", Arial, sans-serif'
1448
+ },
1449
+ {
1450
+ id: PdfStandardFont.Helvetica_BoldOblique,
1451
+ family: "Helvetica",
1452
+ bold: true,
1453
+ italic: true,
1454
+ label: "Helvetica Bold Oblique",
1455
+ css: '"Helvetica-BoldOblique", Arial, sans-serif'
1456
+ },
1457
+ {
1458
+ id: PdfStandardFont.Helvetica_Oblique,
1459
+ family: "Helvetica",
1460
+ bold: false,
1461
+ italic: true,
1462
+ label: "Helvetica Oblique",
1463
+ css: '"Helvetica-Oblique", Arial, sans-serif'
1464
+ },
1465
+ {
1466
+ id: PdfStandardFont.Times_Roman,
1467
+ family: "Times",
1468
+ bold: false,
1469
+ italic: false,
1470
+ label: "Times Roman",
1471
+ css: '"Times New Roman", Times, serif'
1472
+ },
1473
+ {
1474
+ id: PdfStandardFont.Times_Bold,
1475
+ family: "Times",
1476
+ bold: true,
1477
+ italic: false,
1478
+ label: "Times Bold",
1479
+ css: '"Times New Roman Bold", Times, serif'
1480
+ },
1481
+ {
1482
+ id: PdfStandardFont.Times_BoldItalic,
1483
+ family: "Times",
1484
+ bold: true,
1485
+ italic: true,
1486
+ label: "Times Bold Italic",
1487
+ css: '"Times New Roman Bold Italic", Times, serif'
1488
+ },
1489
+ {
1490
+ id: PdfStandardFont.Times_Italic,
1491
+ family: "Times",
1492
+ bold: false,
1493
+ italic: true,
1494
+ label: "Times Italic",
1495
+ css: '"Times New Roman Italic", Times, serif'
1496
+ },
1497
+ {
1498
+ id: PdfStandardFont.Symbol,
1499
+ family: "Symbol",
1500
+ bold: false,
1501
+ italic: false,
1502
+ label: "Symbol",
1503
+ css: "Symbol"
1504
+ },
1505
+ {
1506
+ id: PdfStandardFont.ZapfDingbats,
1507
+ family: "ZapfDingbats",
1508
+ bold: false,
1509
+ italic: false,
1510
+ label: "Zapf Dingbats",
1511
+ css: "ZapfDingbats"
1512
+ }
1513
+ ]);
1514
+ const idToDescriptor = STANDARD_FONT_DESCRIPTORS.reduce((m, d) => (m[d.id] = d, m), {});
1515
+ const familyStyleToId = /* @__PURE__ */ new Map();
1516
+ for (const d of STANDARD_FONT_DESCRIPTORS) {
1517
+ familyStyleToId.set(`${d.family}_${d.bold}_${d.italic}`, d.id);
1518
+ }
1519
+ function unknownDescriptor() {
1520
+ return HELVETICA_DESC;
1521
+ }
1522
+ function getStandardFontDescriptor(font) {
1523
+ return idToDescriptor[font] ?? unknownDescriptor();
1524
+ }
1525
+ function standardFontFamily(font) {
1526
+ return getStandardFontDescriptor(font).family;
1527
+ }
1528
+ function standardFontIsBold(font) {
1529
+ return getStandardFontDescriptor(font).bold;
1530
+ }
1531
+ function standardFontIsItalic(font) {
1532
+ return getStandardFontDescriptor(font).italic;
1533
+ }
1534
+ function makeStandardFont(family, { bold, italic }) {
1535
+ return familyStyleToId.get(`${family}_${bold}_${italic}`) ?? DEFAULT_FALLBACK_FONT;
1536
+ }
1537
+ function standardFontLabel(font) {
1538
+ return getStandardFontDescriptor(font).label;
1539
+ }
1540
+ function standardFontCss(font) {
1541
+ return getStandardFontDescriptor(font).css;
1542
+ }
1543
+ const standardFontFamilySelectOptions = Object.values(PdfStandardFontFamily).filter(
1544
+ (f) => f !== "Unknown"
1545
+ /* Unknown */
1546
+ ).map((family) => ({ value: family, label: family }));
1547
+ function reduceStandardFonts(fonts) {
1548
+ if (!fonts.length) return PdfStandardFont.Unknown;
1549
+ const first = fonts[0];
1550
+ return fonts.every((f) => f === first) ? first : MixedStandardFont;
1551
+ }
1552
+ const STANDARD_FONT_FAMILIES = [
1553
+ ...new Set(STANDARD_FONT_DESCRIPTORS.map((d) => d.family))
1554
+ ];
1555
+ function standardFontFamilyLabel(fam) {
1556
+ switch (fam) {
1557
+ case "Courier":
1558
+ return "Courier";
1559
+ case "Helvetica":
1560
+ return "Helvetica";
1561
+ case "Times":
1562
+ return "Times";
1563
+ case "Symbol":
1564
+ return "Symbol";
1565
+ case "ZapfDingbats":
1566
+ return "ZapfDingbats";
1567
+ /* fallback */
1568
+ default:
1569
+ return "Helvetica";
1570
+ }
1571
+ }
1572
+ const MixedBlendMode = Symbol("mixed");
1573
+ const BLEND_MODE_INFOS = Object.freeze([
1574
+ { id: PdfBlendMode.Normal, label: "Normal", css: "normal" },
1575
+ { id: PdfBlendMode.Multiply, label: "Multiply", css: "multiply" },
1576
+ { id: PdfBlendMode.Screen, label: "Screen", css: "screen" },
1577
+ { id: PdfBlendMode.Overlay, label: "Overlay", css: "overlay" },
1578
+ { id: PdfBlendMode.Darken, label: "Darken", css: "darken" },
1579
+ { id: PdfBlendMode.Lighten, label: "Lighten", css: "lighten" },
1580
+ { id: PdfBlendMode.ColorDodge, label: "Color Dodge", css: "color-dodge" },
1581
+ { id: PdfBlendMode.ColorBurn, label: "Color Burn", css: "color-burn" },
1582
+ { id: PdfBlendMode.HardLight, label: "Hard Light", css: "hard-light" },
1583
+ { id: PdfBlendMode.SoftLight, label: "Soft Light", css: "soft-light" },
1584
+ { id: PdfBlendMode.Difference, label: "Difference", css: "difference" },
1585
+ { id: PdfBlendMode.Exclusion, label: "Exclusion", css: "exclusion" },
1586
+ { id: PdfBlendMode.Hue, label: "Hue", css: "hue" },
1587
+ { id: PdfBlendMode.Saturation, label: "Saturation", css: "saturation" },
1588
+ { id: PdfBlendMode.Color, label: "Color", css: "color" },
1589
+ { id: PdfBlendMode.Luminosity, label: "Luminosity", css: "luminosity" }
1590
+ ]);
1591
+ const enumToInfo = BLEND_MODE_INFOS.reduce(
1592
+ (m, info) => {
1593
+ m[info.id] = info;
1594
+ return m;
1595
+ },
1596
+ {}
1597
+ );
1598
+ const cssToEnum = BLEND_MODE_INFOS.reduce(
1599
+ (m, info) => {
1600
+ m[info.css] = info.id;
1601
+ return m;
1602
+ },
1603
+ {}
1604
+ );
1605
+ function getBlendModeInfo(mode) {
1606
+ return enumToInfo[mode] ?? enumToInfo[PdfBlendMode.Normal];
1607
+ }
1608
+ function blendModeToCss(mode) {
1609
+ return getBlendModeInfo(mode).css;
1610
+ }
1611
+ function cssToBlendMode(value) {
1612
+ return cssToEnum[value];
1613
+ }
1614
+ function blendModeLabel(mode) {
1615
+ return getBlendModeInfo(mode).label;
1616
+ }
1617
+ function reduceBlendModes(modes) {
1618
+ if (!modes.length) return PdfBlendMode.Normal;
1619
+ const first = modes[0];
1620
+ return modes.every((m) => m === first) ? first : MixedBlendMode;
1621
+ }
1622
+ const blendModeSelectOptions = BLEND_MODE_INFOS.map((info) => ({
1623
+ value: info.id,
1624
+ label: info.label
1625
+ }));
1626
+ function uiBlendModeDisplay(value) {
1627
+ return value === MixedBlendMode ? "(mixed)" : blendModeLabel(value);
1628
+ }
1302
1629
  function ignore() {
1303
1630
  }
1304
1631
  export {
@@ -1309,6 +1636,8 @@ export {
1309
1636
  LogLevel,
1310
1637
  MatchFlag,
1311
1638
  MixedBlendMode,
1639
+ MixedStandardFont,
1640
+ MixedTextAlignment,
1312
1641
  NoopLogger,
1313
1642
  PDF_FORM_FIELD_FLAG,
1314
1643
  PDF_FORM_FIELD_TYPE,
@@ -1317,6 +1646,7 @@ export {
1317
1646
  PdfAnnotationColorType,
1318
1647
  PdfAnnotationFlagName,
1319
1648
  PdfAnnotationFlags,
1649
+ PdfAnnotationLineEnding,
1320
1650
  PdfAnnotationObjectStatus,
1321
1651
  PdfAnnotationState,
1322
1652
  PdfAnnotationStateModel,
@@ -1335,14 +1665,19 @@ export {
1335
1665
  PdfPermission,
1336
1666
  PdfSegmentObjectType,
1337
1667
  PdfSoftHyphenMarker,
1668
+ PdfStandardFont,
1669
+ PdfStandardFontFamily,
1338
1670
  PdfTaskHelper,
1671
+ PdfTextAlignment,
1339
1672
  PdfUnwantedTextMarkers,
1340
1673
  PdfUnwantedTextRegex,
1674
+ PdfVerticalAlignment,
1341
1675
  PdfWordJoiner,
1342
1676
  PdfZeroWidthSpace,
1343
1677
  PdfZoomMode,
1344
1678
  PerfLogger,
1345
1679
  Rotation,
1680
+ STANDARD_FONT_FAMILIES,
1346
1681
  Task,
1347
1682
  TaskAbortedError,
1348
1683
  TaskRejectedError,
@@ -1353,28 +1688,54 @@ export {
1353
1688
  boundingRect,
1354
1689
  calculateAngle,
1355
1690
  calculateDegree,
1691
+ combinePdfColorWithAlpha,
1692
+ combineWebColorWithOpacity,
1356
1693
  compareSearchTarget,
1357
1694
  cssToBlendMode,
1695
+ cssToTextAlignment,
1358
1696
  dateToPdfDate,
1697
+ expandRect,
1698
+ extractPdfColor,
1699
+ extractWebOpacity,
1359
1700
  flagsToNames,
1360
1701
  getBlendModeInfo,
1702
+ getStandardFontDescriptor,
1703
+ getTextAlignmentInfo,
1361
1704
  ignore,
1362
1705
  makeMatrix,
1706
+ makeStandardFont,
1363
1707
  namesToFlags,
1364
1708
  pdfAlphaColorToWebAlphaColor,
1709
+ pdfAlphaToWebOpacity,
1710
+ pdfColorToWebColor,
1365
1711
  pdfDateToDate,
1366
1712
  quadToRect,
1713
+ rectEquals,
1714
+ rectFromPoints,
1367
1715
  rectToQuad,
1368
1716
  reduceBlendModes,
1717
+ reduceStandardFonts,
1718
+ reduceTextAlignments,
1369
1719
  restoreOffset,
1370
1720
  restorePosition,
1371
1721
  restoreRect,
1722
+ rotateAndTranslatePoint,
1372
1723
  rotatePosition,
1373
1724
  rotateRect,
1374
1725
  scalePosition,
1375
1726
  scaleRect,
1727
+ standardFontCss,
1728
+ standardFontFamily,
1729
+ standardFontFamilyLabel,
1730
+ standardFontFamilySelectOptions,
1731
+ standardFontIsBold,
1732
+ standardFontIsItalic,
1733
+ standardFontLabel,
1376
1734
  stripPdfUnwantedMarkers,
1377
1735
  swap,
1736
+ textAlignmentLabel,
1737
+ textAlignmentSelectOptions,
1738
+ textAlignmentToCss,
1378
1739
  toIntPos,
1379
1740
  toIntRect,
1380
1741
  toIntSize,
@@ -1383,6 +1744,8 @@ export {
1383
1744
  transformSize,
1384
1745
  uiBlendModeDisplay,
1385
1746
  unionFlags,
1386
- webAlphaColorToPdfAlphaColor
1747
+ webAlphaColorToPdfAlphaColor,
1748
+ webColorToPdfColor,
1749
+ webOpacityToPdfAlpha
1387
1750
  };
1388
1751
  //# sourceMappingURL=index.js.map