@embedpdf/models 1.0.13 → 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/color.d.ts +42 -1
- package/dist/color.test.d.ts +1 -0
- package/dist/helpers/blend-mode.d.ts +53 -0
- package/dist/helpers/font.d.ts +63 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/text-alignment.d.ts +21 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +379 -70
- package/dist/index.js.map +1 -1
- package/dist/pdf.d.ts +84 -62
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -768,6 +768,36 @@ var PdfZoomMode = /* @__PURE__ */ ((PdfZoomMode2) => {
|
|
|
768
768
|
PdfZoomMode2[PdfZoomMode2["FitRectangle"] = 5] = "FitRectangle";
|
|
769
769
|
return PdfZoomMode2;
|
|
770
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 || {});
|
|
771
801
|
var PdfBlendMode = /* @__PURE__ */ ((PdfBlendMode2) => {
|
|
772
802
|
PdfBlendMode2[PdfBlendMode2["Normal"] = 0] = "Normal";
|
|
773
803
|
PdfBlendMode2[PdfBlendMode2["Multiply"] = 1] = "Multiply";
|
|
@@ -787,66 +817,6 @@ var PdfBlendMode = /* @__PURE__ */ ((PdfBlendMode2) => {
|
|
|
787
817
|
PdfBlendMode2[PdfBlendMode2["Luminosity"] = 15] = "Luminosity";
|
|
788
818
|
return PdfBlendMode2;
|
|
789
819
|
})(PdfBlendMode || {});
|
|
790
|
-
const MixedBlendMode = Symbol("mixed");
|
|
791
|
-
const BLEND_MODE_INFOS = Object.freeze([
|
|
792
|
-
{ id: 0, label: "Normal", css: "normal" },
|
|
793
|
-
{ id: 1, label: "Multiply", css: "multiply" },
|
|
794
|
-
{ id: 2, label: "Screen", css: "screen" },
|
|
795
|
-
{ id: 3, label: "Overlay", css: "overlay" },
|
|
796
|
-
{ id: 4, label: "Darken", css: "darken" },
|
|
797
|
-
{ id: 5, label: "Lighten", css: "lighten" },
|
|
798
|
-
{ id: 6, label: "Color Dodge", css: "color-dodge" },
|
|
799
|
-
{ id: 7, label: "Color Burn", css: "color-burn" },
|
|
800
|
-
{ id: 8, label: "Hard Light", css: "hard-light" },
|
|
801
|
-
{ id: 9, label: "Soft Light", css: "soft-light" },
|
|
802
|
-
{ id: 10, label: "Difference", css: "difference" },
|
|
803
|
-
{ id: 11, label: "Exclusion", css: "exclusion" },
|
|
804
|
-
{ id: 12, label: "Hue", css: "hue" },
|
|
805
|
-
{ id: 13, label: "Saturation", css: "saturation" },
|
|
806
|
-
{ id: 14, label: "Color", css: "color" },
|
|
807
|
-
{ id: 15, label: "Luminosity", css: "luminosity" }
|
|
808
|
-
]);
|
|
809
|
-
const enumToInfo = BLEND_MODE_INFOS.reduce(
|
|
810
|
-
(m, info) => {
|
|
811
|
-
m[info.id] = info;
|
|
812
|
-
return m;
|
|
813
|
-
},
|
|
814
|
-
{}
|
|
815
|
-
);
|
|
816
|
-
const cssToEnum = BLEND_MODE_INFOS.reduce(
|
|
817
|
-
(m, info) => {
|
|
818
|
-
m[info.css] = info.id;
|
|
819
|
-
return m;
|
|
820
|
-
},
|
|
821
|
-
{}
|
|
822
|
-
);
|
|
823
|
-
function getBlendModeInfo(mode) {
|
|
824
|
-
return enumToInfo[mode] ?? enumToInfo[
|
|
825
|
-
0
|
|
826
|
-
/* Normal */
|
|
827
|
-
];
|
|
828
|
-
}
|
|
829
|
-
function blendModeToCss(mode) {
|
|
830
|
-
return getBlendModeInfo(mode).css;
|
|
831
|
-
}
|
|
832
|
-
function cssToBlendMode(value) {
|
|
833
|
-
return cssToEnum[value];
|
|
834
|
-
}
|
|
835
|
-
function blendModeLabel(mode) {
|
|
836
|
-
return getBlendModeInfo(mode).label;
|
|
837
|
-
}
|
|
838
|
-
function reduceBlendModes(modes) {
|
|
839
|
-
if (!modes.length) return 0;
|
|
840
|
-
const first = modes[0];
|
|
841
|
-
return modes.every((m) => m === first) ? first : MixedBlendMode;
|
|
842
|
-
}
|
|
843
|
-
const blendModeSelectOptions = BLEND_MODE_INFOS.map((info) => ({
|
|
844
|
-
value: info.id,
|
|
845
|
-
label: info.label
|
|
846
|
-
}));
|
|
847
|
-
function uiBlendModeDisplay(value) {
|
|
848
|
-
return value === MixedBlendMode ? "(mixed)" : blendModeLabel(value);
|
|
849
|
-
}
|
|
850
820
|
var PdfActionType = /* @__PURE__ */ ((PdfActionType2) => {
|
|
851
821
|
PdfActionType2[PdfActionType2["Unsupported"] = 0] = "Unsupported";
|
|
852
822
|
PdfActionType2[PdfActionType2["Goto"] = 1] = "Goto";
|
|
@@ -1306,28 +1276,54 @@ class PdfTaskHelper {
|
|
|
1306
1276
|
return task;
|
|
1307
1277
|
}
|
|
1308
1278
|
}
|
|
1309
|
-
function
|
|
1279
|
+
function pdfColorToWebColor(c) {
|
|
1310
1280
|
const clamp = (n) => Math.max(0, Math.min(255, n));
|
|
1311
1281
|
const toHex = (n) => clamp(n).toString(16).padStart(2, "0");
|
|
1312
|
-
|
|
1313
|
-
const opacity = clamp(c.alpha) / 255;
|
|
1314
|
-
return { color, opacity };
|
|
1282
|
+
return `#${toHex(c.red)}${toHex(c.green)}${toHex(c.blue)}`;
|
|
1315
1283
|
}
|
|
1316
|
-
function
|
|
1284
|
+
function webColorToPdfColor(color) {
|
|
1317
1285
|
if (/^#?[0-9a-f]{3}$/i.test(color)) {
|
|
1318
1286
|
color = color.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i, "#$1$1$2$2$3$3").toLowerCase();
|
|
1319
1287
|
}
|
|
1320
1288
|
const [, r, g, b] = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color) ?? (() => {
|
|
1321
|
-
throw new Error(`Invalid hex colour:
|
|
1289
|
+
throw new Error(`Invalid hex colour: "${color}"`);
|
|
1322
1290
|
})();
|
|
1323
|
-
const clamp = (n, hi = 255) => Math.max(0, Math.min(hi, n));
|
|
1324
1291
|
return {
|
|
1325
1292
|
red: parseInt(r, 16),
|
|
1326
1293
|
green: parseInt(g, 16),
|
|
1327
|
-
blue: parseInt(b, 16)
|
|
1328
|
-
alpha: clamp(Math.round(opacity * 255))
|
|
1294
|
+
blue: parseInt(b, 16)
|
|
1329
1295
|
};
|
|
1330
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
|
+
}
|
|
1331
1327
|
function pdfDateToDate(pdf) {
|
|
1332
1328
|
if (!(pdf == null ? void 0 : pdf.startsWith("D:")) || pdf.length < 16) return;
|
|
1333
1329
|
const y = +pdf.slice(2, 6);
|
|
@@ -1348,6 +1344,288 @@ function dateToPdfDate(date = /* @__PURE__ */ new Date()) {
|
|
|
1348
1344
|
const SS = z(date.getUTCSeconds());
|
|
1349
1345
|
return `D:${YYYY}${MM}${DD}${HH}${mm}${SS}`;
|
|
1350
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
|
+
}
|
|
1351
1629
|
function ignore() {
|
|
1352
1630
|
}
|
|
1353
1631
|
export {
|
|
@@ -1358,6 +1636,8 @@ export {
|
|
|
1358
1636
|
LogLevel,
|
|
1359
1637
|
MatchFlag,
|
|
1360
1638
|
MixedBlendMode,
|
|
1639
|
+
MixedStandardFont,
|
|
1640
|
+
MixedTextAlignment,
|
|
1361
1641
|
NoopLogger,
|
|
1362
1642
|
PDF_FORM_FIELD_FLAG,
|
|
1363
1643
|
PDF_FORM_FIELD_TYPE,
|
|
@@ -1385,14 +1665,19 @@ export {
|
|
|
1385
1665
|
PdfPermission,
|
|
1386
1666
|
PdfSegmentObjectType,
|
|
1387
1667
|
PdfSoftHyphenMarker,
|
|
1668
|
+
PdfStandardFont,
|
|
1669
|
+
PdfStandardFontFamily,
|
|
1388
1670
|
PdfTaskHelper,
|
|
1671
|
+
PdfTextAlignment,
|
|
1389
1672
|
PdfUnwantedTextMarkers,
|
|
1390
1673
|
PdfUnwantedTextRegex,
|
|
1674
|
+
PdfVerticalAlignment,
|
|
1391
1675
|
PdfWordJoiner,
|
|
1392
1676
|
PdfZeroWidthSpace,
|
|
1393
1677
|
PdfZoomMode,
|
|
1394
1678
|
PerfLogger,
|
|
1395
1679
|
Rotation,
|
|
1680
|
+
STANDARD_FONT_FAMILIES,
|
|
1396
1681
|
Task,
|
|
1397
1682
|
TaskAbortedError,
|
|
1398
1683
|
TaskRejectedError,
|
|
@@ -1403,22 +1688,34 @@ export {
|
|
|
1403
1688
|
boundingRect,
|
|
1404
1689
|
calculateAngle,
|
|
1405
1690
|
calculateDegree,
|
|
1691
|
+
combinePdfColorWithAlpha,
|
|
1692
|
+
combineWebColorWithOpacity,
|
|
1406
1693
|
compareSearchTarget,
|
|
1407
1694
|
cssToBlendMode,
|
|
1695
|
+
cssToTextAlignment,
|
|
1408
1696
|
dateToPdfDate,
|
|
1409
1697
|
expandRect,
|
|
1698
|
+
extractPdfColor,
|
|
1699
|
+
extractWebOpacity,
|
|
1410
1700
|
flagsToNames,
|
|
1411
1701
|
getBlendModeInfo,
|
|
1702
|
+
getStandardFontDescriptor,
|
|
1703
|
+
getTextAlignmentInfo,
|
|
1412
1704
|
ignore,
|
|
1413
1705
|
makeMatrix,
|
|
1706
|
+
makeStandardFont,
|
|
1414
1707
|
namesToFlags,
|
|
1415
1708
|
pdfAlphaColorToWebAlphaColor,
|
|
1709
|
+
pdfAlphaToWebOpacity,
|
|
1710
|
+
pdfColorToWebColor,
|
|
1416
1711
|
pdfDateToDate,
|
|
1417
1712
|
quadToRect,
|
|
1418
1713
|
rectEquals,
|
|
1419
1714
|
rectFromPoints,
|
|
1420
1715
|
rectToQuad,
|
|
1421
1716
|
reduceBlendModes,
|
|
1717
|
+
reduceStandardFonts,
|
|
1718
|
+
reduceTextAlignments,
|
|
1422
1719
|
restoreOffset,
|
|
1423
1720
|
restorePosition,
|
|
1424
1721
|
restoreRect,
|
|
@@ -1427,8 +1724,18 @@ export {
|
|
|
1427
1724
|
rotateRect,
|
|
1428
1725
|
scalePosition,
|
|
1429
1726
|
scaleRect,
|
|
1727
|
+
standardFontCss,
|
|
1728
|
+
standardFontFamily,
|
|
1729
|
+
standardFontFamilyLabel,
|
|
1730
|
+
standardFontFamilySelectOptions,
|
|
1731
|
+
standardFontIsBold,
|
|
1732
|
+
standardFontIsItalic,
|
|
1733
|
+
standardFontLabel,
|
|
1430
1734
|
stripPdfUnwantedMarkers,
|
|
1431
1735
|
swap,
|
|
1736
|
+
textAlignmentLabel,
|
|
1737
|
+
textAlignmentSelectOptions,
|
|
1738
|
+
textAlignmentToCss,
|
|
1432
1739
|
toIntPos,
|
|
1433
1740
|
toIntRect,
|
|
1434
1741
|
toIntSize,
|
|
@@ -1437,6 +1744,8 @@ export {
|
|
|
1437
1744
|
transformSize,
|
|
1438
1745
|
uiBlendModeDisplay,
|
|
1439
1746
|
unionFlags,
|
|
1440
|
-
webAlphaColorToPdfAlphaColor
|
|
1747
|
+
webAlphaColorToPdfAlphaColor,
|
|
1748
|
+
webColorToPdfColor,
|
|
1749
|
+
webOpacityToPdfAlpha
|
|
1441
1750
|
};
|
|
1442
1751
|
//# sourceMappingURL=index.js.map
|