@pdfme/schemas 3.2.3 → 3.3.0-dev.1

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.
@@ -5,7 +5,8 @@ const constants_js_1 = require("../constants.js");
5
5
  const DEFAULT_LINE_COLOR = '#000000';
6
6
  const lineSchema = {
7
7
  pdf: (arg) => {
8
- const { page, schema } = arg;
8
+ const { page, schema, options } = arg;
9
+ const { colorType } = options;
9
10
  const pageHeight = page.getHeight();
10
11
  const { width, height, rotate, position: { x, y }, opacity, } = (0, utils_js_1.convertForPdfLayoutProps)({ schema, pageHeight, applyRotateTranslate: false });
11
12
  const pivot = { x: x + width / 2, y: y + height / 2 };
@@ -13,7 +14,7 @@ const lineSchema = {
13
14
  start: (0, utils_js_1.rotatePoint)({ x, y: y + height / 2 }, pivot, rotate.angle),
14
15
  end: (0, utils_js_1.rotatePoint)({ x: x + width, y: y + height / 2 }, pivot, rotate.angle),
15
16
  thickness: height,
16
- color: (0, utils_js_1.hex2RgbColor)(schema.color ?? DEFAULT_LINE_COLOR),
17
+ color: (0, utils_js_1.hex2PrintingColor)(schema.color ?? DEFAULT_LINE_COLOR, colorType),
17
18
  opacity: opacity,
18
19
  });
19
20
  },
@@ -1 +1 @@
1
- {"version":3,"file":"line.js","sourceRoot":"","sources":["../../../../src/shapes/line.ts"],"names":[],"mappings":";;AACA,0CAAkF;AAClF,kDAAoD;AAEpD,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAMrC,MAAM,UAAU,GAAuB;IACrC,GAAG,EAAE,CAAC,GAA+B,EAAE,EAAE;QACvC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;QAC7B,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACpC,MAAM,EACJ,KAAK,EACL,MAAM,EACN,MAAM,EACN,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAClB,OAAO,GACR,GAAG,IAAA,mCA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AK,EAAE;oBACL;wBACE,OAAO,EAAE,gCAAiB;wBAC1B,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC;qBAChC;iBACF;aACF;SACF,CAAC;QACF,YAAY,EAAE,EAAE;QAChB,aAAa,EAAE;YACb,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;YACxB,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,kBAAkB;SAC1B;KACF;CACF,CAAC;AACF,kBAAe,UAAU,CAAC"}
@@ -21,7 +21,8 @@ const shape = {
21
21
  rootElement.appendChild(div);
22
22
  },
23
23
  pdf: (arg) => {
24
- const { schema, page } = arg;
24
+ const { schema, page, options } = arg;
25
+ const { colorType } = options;
25
26
  const pageHeight = page.getHeight();
26
27
  const cArg = { schema, pageHeight };
27
28
  const { position, width, height, rotate, opacity } = (0, utils_js_1.convertForPdfLayoutProps)(cArg);
@@ -30,8 +31,8 @@ const shape = {
30
31
  const drawOptions = {
31
32
  rotate,
32
33
  borderWidth,
33
- borderColor: (0, utils_js_1.hex2RgbColor)(schema.borderColor),
34
- color: (0, utils_js_1.hex2RgbColor)(schema.color),
34
+ borderColor: (0, utils_js_1.hex2PrintingColor)(schema.borderColor, colorType),
35
+ color: (0, utils_js_1.hex2PrintingColor)(schema.color, colorType),
35
36
  opacity,
36
37
  borderOpacity: opacity,
37
38
  };
@@ -1 +1 @@
1
- {"version":3,"file":"rectAndEllipse.js","sourceRoot":"","sources":["../../../../src/shapes/rectAndEllipse.ts"],"names":[],"mappings":";;;AAAA,0CAAsD;AACtD,kDAAoD;AACpD,0CAAqE;AASrE,MAAM,KAAK,GAAkB;IAC3B,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;QACV,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE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AE,CAAC;YACT,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,CAAC;YACd,WAAW,EAAE,SAAS;YACtB,KAAK,EAAE,SAAS;YAChB,QAAQ,EAAE,IAAI;SACf;KACF;CACF,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,IAA6B,EAAE,EAAE,CAAC,CAAC;IAC7D,GAAG,KAAK,CAAC,SAAS;IAClB,aAAa,EAAE,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,EAAE;CAC1D,CAAC,CAAC;AAEU,QAAA,SAAS,GAAG,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;AAErE,QAAA,OAAO,GAAG,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,kBAAkB,CAAC,SAAS,CAAC,EAAE,CAAC"}
@@ -23,11 +23,11 @@ const embedAndGetFontObj = async (arg) => {
23
23
  _cache.set(pdfDoc, fontObj);
24
24
  return fontObj;
25
25
  };
26
- const getFontProp = async ({ value, font, schema, _cache, }) => {
26
+ const getFontProp = async ({ value, font, schema, colorType, _cache, }) => {
27
27
  const fontSize = schema.dynamicFontSize
28
28
  ? await (0, helper_js_1.calculateDynamicFontSize)({ textSchema: schema, font, value, _cache })
29
29
  : schema.fontSize ?? constants_js_1.DEFAULT_FONT_SIZE;
30
- const color = (0, utils_js_1.hex2RgbColor)(schema.fontColor || constants_js_1.DEFAULT_FONT_COLOR);
30
+ const color = (0, utils_js_1.hex2PrintingColor)(schema.fontColor || constants_js_1.DEFAULT_FONT_COLOR, colorType);
31
31
  return {
32
32
  alignment: schema.alignment ?? constants_js_1.DEFAULT_ALIGNMENT,
33
33
  verticalAlignment: schema.verticalAlignment ?? constants_js_1.DEFAULT_VERTICAL_ALIGNMENT,
@@ -41,11 +41,11 @@ const pdfRender = async (arg) => {
41
41
  const { value, pdfDoc, pdfLib, page, options, schema, _cache } = arg;
42
42
  if (!value)
43
43
  return;
44
- const { font = (0, common_1.getDefaultFont)() } = options;
44
+ const { font = (0, common_1.getDefaultFont)(), colorType } = options;
45
45
  const [pdfFontObj, fontKitFont, fontProp] = await Promise.all([
46
46
  embedAndGetFontObj({ pdfDoc, font, _cache }),
47
47
  (0, helper_js_1.getFontKitFont)(schema, font, _cache),
48
- getFontProp({ value, font, schema, _cache }),
48
+ getFontProp({ value, font, schema, _cache, colorType }),
49
49
  ]);
50
50
  const { fontSize, color, alignment, verticalAlignment, lineHeight, characterSpacing } = fontProp;
51
51
  const fontName = (schema.fontName ? schema.fontName : (0, common_1.getFallbackFontName)(font));
@@ -53,7 +53,7 @@ const pdfRender = async (arg) => {
53
53
  const pageHeight = page.getHeight();
54
54
  const { width, height, rotate, position: { x, y }, opacity, } = (0, utils_js_1.convertForPdfLayoutProps)({ schema, pageHeight, applyRotateTranslate: false });
55
55
  if (schema.backgroundColor) {
56
- const color = (0, utils_js_1.hex2RgbColor)(schema.backgroundColor);
56
+ const color = (0, utils_js_1.hex2PrintingColor)(schema.backgroundColor, colorType);
57
57
  page.drawRectangle({ x, y, width, height, rotate, color });
58
58
  }
59
59
  page.pushOperators(pdfLib.setCharacterSpacing(characterSpacing ?? constants_js_1.DEFAULT_CHARACTER_SPACING));
@@ -1 +1 @@
1
- {"version":3,"file":"pdfRender.js","sourceRoot":"","sources":["../../../../src/text/pdfRender.ts"],"names":[],"mappings":";;;AAEA,0CAAiG;AACjG,iDAUwB;AACxB,2CAOqB;AACrB,0CAAkF;AAElF,MAAM,kBAAkB,GAAG,KAAK,EAAE,GAIjC,EAAE,EAAE;IACH,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IACrC,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QACtB,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,CAA+B,CAAC;KACzD;IAED,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,GAAG,CAClC,MAAM,CAAC,M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I,SAAS,KAAK,QAAQ,EAAE;YAC1B,KAAK,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;SAClC;aAAM,IAAI,SAAS,KAAK,OAAO,EAAE;YAChC,KAAK,IAAI,KAAK,GAAG,SAAS,CAAC;SAC5B;QAED,IAAI,KAAK,GAAG,UAAU,GAAG,IAAA,cAAK,EAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,UAAU,CAAC;QAEzE,IAAI,MAAM,CAAC,KAAK,KAAK,CAAC,EAAE;YACtB,iGAAiG;YACjG,qGAAqG;YACrG,MAAM,YAAY,GAAG,IAAA,sBAAW,EAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;YACnF,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC;YACvB,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC;SACxB;QAED,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;YAClB,CAAC,EAAE,KAAK;YACR,CAAC,EAAE,KAAK;YACR,MAAM;YACN,IAAI,EAAE,QAAQ;YACd,KAAK;YACL,UAAU,EAAE,UAAU,GAAG,QAAQ;YACjC,IAAI,EAAE,YAAY;YAClB,OAAO;SACR,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AApGW,QAAA,SAAS,aAoGpB"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createErrorElm = exports.readFile = exports.hex2RgbColor = exports.isEditable = exports.addAlphaToHex = exports.rotatePoint = exports.convertForPdfLayoutProps = void 0;
3
+ exports.createErrorElm = exports.readFile = exports.hex2PrintingColor = exports.hex2CmykColor = exports.hex2RgbColor = exports.isEditable = exports.addAlphaToHex = exports.rotatePoint = exports.convertForPdfLayoutProps = void 0;
4
4
  const pdf_lib_1 = require("@pdfme/pdf-lib");
5
5
  const common_1 = require("@pdfme/common");
6
6
  const convertForPdfLayoutProps = ({ schema, pageHeight, applyRotateTranslate = true, }) => {
@@ -80,6 +80,42 @@ const hex2RgbColor = (hexString) => {
80
80
  return undefined;
81
81
  };
82
82
  exports.hex2RgbColor = hex2RgbColor;
83
+ const hex2CmykColor = (hexString) => {
84
+ if (hexString) {
85
+ const isValid = (0, common_1.isHexValid)(hexString);
86
+ if (!isValid) {
87
+ throw new Error(`Invalid hex color value ${hexString}`);
88
+ }
89
+ // Remove the # if it's present
90
+ hexString = hexString.replace('#', '');
91
+ // Extract the hexadecimal color code and the opacity
92
+ const hexColor = hexString.substring(0, 6);
93
+ const opacityColor = hexString.substring(6, 8);
94
+ const opacity = opacityColor ? parseInt(opacityColor, 16) / 255 : 1;
95
+ // Convert the hex values to decimal
96
+ let r = parseInt(hexColor.substring(0, 2), 16) / 255;
97
+ let g = parseInt(hexColor.substring(2, 4), 16) / 255;
98
+ let b = parseInt(hexColor.substring(4, 6), 16) / 255;
99
+ // Apply the opacity
100
+ r = r * opacity + (1 - opacity);
101
+ g = g * opacity + (1 - opacity);
102
+ b = b * opacity + (1 - opacity);
103
+ // Calculate the CMYK values
104
+ const k = 1 - Math.max(r, g, b);
105
+ const c = r === 0 ? 0 : (1 - r - k) / (1 - k);
106
+ const m = g === 0 ? 0 : (1 - g - k) / (1 - k);
107
+ const y = b === 0 ? 0 : (1 - b - k) / (1 - k);
108
+ return (0, pdf_lib_1.cmyk)(c, m, y, k);
109
+ }
110
+ return undefined;
111
+ };
112
+ exports.hex2CmykColor = hex2CmykColor;
113
+ const hex2PrintingColor = (hexString, colorType) => {
114
+ return colorType?.toLocaleLowerCase() == 'cmyk'
115
+ ? (0, exports.hex2CmykColor)(hexString)
116
+ : (0, exports.hex2RgbColor)(hexString);
117
+ };
118
+ exports.hex2PrintingColor = hex2PrintingColor;
83
119
  const readFile = (input) => new Promise((resolve, reject) => {
84
120
  const fileReader = new FileReader();
85
121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AC,oCAAoC,CAAC,CAAC,CAAC;KACzD;AACH,CAAC,CAAC,CAAC;AA1BQ,QAAA,QAAQ,YA0BhB;AAEE,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,MAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,cAAc,GAAmB;QACrC,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;QACxB,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;KACf,CAAC;IACF,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IAE/C,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,SAAS,GAAmB;QAChC,KAAK,EAAE,OAAO;QACd,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,SAAS;QAClB,QAAQ,EAAE,MAAM;QAChB,UAAU,EAAE,MAAM;QAClB,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,yBAAyB;KACtC,CAAC;IACF,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAErC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;IAC3B,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAE5B,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AA3BW,QAAA,cAAc,kBA2BzB"}
@@ -1,9 +1,10 @@
1
- import { rotatePoint, convertForPdfLayoutProps, hex2RgbColor } from '../utils.js';
1
+ import { rotatePoint, convertForPdfLayoutProps, hex2PrintingColor } from '../utils.js';
2
2
  import { HEX_COLOR_PATTERN } from '../constants.js';
3
3
  const DEFAULT_LINE_COLOR = '#000000';
4
4
  const lineSchema = {
5
5
  pdf: (arg) => {
6
- const { page, schema } = arg;
6
+ const { page, schema, options } = arg;
7
+ const { colorType } = options;
7
8
  const pageHeight = page.getHeight();
8
9
  const { width, height, rotate, position: { x, y }, opacity, } = convertForPdfLayoutProps({ schema, pageHeight, applyRotateTranslate: false });
9
10
  const pivot = { x: x + width / 2, y: y + height / 2 };
@@ -11,7 +12,7 @@ const lineSchema = {
11
12
  start: rotatePoint({ x, y: y + height / 2 }, pivot, rotate.angle),
12
13
  end: rotatePoint({ x: x + width, y: y + height / 2 }, pivot, rotate.angle),
13
14
  thickness: height,
14
- color: hex2RgbColor(schema.color ?? DEFAULT_LINE_COLOR),
15
+ color: hex2PrintingColor(schema.color ?? DEFAULT_LINE_COLOR, colorType),
15
16
  opacity: opacity,
16
17
  });
17
18
  },
@@ -1 +1 @@
1
- {"version":3,"file":"line.js","sourceRoot":"","sources":["../../../../src/shapes/line.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAMrC,MAAM,UAAU,GAAuB;IACrC,GAAG,EAAE,CAAC,GAA+B,EAAE,EAAE;QACvC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;QAC7B,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACpC,MAAM,EACJ,KAAK,EACL,MAAM,EACN,MAAM,EACN,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAClB,OAAO,GACR,GAAG,wBAAwB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC,CAAC;QAClF,MAAM,KAAK,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC;QACtD,IAAI,CAAC,QAAQ,CAAC;YACZ,KAAK,EAAE,WAAW,C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,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;YACxB,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,kBAAkB;SAC1B;KACF;CACF,CAAC;AACF,eAAe,UAAU,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { mm2pt } from '@pdfme/common';
2
2
  import { HEX_COLOR_PATTERN } from '../constants.js';
3
- import { hex2RgbColor, convertForPdfLayoutProps } from '../utils.js';
3
+ import { hex2PrintingColor, convertForPdfLayoutProps } from '../utils.js';
4
4
  const shape = {
5
5
  ui: (arg) => {
6
6
  const { schema, rootElement } = arg;
@@ -18,7 +18,8 @@ const shape = {
18
18
  rootElement.appendChild(div);
19
19
  },
20
20
  pdf: (arg) => {
21
- const { schema, page } = arg;
21
+ const { schema, page, options } = arg;
22
+ const { colorType } = options;
22
23
  const pageHeight = page.getHeight();
23
24
  const cArg = { schema, pageHeight };
24
25
  const { position, width, height, rotate, opacity } = convertForPdfLayoutProps(cArg);
@@ -27,8 +28,8 @@ const shape = {
27
28
  const drawOptions = {
28
29
  rotate,
29
30
  borderWidth,
30
- borderColor: hex2RgbColor(schema.borderColor),
31
- color: hex2RgbColor(schema.color),
31
+ borderColor: hex2PrintingColor(schema.borderColor, colorType),
32
+ color: hex2PrintingColor(schema.color, colorType),
32
33
  opacity,
33
34
  borderOpacity: opacity,
34
35
  };
@@ -1 +1 @@
1
- {"version":3,"file":"rectAndEllipse.js","sourceRoot":"","sources":["../../../../src/shapes/rectAndEllipse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AASrE,MAAM,KAAK,GAAkB;IAC3B,EAAE,EAAE,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EAAE,WAAW;YACjB,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;YACxB,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,CAAC;YACd,WAAW,EAAE,SAAS;YACtB,KAAK,EAAE,SAAS;YAChB,QAAQ,EAAE,IAAI;SACf;KACF;CACF,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,IAA6B,EAAE,EAAE,CAAC,CAAC;IAC7D,GAAG,KAAK,CAAC,SAAS;IAClB,aAAa,EAAE,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,EAAE;CAC1D,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;AAElF,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,kBAAkB,CAAC,SAAS,CAAC,EAAE,CAAC"}
@@ -1,7 +1,7 @@
1
- import { getDefaultFont, getFallbackFontName, mm2pt } from '@pdfme/common';
1
+ import { getDefaultFont, getFallbackFontName, mm2pt, } from '@pdfme/common';
2
2
  import { VERTICAL_ALIGN_TOP, VERTICAL_ALIGN_MIDDLE, VERTICAL_ALIGN_BOTTOM, DEFAULT_FONT_SIZE, DEFAULT_ALIGNMENT, DEFAULT_VERTICAL_ALIGNMENT, DEFAULT_LINE_HEIGHT, DEFAULT_CHARACTER_SPACING, DEFAULT_FONT_COLOR, } from './constants.js';
3
3
  import { calculateDynamicFontSize, heightOfFontAtSize, getFontDescentInPt, getFontKitFont, getSplittedLines, widthOfTextAtSize, } from './helper.js';
4
- import { convertForPdfLayoutProps, rotatePoint, hex2RgbColor } from '../utils.js';
4
+ import { convertForPdfLayoutProps, rotatePoint, hex2PrintingColor } from '../utils.js';
5
5
  const embedAndGetFontObj = async (arg) => {
6
6
  const { pdfDoc, font, _cache } = arg;
7
7
  if (_cache.has(pdfDoc)) {
@@ -20,11 +20,11 @@ const embedAndGetFontObj = async (arg) => {
20
20
  _cache.set(pdfDoc, fontObj);
21
21
  return fontObj;
22
22
  };
23
- const getFontProp = async ({ value, font, schema, _cache, }) => {
23
+ const getFontProp = async ({ value, font, schema, colorType, _cache, }) => {
24
24
  const fontSize = schema.dynamicFontSize
25
25
  ? await calculateDynamicFontSize({ textSchema: schema, font, value, _cache })
26
26
  : schema.fontSize ?? DEFAULT_FONT_SIZE;
27
- const color = hex2RgbColor(schema.fontColor || DEFAULT_FONT_COLOR);
27
+ const color = hex2PrintingColor(schema.fontColor || DEFAULT_FONT_COLOR, colorType);
28
28
  return {
29
29
  alignment: schema.alignment ?? DEFAULT_ALIGNMENT,
30
30
  verticalAlignment: schema.verticalAlignment ?? DEFAULT_VERTICAL_ALIGNMENT,
@@ -38,11 +38,11 @@ export const pdfRender = async (arg) => {
38
38
  const { value, pdfDoc, pdfLib, page, options, schema, _cache } = arg;
39
39
  if (!value)
40
40
  return;
41
- const { font = getDefaultFont() } = options;
41
+ const { font = getDefaultFont(), colorType } = options;
42
42
  const [pdfFontObj, fontKitFont, fontProp] = await Promise.all([
43
43
  embedAndGetFontObj({ pdfDoc, font, _cache }),
44
44
  getFontKitFont(schema, font, _cache),
45
- getFontProp({ value, font, schema, _cache }),
45
+ getFontProp({ value, font, schema, _cache, colorType }),
46
46
  ]);
47
47
  const { fontSize, color, alignment, verticalAlignment, lineHeight, characterSpacing } = fontProp;
48
48
  const fontName = (schema.fontName ? schema.fontName : getFallbackFontName(font));
@@ -50,7 +50,7 @@ export const pdfRender = async (arg) => {
50
50
  const pageHeight = page.getHeight();
51
51
  const { width, height, rotate, position: { x, y }, opacity, } = convertForPdfLayoutProps({ schema, pageHeight, applyRotateTranslate: false });
52
52
  if (schema.backgroundColor) {
53
- const color = hex2RgbColor(schema.backgroundColor);
53
+ const color = hex2PrintingColor(schema.backgroundColor, colorType);
54
54
  page.drawRectangle({ x, y, width, height, rotate, color });
55
55
  }
56
56
  page.pushOperators(pdfLib.setCharacterSpacing(characterSpacing ?? DEFAULT_CHARACTER_SPACING));
@@ -1 +1 @@
1
- {"version":3,"file":"pdfRender.js","sourceRoot":"","sources":["../../../../src/text/pdfRender.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,cAAc,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjG,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAElF,MAAM,kBAAkB,GAAG,KAAK,EAAE,GAIjC,EAAE,EAAE;IACH,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IACrC,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QACtB,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,CAA+B,CAAC;KACzD;IAED,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,GAAG,CAClC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;QAClC,IAAI,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC;QACtB,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;YAC/D,QAAQ,GAAG,MAAM,K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;YAC1B,KAAK,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;SAClC;aAAM,IAAI,SAAS,KAAK,OAAO,EAAE;YAChC,KAAK,IAAI,KAAK,GAAG,SAAS,CAAC;SAC5B;QAED,IAAI,KAAK,GAAG,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,UAAU,CAAC;QAEzE,IAAI,MAAM,CAAC,KAAK,KAAK,CAAC,EAAE;YACtB,iGAAiG;YACjG,qGAAqG;YACrG,MAAM,YAAY,GAAG,WAAW,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;YACnF,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC;YACvB,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC;SACxB;QAED,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;YAClB,CAAC,EAAE,KAAK;YACR,CAAC,EAAE,KAAK;YACR,MAAM;YACN,IAAI,EAAE,QAAQ;YACd,KAAK;YACL,UAAU,EAAE,UAAU,GAAG,QAAQ;YACjC,IAAI,EAAE,YAAY;YAClB,OAAO;SACR,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { degrees, degreesToRadians, rgb } from '@pdfme/pdf-lib';
1
+ import { cmyk, degrees, degreesToRadians, rgb } from '@pdfme/pdf-lib';
2
2
  import { mm2pt, isHexValid } from '@pdfme/common';
3
3
  export const convertForPdfLayoutProps = ({ schema, pageHeight, applyRotateTranslate = true, }) => {
4
4
  const { width: mmWidth, height: mmHeight, position, rotate, opacity } = schema;
@@ -72,6 +72,40 @@ export const hex2RgbColor = (hexString) => {
72
72
  }
73
73
  return undefined;
74
74
  };
75
+ export const hex2CmykColor = (hexString) => {
76
+ if (hexString) {
77
+ const isValid = isHexValid(hexString);
78
+ if (!isValid) {
79
+ throw new Error(`Invalid hex color value ${hexString}`);
80
+ }
81
+ // Remove the # if it's present
82
+ hexString = hexString.replace('#', '');
83
+ // Extract the hexadecimal color code and the opacity
84
+ const hexColor = hexString.substring(0, 6);
85
+ const opacityColor = hexString.substring(6, 8);
86
+ const opacity = opacityColor ? parseInt(opacityColor, 16) / 255 : 1;
87
+ // Convert the hex values to decimal
88
+ let r = parseInt(hexColor.substring(0, 2), 16) / 255;
89
+ let g = parseInt(hexColor.substring(2, 4), 16) / 255;
90
+ let b = parseInt(hexColor.substring(4, 6), 16) / 255;
91
+ // Apply the opacity
92
+ r = r * opacity + (1 - opacity);
93
+ g = g * opacity + (1 - opacity);
94
+ b = b * opacity + (1 - opacity);
95
+ // Calculate the CMYK values
96
+ const k = 1 - Math.max(r, g, b);
97
+ const c = r === 0 ? 0 : (1 - r - k) / (1 - k);
98
+ const m = g === 0 ? 0 : (1 - g - k) / (1 - k);
99
+ const y = b === 0 ? 0 : (1 - b - k) / (1 - k);
100
+ return cmyk(c, m, y, k);
101
+ }
102
+ return undefined;
103
+ };
104
+ export const hex2PrintingColor = (hexString, colorType) => {
105
+ return colorType?.toLocaleLowerCase() == 'cmyk'
106
+ ? hex2CmykColor(hexString)
107
+ : hex2RgbColor(hexString);
108
+ };
75
109
  export const readFile = (input) => new Promise((resolve, reject) => {
76
110
  const fileReader = new FileReader();
77
111
  fileReader.onload = (e) => {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAU,KAAK,EAAQ,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhE,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EACvC,MAAM,EACN,UAAU,EACV,oBAAoB,GAAG,IAAI,GAK5B,EAAE,EAAE;IACH,MAA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AAmB;QAChC,KAAK,EAAE,OAAO;QACd,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,SAAS;QAClB,QAAQ,EAAE,MAAM;QAChB,UAAU,EAAE,MAAM;QAClB,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,yBAAyB;KACtC,CAAC;IACF,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAErC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;IAC3B,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAE5B,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Schema, Mode } from '@pdfme/common';
1
+ import { Schema, Mode, ColorType } from '@pdfme/common';
2
2
  export declare const convertForPdfLayoutProps: ({ schema, pageHeight, applyRotateTranslate, }: {
3
3
  schema: Schema;
4
4
  pageHeight: number;
@@ -26,5 +26,7 @@ export declare const rotatePoint: (point: {
26
26
  export declare const addAlphaToHex: (hex: string, alphaPercentage: number) => string;
27
27
  export declare const isEditable: (mode: Mode, schema: Schema) => boolean;
28
28
  export declare const hex2RgbColor: (hexString: string | undefined) => import("@pdfme/pdf-lib").RGB | undefined;
29
+ export declare const hex2CmykColor: (hexString: string | undefined) => import("@pdfme/pdf-lib").CMYK | undefined;
30
+ export declare const hex2PrintingColor: (hexString: string | undefined, colorType?: ColorType) => import("@pdfme/pdf-lib").RGB | import("@pdfme/pdf-lib").CMYK | undefined;
29
31
  export declare const readFile: (input: File | FileList | null) => Promise<string | ArrayBuffer>;
30
32
  export declare const createErrorElm: () => HTMLDivElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/schemas",
3
- "version": "3.2.3",
3
+ "version": "3.3.0-dev.1",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
@@ -1,5 +1,5 @@
1
1
  import type { Schema, Plugin, PDFRenderProps, UIRenderProps } from '@pdfme/common';
2
- import { rotatePoint, convertForPdfLayoutProps, hex2RgbColor } from '../utils.js';
2
+ import { rotatePoint, convertForPdfLayoutProps, hex2PrintingColor } from '../utils.js';
3
3
  import { HEX_COLOR_PATTERN } from '../constants.js';
4
4
 
5
5
  const DEFAULT_LINE_COLOR = '#000000';
@@ -10,7 +10,8 @@ interface LineSchema extends Schema {
10
10
 
11
11
  const lineSchema: Plugin<LineSchema> = {
12
12
  pdf: (arg: PDFRenderProps<LineSchema>) => {
13
- const { page, schema } = arg;
13
+ const { page, schema, options } = arg;
14
+ const { colorType } = options;
14
15
  const pageHeight = page.getHeight();
15
16
  const {
16
17
  width,
@@ -24,7 +25,7 @@ const lineSchema: Plugin<LineSchema> = {
24
25
  start: rotatePoint({ x, y: y + height / 2 }, pivot, rotate.angle),
25
26
  end: rotatePoint({ x: x + width, y: y + height / 2 }, pivot, rotate.angle),
26
27
  thickness: height,
27
- color: hex2RgbColor(schema.color ?? DEFAULT_LINE_COLOR),
28
+ color: hex2PrintingColor(schema.color ?? DEFAULT_LINE_COLOR, colorType),
28
29
  opacity: opacity,
29
30
  });
30
31
  },
@@ -1,6 +1,6 @@
1
1
  import { Plugin, Schema, mm2pt } from '@pdfme/common';
2
2
  import { HEX_COLOR_PATTERN } from '../constants.js';
3
- import { hex2RgbColor, convertForPdfLayoutProps } from '../utils.js';
3
+ import { hex2PrintingColor, convertForPdfLayoutProps } from '../utils.js';
4
4
 
5
5
  interface Shape extends Schema {
6
6
  type: 'ellipse' | 'rectangle';
@@ -27,7 +27,8 @@ const shape: Plugin<Shape> = {
27
27
  rootElement.appendChild(div);
28
28
  },
29
29
  pdf: (arg) => {
30
- const { schema, page } = arg;
30
+ const { schema, page, options } = arg;
31
+ const { colorType } = options;
31
32
  const pageHeight = page.getHeight();
32
33
  const cArg = { schema, pageHeight };
33
34
  const { position, width, height, rotate, opacity } = convertForPdfLayoutProps(cArg);
@@ -39,8 +40,8 @@ const shape: Plugin<Shape> = {
39
40
  const drawOptions = {
40
41
  rotate,
41
42
  borderWidth,
42
- borderColor: hex2RgbColor(schema.borderColor),
43
- color: hex2RgbColor(schema.color),
43
+ borderColor: hex2PrintingColor(schema.borderColor, colorType),
44
+ color: hex2PrintingColor(schema.color, colorType),
44
45
  opacity,
45
46
  borderOpacity: opacity,
46
47
  };
@@ -1,6 +1,13 @@
1
1
  import { PDFFont, PDFDocument } from '@pdfme/pdf-lib';
2
2
  import type { TextSchema, FontWidthCalcValues } from './types';
3
- import { PDFRenderProps, Font, getDefaultFont, getFallbackFontName, mm2pt } from '@pdfme/common';
3
+ import {
4
+ PDFRenderProps,
5
+ Font,
6
+ getDefaultFont,
7
+ getFallbackFontName,
8
+ mm2pt,
9
+ ColorType,
10
+ } from '@pdfme/common';
4
11
  import {
5
12
  VERTICAL_ALIGN_TOP,
6
13
  VERTICAL_ALIGN_MIDDLE,
@@ -20,7 +27,7 @@ import {
20
27
  getSplittedLines,
21
28
  widthOfTextAtSize,
22
29
  } from './helper.js';
23
- import { convertForPdfLayoutProps, rotatePoint, hex2RgbColor } from '../utils.js';
30
+ import { convertForPdfLayoutProps, rotatePoint, hex2PrintingColor } from '../utils.js';
24
31
 
25
32
  const embedAndGetFontObj = async (arg: {
26
33
  pdfDoc: PDFDocument;
@@ -57,17 +64,19 @@ const getFontProp = async ({
57
64
  value,
58
65
  font,
59
66
  schema,
67
+ colorType,
60
68
  _cache,
61
69
  }: {
62
70
  value: string;
63
71
  font: Font;
72
+ colorType?: ColorType;
64
73
  schema: TextSchema;
65
74
  _cache: Map<any, any>;
66
75
  }) => {
67
76
  const fontSize = schema.dynamicFontSize
68
77
  ? await calculateDynamicFontSize({ textSchema: schema, font, value, _cache })
69
78
  : schema.fontSize ?? DEFAULT_FONT_SIZE;
70
- const color = hex2RgbColor(schema.fontColor || DEFAULT_FONT_COLOR);
79
+ const color = hex2PrintingColor(schema.fontColor || DEFAULT_FONT_COLOR, colorType);
71
80
 
72
81
  return {
73
82
  alignment: schema.alignment ?? DEFAULT_ALIGNMENT,
@@ -83,12 +92,12 @@ export const pdfRender = async (arg: PDFRenderProps<TextSchema>) => {
83
92
  const { value, pdfDoc, pdfLib, page, options, schema, _cache } = arg;
84
93
  if (!value) return;
85
94
 
86
- const { font = getDefaultFont() } = options;
95
+ const { font = getDefaultFont(), colorType } = options;
87
96
 
88
97
  const [pdfFontObj, fontKitFont, fontProp] = await Promise.all([
89
98
  embedAndGetFontObj({ pdfDoc, font, _cache }),
90
99
  getFontKitFont(schema, font, _cache),
91
- getFontProp({ value, font, schema, _cache }),
100
+ getFontProp({ value, font, schema, _cache, colorType }),
92
101
  ]);
93
102
 
94
103
  const { fontSize, color, alignment, verticalAlignment, lineHeight, characterSpacing } = fontProp;
@@ -108,7 +117,7 @@ export const pdfRender = async (arg: PDFRenderProps<TextSchema>) => {
108
117
  } = convertForPdfLayoutProps({ schema, pageHeight, applyRotateTranslate: false });
109
118
 
110
119
  if (schema.backgroundColor) {
111
- const color = hex2RgbColor(schema.backgroundColor);
120
+ const color = hex2PrintingColor(schema.backgroundColor, colorType);
112
121
  page.drawRectangle({ x, y, width, height, rotate, color });
113
122
  }
114
123
 
package/src/utils.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type * as CSS from 'csstype';
2
- import { degrees, degreesToRadians, rgb } from '@pdfme/pdf-lib';
3
- import { Schema, mm2pt, Mode, isHexValid } from '@pdfme/common';
2
+ import { cmyk, degrees, degreesToRadians, rgb } from '@pdfme/pdf-lib';
3
+ import { Schema, mm2pt, Mode, isHexValid, ColorType } from '@pdfme/common';
4
4
 
5
5
  export const convertForPdfLayoutProps = ({
6
6
  schema,
@@ -103,6 +103,50 @@ export const hex2RgbColor = (hexString: string | undefined) => {
103
103
  return undefined;
104
104
  };
105
105
 
106
+ export const hex2CmykColor = (hexString: string | undefined) => {
107
+ if (hexString) {
108
+ const isValid = isHexValid(hexString);
109
+
110
+ if (!isValid) {
111
+ throw new Error(`Invalid hex color value ${hexString}`);
112
+ }
113
+
114
+ // Remove the # if it's present
115
+ hexString = hexString.replace('#', '');
116
+
117
+ // Extract the hexadecimal color code and the opacity
118
+ const hexColor = hexString.substring(0, 6);
119
+ const opacityColor = hexString.substring(6, 8);
120
+ const opacity = opacityColor ? parseInt(opacityColor, 16) / 255 : 1;
121
+
122
+ // Convert the hex values to decimal
123
+ let r = parseInt(hexColor.substring(0, 2), 16) / 255;
124
+ let g = parseInt(hexColor.substring(2, 4), 16) / 255;
125
+ let b = parseInt(hexColor.substring(4, 6), 16) / 255;
126
+
127
+ // Apply the opacity
128
+ r = r * opacity + (1 - opacity);
129
+ g = g * opacity + (1 - opacity);
130
+ b = b * opacity + (1 - opacity);
131
+
132
+ // Calculate the CMYK values
133
+ const k = 1 - Math.max(r, g, b);
134
+ const c = r === 0 ? 0 : (1 - r - k) / (1 - k);
135
+ const m = g === 0 ? 0 : (1 - g - k) / (1 - k);
136
+ const y = b === 0 ? 0 : (1 - b - k) / (1 - k);
137
+
138
+ return cmyk(c, m, y, k);
139
+ }
140
+
141
+ return undefined;
142
+ };
143
+
144
+ export const hex2PrintingColor = (hexString: string | undefined, colorType?: ColorType) => {
145
+ return colorType?.toLocaleLowerCase() == 'cmyk'
146
+ ? hex2CmykColor(hexString)
147
+ : hex2RgbColor(hexString);
148
+ };
149
+
106
150
  export const readFile = (input: File | FileList | null): Promise<string | ArrayBuffer> =>
107
151
  new Promise((resolve, reject) => {
108
152
  const fileReader = new FileReader();