@pdfme/schemas 4.0.0-alpha.0 → 4.0.0-dev.3

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.
Files changed (107) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/__tests__/text.test.js +10 -4
  3. package/dist/cjs/__tests__/text.test.js.map +1 -1
  4. package/dist/cjs/src/barcodes/propPanel.js +12 -0
  5. package/dist/cjs/src/barcodes/propPanel.js.map +1 -1
  6. package/dist/cjs/src/graphics/cacheKey.js +6 -0
  7. package/dist/cjs/src/graphics/cacheKey.js.map +1 -0
  8. package/dist/cjs/src/graphics/image.js +26 -15
  9. package/dist/cjs/src/graphics/image.js.map +1 -1
  10. package/dist/{esm/src/graphics/helper.js → cjs/src/graphics/imagehelper.js} +15 -2
  11. package/dist/cjs/src/graphics/imagehelper.js.map +1 -0
  12. package/dist/cjs/src/graphics/pdfHelper.js +49 -0
  13. package/dist/cjs/src/graphics/pdfHelper.js.map +1 -0
  14. package/dist/cjs/src/graphics/svg.js +2 -0
  15. package/dist/cjs/src/graphics/svg.js.map +1 -1
  16. package/dist/cjs/src/index.js +3 -2
  17. package/dist/cjs/src/index.js.map +1 -1
  18. package/dist/cjs/src/shapes/line.js +4 -2
  19. package/dist/cjs/src/shapes/line.js.map +1 -1
  20. package/dist/cjs/src/shapes/rectAndEllipse.js +13 -6
  21. package/dist/cjs/src/shapes/rectAndEllipse.js.map +1 -1
  22. package/dist/cjs/src/tables/pdfRender.js +0 -2
  23. package/dist/cjs/src/tables/pdfRender.js.map +1 -1
  24. package/dist/cjs/src/tables/propPanel.js +1 -0
  25. package/dist/cjs/src/tables/propPanel.js.map +1 -1
  26. package/dist/cjs/src/tables/uiRender.js +44 -23
  27. package/dist/cjs/src/tables/uiRender.js.map +1 -1
  28. package/dist/cjs/src/text/helper.js +27 -7
  29. package/dist/cjs/src/text/helper.js.map +1 -1
  30. package/dist/cjs/src/text/index.js +1 -0
  31. package/dist/cjs/src/text/index.js.map +1 -1
  32. package/dist/cjs/src/text/pdfRender.js +4 -4
  33. package/dist/cjs/src/text/pdfRender.js.map +1 -1
  34. package/dist/cjs/src/text/propPanel.js +1 -0
  35. package/dist/cjs/src/text/propPanel.js.map +1 -1
  36. package/dist/cjs/src/text/uiRender.js +22 -1
  37. package/dist/cjs/src/text/uiRender.js.map +1 -1
  38. package/dist/cjs/src/utils.js +37 -7
  39. package/dist/cjs/src/utils.js.map +1 -1
  40. package/dist/esm/__tests__/text.test.js +10 -4
  41. package/dist/esm/__tests__/text.test.js.map +1 -1
  42. package/dist/esm/src/barcodes/propPanel.js +12 -0
  43. package/dist/esm/src/barcodes/propPanel.js.map +1 -1
  44. package/dist/esm/src/graphics/cacheKey.js +2 -0
  45. package/dist/esm/src/graphics/cacheKey.js.map +1 -0
  46. package/dist/esm/src/graphics/image.js +25 -14
  47. package/dist/esm/src/graphics/image.js.map +1 -1
  48. package/dist/{cjs/src/graphics/helper.js → esm/src/graphics/imagehelper.js} +10 -5
  49. package/dist/esm/src/graphics/imagehelper.js.map +1 -0
  50. package/dist/esm/src/graphics/pdfHelper.js +44 -0
  51. package/dist/esm/src/graphics/pdfHelper.js.map +1 -0
  52. package/dist/esm/src/graphics/svg.js +2 -0
  53. package/dist/esm/src/graphics/svg.js.map +1 -1
  54. package/dist/esm/src/index.js +2 -1
  55. package/dist/esm/src/index.js.map +1 -1
  56. package/dist/esm/src/shapes/line.js +5 -3
  57. package/dist/esm/src/shapes/line.js.map +1 -1
  58. package/dist/esm/src/shapes/rectAndEllipse.js +14 -7
  59. package/dist/esm/src/shapes/rectAndEllipse.js.map +1 -1
  60. package/dist/esm/src/tables/pdfRender.js +0 -2
  61. package/dist/esm/src/tables/pdfRender.js.map +1 -1
  62. package/dist/esm/src/tables/propPanel.js +1 -0
  63. package/dist/esm/src/tables/propPanel.js.map +1 -1
  64. package/dist/esm/src/tables/uiRender.js +39 -18
  65. package/dist/esm/src/tables/uiRender.js.map +1 -1
  66. package/dist/esm/src/text/helper.js +25 -6
  67. package/dist/esm/src/text/helper.js.map +1 -1
  68. package/dist/esm/src/text/index.js +1 -0
  69. package/dist/esm/src/text/index.js.map +1 -1
  70. package/dist/esm/src/text/pdfRender.js +6 -6
  71. package/dist/esm/src/text/pdfRender.js.map +1 -1
  72. package/dist/esm/src/text/propPanel.js +1 -0
  73. package/dist/esm/src/text/propPanel.js.map +1 -1
  74. package/dist/esm/src/text/uiRender.js +23 -2
  75. package/dist/esm/src/text/uiRender.js.map +1 -1
  76. package/dist/esm/src/utils.js +35 -6
  77. package/dist/esm/src/utils.js.map +1 -1
  78. package/dist/types/src/graphics/cacheKey.d.ts +2 -0
  79. package/dist/types/src/graphics/image.d.ts +1 -1
  80. package/dist/types/src/graphics/imagehelper.d.ts +4 -0
  81. package/dist/types/src/graphics/pdfHelper.d.ts +8 -0
  82. package/dist/types/src/index.d.ts +2 -2
  83. package/dist/types/src/shapes/rectAndEllipse.d.ts +6 -0
  84. package/dist/types/src/text/helper.d.ts +1 -0
  85. package/dist/types/src/utils.d.ts +3 -2
  86. package/package.json +1 -1
  87. package/src/barcodes/propPanel.ts +14 -0
  88. package/src/graphics/cacheKey.ts +3 -0
  89. package/src/graphics/image.ts +28 -19
  90. package/src/graphics/{helper.ts → imagehelper.ts} +10 -1
  91. package/src/graphics/pdfHelper.ts +55 -0
  92. package/src/graphics/svg.ts +2 -0
  93. package/src/index.ts +3 -1
  94. package/src/shapes/line.ts +5 -3
  95. package/src/shapes/rectAndEllipse.ts +17 -7
  96. package/src/tables/pdfRender.ts +0 -2
  97. package/src/tables/propPanel.ts +1 -0
  98. package/src/tables/uiRender.ts +50 -19
  99. package/src/text/helper.ts +27 -6
  100. package/src/text/index.ts +1 -0
  101. package/src/text/pdfRender.ts +14 -5
  102. package/src/text/propPanel.ts +1 -0
  103. package/src/text/uiRender.ts +22 -1
  104. package/src/utils.ts +46 -9
  105. package/dist/cjs/src/graphics/helper.js.map +0 -1
  106. package/dist/esm/src/graphics/helper.js.map +0 -1
  107. package/dist/types/src/graphics/helper.d.ts +0 -5
@@ -1 +1 @@
1
- {"version":3,"file":"propPanel.js","sourceRoot":"","sources":["../../../../src/text/propPanel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAIjB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,0BAA0B,EAC1B,yBAAyB,EACzB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,6BAA6B,EAC7B,6BAA6B,EAC7B,WAAW,EACX,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAErE,MAAM,kBAAkB,GAAG,CAAC,KAA2B,EAAE,EAAE;IACzD,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAEjE,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACjD,QAAQ,CAAC,IAAI,GAAG,UAAU,CAAC;IAC3B,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAE,YAAoB,EAAE,eAAe,CAAC,CAAC;IACnE,QAAQ,CAAC,QAAQ,GAAG,CAAC,CAAM,EAAE,EAAE;QAC7B,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO;YAC1B,CAAC,CAAC;gBACE,GAAG,EAAE,6BAA6B;gBAClC,GAAG,EAAE,6BAA6B;gBAClC,GAAG,EAAE,mBAAmB;aACzB;YACH,CAAC,CAAC,SAAS,CAAC;QACd,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,iBAAiB,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,C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,EAAE,IAAI,CAAC,gBAAgB,CAAC;qBAChC;iBACF;aACF;YACD,eAAe,EAAE;gBACf,KAAK,EAAE,IAAI,CAAC,iBAAiB,CAAC;gBAC9B,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE,OAAO;gBACf,KAAK,EAAE;oBACL;wBACE,OAAO,EAAE,iBAAiB;wBAC1B,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC;qBAChC;iBACF;aACF;SACF,CAAC;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,OAAO,EAAE,EAAE,kBAAkB,EAAE;IAC/B,aAAa,EAAE;QACb,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,mcAAmc;QACzc,OAAO,EAAE,mBAAmB;QAC5B,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;QACxB,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,uGAAuG;QACvG,4GAA4G;QAC5G,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,iBAAiB;QAC5B,iBAAiB,EAAE,0BAA0B;QAC7C,QAAQ,EAAE,iBAAiB;QAC3B,UAAU,EAAE,mBAAmB;QAC/B,gBAAgB,EAAE,yBAAyB;QAC3C,eAAe,EAAE,SAAS;QAC1B,SAAS,EAAE,kBAAkB;QAC7B,QAAQ,EAAE,SAAS;QACnB,eAAe,EAAE,EAAE;QACnB,OAAO,EAAE,eAAe;KACzB;CACF,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { getDefaultFont } from '@pdfme/common';
2
2
  import { DEFAULT_FONT_SIZE, DEFAULT_ALIGNMENT, VERTICAL_ALIGN_TOP, VERTICAL_ALIGN_MIDDLE, VERTICAL_ALIGN_BOTTOM, DEFAULT_VERTICAL_ALIGNMENT, DEFAULT_LINE_HEIGHT, DEFAULT_CHARACTER_SPACING, DEFAULT_FONT_COLOR, PLACEHOLDER_FONT_COLOR, } from './constants.js';
3
- import { calculateDynamicFontSize, getFontKitFont, getBrowserVerticalFontAdjustments, } from './helper.js';
3
+ import { calculateDynamicFontSize, getFontKitFont, getBrowserVerticalFontAdjustments, isFirefox, } from './helper.js';
4
4
  import { isEditable } from '../utils.js';
5
5
  const mapVerticalAlignToFlex = (verticalAlignmentValue) => {
6
6
  switch (verticalAlignmentValue) {
@@ -75,7 +75,28 @@ export const uiRender = async (arg) => {
75
75
  const textBlock = document.createElement('div');
76
76
  Object.assign(textBlock.style, textBlockStyle);
77
77
  if (isEditable(mode, schema)) {
78
- textBlock.contentEditable = 'plaintext-only';
78
+ if (!isFirefox()) {
79
+ textBlock.contentEditable = 'plaintext-only';
80
+ }
81
+ else {
82
+ textBlock.contentEditable = 'true';
83
+ textBlock.addEventListener('keydown', (e) => {
84
+ if (e.key === 'Enter' && !e.shiftKey) {
85
+ e.preventDefault();
86
+ document.execCommand('insertLineBreak', false, undefined);
87
+ }
88
+ });
89
+ textBlock.addEventListener('paste', (e) => {
90
+ e.preventDefault();
91
+ const paste = e.clipboardData?.getData('text');
92
+ const selection = window.getSelection();
93
+ if (!selection?.rangeCount)
94
+ return;
95
+ selection.deleteFromDocument();
96
+ selection.getRangeAt(0).insertNode(document.createTextNode(paste || ''));
97
+ selection.collapseToEnd();
98
+ });
99
+ }
79
100
  textBlock.tabIndex = tabIndex || 0;
80
101
  textBlock.innerText = value;
81
102
  textBlock.addEventListener('blur', (e) => {
@@ -1 +1 @@
1
- {"version":3,"file":"uiRender.js","sourceRoot":"","sources":["../../../../src/text/uiRender.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,cAAc,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,i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AAC,CAAC;QAEjC,IAAI,IAAI,KAAK,UAAU,EAAE;YACvB,UAAU,CAAC,GAAG,EAAE;gBACd,SAAS,CAAC,KAAK,EAAE,CAAC;gBAClB,8FAA8F;gBAC9F,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;gBACxC,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;gBACrC,KAAK,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;gBACpC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,4BAA4B;gBACnD,SAAS,EAAE,eAAe,EAAE,CAAC;gBAC7B,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC;SACJ;KACF;SAAM;QACL,SAAS,CAAC,SAAS,GAAG,KAAK;aACxB,KAAK,CAAC,EAAE,CAAC;aACT,GAAG,CACF,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CACvB,+BACE,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SACvC,MAAM,CAAC,SAAS,CACnB;aACA,IAAI,CAAC,EAAE,CAAC,CAAC;QAEZ,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;KAClC;AACH,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) => {
@@ -121,10 +155,5 @@ export const createErrorElm = () => {
121
155
  container.appendChild(span);
122
156
  return container;
123
157
  };
124
- export const px2mm = (px) => {
125
- // http://www.endmemo.com/sconvert/millimeterpixel.php
126
- const ratio = 0.26458333333333;
127
- return parseFloat(String(px)) * ratio;
128
- };
129
158
  export const cloneDeep = (value) => JSON.parse(JSON.stringify(value));
130
159
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],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-1,6 +1,6 @@
1
1
  import type { Plugin } from '@pdfme/common';
2
2
  import type { Schema } from '@pdfme/common';
3
- interface ImageSchema extends Schema {
3
+ export interface ImageSchema extends Schema {
4
4
  }
5
5
  declare const imageSchema: Plugin<ImageSchema>;
6
6
  export default imageSchema;
@@ -0,0 +1,4 @@
1
+ export declare const getImageDimension: (value: string) => {
2
+ height: number;
3
+ width: number;
4
+ };
@@ -0,0 +1,8 @@
1
+ import { UIRenderProps } from '@pdfme/common';
2
+ import { ImageSchema } from './image';
3
+ export declare function isPdf(content: string): boolean;
4
+ /**
5
+ * convert pdf to blob image url
6
+ * @param content
7
+ */
8
+ export declare const pdfToImage: ({ schema, value, _cache, pdfJs, }: UIRenderProps<ImageSchema>) => Promise<string>;
@@ -3,11 +3,11 @@ import image, { readOnlyImage } from './graphics/image.js';
3
3
  import svg, { readOnlySvg } from './graphics/svg.js';
4
4
  import barcodes from './barcodes/index.js';
5
5
  import line from './shapes/line.js';
6
- import table from './tables/index.js';
7
6
  import { modifyTemplateForTable, getDynamicHeightForTable } from './tables/dynamicTemplate.js';
8
7
  import { rectangle, ellipse } from './shapes/rectAndEllipse.js';
9
8
  import { convertForPdfLayoutProps, rotatePoint } from './utils.js';
9
+ declare const tableBeta: import("@pdfme/common").Plugin<import("./tables/types.js").TableSchema>;
10
10
  declare const builtInPlugins: {
11
11
  Text: import("@pdfme/common").Plugin<import("./text/types.js").TextSchema>;
12
12
  };
13
- export { text, readOnlyText, image, readOnlyImage, svg, readOnlySvg, barcodes, line, table, modifyTemplateForTable, getDynamicHeightForTable, rectangle, ellipse, builtInPlugins, convertForPdfLayoutProps, rotatePoint, };
13
+ export { text, readOnlyText, image, readOnlyImage, svg, readOnlySvg, barcodes, line, tableBeta, modifyTemplateForTable, getDynamicHeightForTable, rectangle, ellipse, builtInPlugins, convertForPdfLayoutProps, rotatePoint, };
@@ -9,6 +9,7 @@ export declare const rectangle: {
9
9
  propPanel: {
10
10
  defaultSchema: {
11
11
  type: "ellipse" | "rectangle";
12
+ icon: string;
12
13
  borderWidth: number;
13
14
  borderColor: string;
14
15
  color: string;
@@ -37,6 +38,7 @@ export declare const rectangle: {
37
38
  key: string;
38
39
  opacity?: number | undefined;
39
40
  rotate?: number | undefined;
41
+ icon?: string | undefined;
40
42
  content?: string | undefined;
41
43
  readOnly?: boolean | undefined;
42
44
  };
@@ -54,6 +56,7 @@ export declare const rectangle: {
54
56
  key: string;
55
57
  opacity?: number | undefined;
56
58
  rotate?: number | undefined;
59
+ icon?: string | undefined;
57
60
  content?: string | undefined;
58
61
  readOnly?: boolean | undefined;
59
62
  }[];
@@ -70,6 +73,7 @@ export declare const ellipse: {
70
73
  propPanel: {
71
74
  defaultSchema: {
72
75
  type: "ellipse" | "rectangle";
76
+ icon: string;
73
77
  borderWidth: number;
74
78
  borderColor: string;
75
79
  color: string;
@@ -98,6 +102,7 @@ export declare const ellipse: {
98
102
  key: string;
99
103
  opacity?: number | undefined;
100
104
  rotate?: number | undefined;
105
+ icon?: string | undefined;
101
106
  content?: string | undefined;
102
107
  readOnly?: boolean | undefined;
103
108
  };
@@ -115,6 +120,7 @@ export declare const ellipse: {
115
120
  key: string;
116
121
  opacity?: number | undefined;
117
122
  rotate?: number | undefined;
123
+ icon?: string | undefined;
118
124
  content?: string | undefined;
119
125
  readOnly?: boolean | undefined;
120
126
  }[];
@@ -35,3 +35,4 @@ export declare const splitTextToSize: (arg: {
35
35
  fontSize: number;
36
36
  fontKitFont: fontkit.Font;
37
37
  }) => string[];
38
+ export declare const isFirefox: () => boolean;
@@ -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,7 +26,8 @@ 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;
31
- export declare const px2mm: (px: number) => number;
32
33
  export declare const cloneDeep: <T>(value: T) => T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/schemas",
3
- "version": "4.0.0-alpha.0",
3
+ "version": "4.0.0-dev.3",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
@@ -16,10 +16,14 @@ const defaultIncludetext = { includetext: DEFAULT_BARCODE_INCLUDETEXT };
16
16
  const position = { x: 0, y: 0 };
17
17
  const default40x20 = { width: 40, height: 20 };
18
18
 
19
+ const barcodeIcon =
20
+ '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-barcode"><path d="M3 5v14"/><path d="M8 5v14"/><path d="M12 5v14"/><path d="M17 5v14"/><path d="M21 5v14"/></svg>';
21
+
19
22
  const barcodeDefaults: { defaultSchema: BarcodeSchema }[] = [
20
23
  {
21
24
  defaultSchema: {
22
25
  type: 'qrcode',
26
+ icon: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-qr-code"><rect width="5" height="5" x="3" y="3" rx="1"/><rect width="5" height="5" x="16" y="3" rx="1"/><rect width="5" height="5" x="3" y="16" rx="1"/><path d="M21 16h-3a2 2 0 0 0-2 2v3"/><path d="M21 21v.01"/><path d="M12 7v3a2 2 0 0 1-2 2H7"/><path d="M3 12h.01"/><path d="M12 3h.01"/><path d="M12 16v.01"/><path d="M16 12h1"/><path d="M21 12v.01"/><path d="M12 21v-1"/></svg>',
23
27
  content: 'https://pdfme.com/',
24
28
  position,
25
29
  ...defaultColors,
@@ -32,6 +36,7 @@ const barcodeDefaults: { defaultSchema: BarcodeSchema }[] = [
32
36
  {
33
37
  defaultSchema: {
34
38
  type: 'japanpost',
39
+ icon: barcodeIcon,
35
40
  content: '6540123789-A-K-Z',
36
41
  position,
37
42
  ...defaultColors,
@@ -46,6 +51,7 @@ const barcodeDefaults: { defaultSchema: BarcodeSchema }[] = [
46
51
  {
47
52
  defaultSchema: {
48
53
  type: 'ean13',
54
+ icon: barcodeIcon,
49
55
  content: '2112345678900',
50
56
  position,
51
57
  ...defaultColors,
@@ -60,6 +66,7 @@ const barcodeDefaults: { defaultSchema: BarcodeSchema }[] = [
60
66
  {
61
67
  defaultSchema: {
62
68
  type: 'ean8',
69
+ icon: barcodeIcon,
63
70
  content: '02345673',
64
71
  position,
65
72
  ...defaultColors,
@@ -73,6 +80,7 @@ const barcodeDefaults: { defaultSchema: BarcodeSchema }[] = [
73
80
  {
74
81
  defaultSchema: {
75
82
  type: 'code39',
83
+ icon: barcodeIcon,
76
84
  content: 'THIS IS CODE 39',
77
85
  position,
78
86
  ...defaultColors,
@@ -85,6 +93,7 @@ const barcodeDefaults: { defaultSchema: BarcodeSchema }[] = [
85
93
  {
86
94
  defaultSchema: {
87
95
  type: 'code128',
96
+ icon: barcodeIcon,
88
97
  content: 'This is Code 128!',
89
98
  position,
90
99
  ...defaultColors,
@@ -98,6 +107,7 @@ const barcodeDefaults: { defaultSchema: BarcodeSchema }[] = [
98
107
  {
99
108
  defaultSchema: {
100
109
  type: 'nw7',
110
+ icon: barcodeIcon,
101
111
  content: 'A0123456789B',
102
112
  position,
103
113
  ...defaultColors,
@@ -111,6 +121,7 @@ const barcodeDefaults: { defaultSchema: BarcodeSchema }[] = [
111
121
  {
112
122
  defaultSchema: {
113
123
  type: 'itf14',
124
+ icon: barcodeIcon,
114
125
  content: '04601234567893',
115
126
  position,
116
127
  ...defaultColors,
@@ -125,6 +136,7 @@ const barcodeDefaults: { defaultSchema: BarcodeSchema }[] = [
125
136
  {
126
137
  defaultSchema: {
127
138
  type: 'upca',
139
+ icon: barcodeIcon,
128
140
  content: '416000336108',
129
141
  position,
130
142
  ...defaultColors,
@@ -139,6 +151,7 @@ const barcodeDefaults: { defaultSchema: BarcodeSchema }[] = [
139
151
  {
140
152
  defaultSchema: {
141
153
  type: 'upce',
154
+ icon: barcodeIcon,
142
155
  content: '00123457',
143
156
  position,
144
157
  ...defaultColors,
@@ -152,6 +165,7 @@ const barcodeDefaults: { defaultSchema: BarcodeSchema }[] = [
152
165
  {
153
166
  defaultSchema: {
154
167
  type: 'gs1datamatrix',
168
+ icon: barcodeIcon,
155
169
  content: '(01)03453120000011(17)191125(10)ABCD1234',
156
170
  position,
157
171
  ...defaultColors,
@@ -0,0 +1,3 @@
1
+ import { Schema } from '@pdfme/common';
2
+
3
+ export const getCacheKey = (schema: Schema, input: string) => `${schema.type}${input}`;
@@ -1,40 +1,42 @@
1
1
  import type { ChangeEvent } from 'react';
2
- import type { PDFImage } from '@pdfme/pdf-lib';
2
+ import type { PDFImage, PDFEmbeddedPage } from '@pdfme/pdf-lib';
3
3
  import type { Plugin } from '@pdfme/common';
4
4
  import type { PDFRenderProps, Schema } from '@pdfme/common';
5
5
  import type * as CSS from 'csstype';
6
- import { Buffer } from 'buffer';
7
- import { UIRenderProps } from '@pdfme/common';
8
- import { convertForPdfLayoutProps, addAlphaToHex, isEditable, readFile, px2mm } from '../utils.js';
6
+ import { UIRenderProps, px2mm } from '@pdfme/common';
7
+ import { convertForPdfLayoutProps, addAlphaToHex, isEditable, readFile } from '../utils.js';
9
8
  import { DEFAULT_OPACITY } from '../constants.js';
10
- import { imageSize } from './helper.js';
9
+ import { getImageDimension } from './imagehelper.js';
10
+ import { isPdf, pdfToImage } from './pdfHelper.js';
11
11
 
12
12
  const getCacheKey = (schema: Schema, input: string) => `${schema.type}${input}`;
13
13
  const fullSize = { width: '100%', height: '100%' };
14
14
  const defaultValue =
15
15
  'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUgAAAGQBAMAAAA+V+RCAAAAAXNSR0IArs4c6QAAABtQTFRFAAAAR3BMAAAAAAAAAAAAAAAAAAAAAAAAAAAAqmQqwQAAAAh0Uk5TDQAvVYGtxusE1uR9AAAKg0lEQVR42tTbwU7bQBDG8TWoPeOBPoBbdbhiVMGV0Kr0GChSe0RtRfccEOROnP0eu8ckTMHrjD27/h4Afvo7u4kUxZXbjuboZ+Hx9vrz+6J8eW5rJKPHhYfr46J/JHn0u/DnuHcko/eF71Ub0j6k3P1Rr0jGIHs4bkPah5RbnveHZMBQ6VKHlMqjnpCMAdfUApk8pNx91QeSMex+C2R2IYFwrkcyht6yEsjkIeXutEjG8AtnApldSGBRqJAMk10JZHYhgaZSIBlG+yWQipAGKZ0ipNmr0uUaEmiKLZEMw52tkLqQD7f6PT7iv1uskLqQV06/nQ9ffswhF+oVUhMS07KX7Xz6+8ot5BQhBVLF/Pry0XGKkAKpGp3IRz7pjmQMiSz3TvB8s85I8h2ReuWy6IpkDIws6UI8745I8oMjy10vnnc3JGN4ZPlRnO9OSPIWyL0LcZ93QTIskOXuXPz9eCR5G2R5io09dUEyjJD7c3kJudiQJkiZMtTxSIYZ8mAu/oGLDGmHLL9hfXfRSIYh8g3W18QiyVsh5VdtoYpEMsyQ8uhM4pDk7ZDyeU/jkAw7pHzesygkeUOkPN+LKCTDGsnP3nNcREhz5MHm8Y5AMkyRskvdjiRvi5Qvyst2JCMB8hBru2lFkjdGypty1opkpEDuY21PbUjy1kh5nS/akIwkyL2fWK0pXEtIc6Q83ssWJCMR8nTjNncxIe2Rh/FIRirkW6ytdjEh7ZHvopGMFEj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Nwr7gmRecwmzs2l69I6dlxfrPuw2Q4T6SonTs2B2FKRkXd3L3hPdN3g4rC3LmREyT6OFE7SSOn9omYIlKRr7E/2SdiBiJFNHOsU6JIQbpLZ6ZynnAUHxY5M1N2NdCcSHE3deZAaLKbMkxxdF1pb/QoIordau+WxnkhIgXhXXt2jf4Mup8Cuu35vJNBwyo+MGK7Q8MmHxVIP4GV9tavXfD+pkDSOYTSmUCuqES2cgilxUDiXKPgE6sD3L+BeBVITKdxaws5gOcRlUh8hM3GSoNjAoX8iRgJ6VOeezaMmIpiykiehHiEe+aN/tmuYuMxktuby4NnxYitzchOjkrDLR6cZWCYMrIiXc7zoUnj3nX1s8ZUTbqc5eWhMeLpoibvkdJmemBejSPVeIn6V4ssr0nXo7QzNCxp+th4KVKEQXkmRvLQcaxcANKPXTO+eICkgWvIW0JkEDsWyB4hkgbuBRKRQexcIBFJA/cCichg5o5x7VUg6SCzTMN0YYikiSvIL1SNDGLnRg0i6ch2g2PeNUTSmQvIBwIknAtZLXgWiEgKY+sdckTfQ9J+Yte4eUOIhHJkQ4mJABGJSvvGeiT1F7aMyzH9KJL2biyN6zdUjUTlr6l54vZDj+qQWPrXmWEi5KUEJBa//26RGRMuP449+jEkprV8TLPGgenjx8uomkj0N73+g6V/XjknAAAAAElFTkSuQmCC';
16
16
 
17
- interface ImageSchema extends Schema {}
17
+ export interface ImageSchema extends Schema {}
18
18
 
19
19
  const imageSchema: Plugin<ImageSchema> = {
20
20
  pdf: async (arg: PDFRenderProps<ImageSchema>) => {
21
21
  const { value, schema, pdfDoc, page, _cache } = arg;
22
- if (!value || !value.startsWith('data:image/')) return;
22
+ const isGraphicPdf = isPdf(value);
23
+ const isImageOrPdf = value.startsWith('data:image/') || isGraphicPdf;
24
+ if (!value || !isImageOrPdf) return;
23
25
 
24
26
  const inputImageCacheKey = getCacheKey(schema, value);
25
- let image = _cache.get(inputImageCacheKey) as PDFImage;
27
+ let image = _cache.get(inputImageCacheKey) as PDFImage | PDFEmbeddedPage;
26
28
  if (!image) {
27
- const isPng = value.startsWith('data:image/png;');
28
- image = await (isPng ? pdfDoc.embedPng(value) : pdfDoc.embedJpg(value));
29
+ if (isGraphicPdf) {
30
+ [image] = await pdfDoc.embedPdf(value);
31
+ } else {
32
+ const isPng = value.startsWith('data:image/png;');
33
+ image = await (isPng ? pdfDoc.embedPng(value) : pdfDoc.embedJpg(value));
34
+ }
29
35
  _cache.set(inputImageCacheKey, image);
30
36
  }
31
37
 
32
38
  const _schema = { ...schema, position: { ...schema.position } };
33
- const dataUriPrefix = ';base64,';
34
- const idx = value.indexOf(dataUriPrefix);
35
- const imgBase64 = value.substring(idx + dataUriPrefix.length, value.length);
36
- const dimension = imageSize(Buffer.from(imgBase64, 'base64'));
37
-
39
+ const dimension = isGraphicPdf ? image.scale(1) : getImageDimension(value);
38
40
  const imageWidth = px2mm(dimension.width);
39
41
  const imageHeight = px2mm(dimension.height);
40
42
  const boxWidth = _schema.width;
@@ -57,9 +59,13 @@ const imageSchema: Plugin<ImageSchema> = {
57
59
  const lProps = convertForPdfLayoutProps({ schema: _schema, pageHeight });
58
60
  const { width, height, rotate, position, opacity } = lProps;
59
61
  const { x, y } = position;
60
- page.drawImage(image, { x, y, rotate, width, height, opacity });
62
+
63
+ const drawOptions = { x, y, rotate, width, height, opacity };
64
+ isGraphicPdf
65
+ ? page.drawPage(image as PDFEmbeddedPage, drawOptions)
66
+ : page.drawImage(image as PDFImage, drawOptions);
61
67
  },
62
- ui: (arg: UIRenderProps<ImageSchema>) => {
68
+ ui: async (arg: UIRenderProps<ImageSchema>) => {
63
69
  const {
64
70
  value,
65
71
  rootElement,
@@ -93,6 +99,7 @@ const imageSchema: Plugin<ImageSchema> = {
93
99
 
94
100
  // image tag
95
101
  if (value) {
102
+ let src = isPdf(value) ? await pdfToImage(arg) : value;
96
103
  const img = document.createElement('img');
97
104
  const imgStyle: CSS.Properties = {
98
105
  height: '100%',
@@ -101,7 +108,7 @@ const imageSchema: Plugin<ImageSchema> = {
101
108
  objectFit: 'contain',
102
109
  };
103
110
  Object.assign(img.style, imgStyle);
104
- img.src = value;
111
+ img.src = src;
105
112
  container.appendChild(img);
106
113
  }
107
114
 
@@ -159,7 +166,7 @@ const imageSchema: Plugin<ImageSchema> = {
159
166
  Object.assign(input.style, inputStyle);
160
167
  input.tabIndex = tabIndex || 0;
161
168
  input.type = 'file';
162
- input.accept = 'image/jpeg, image/png';
169
+ input.accept = 'image/jpeg, image/png, application/pdf';
163
170
  input.addEventListener('change', (event: Event) => {
164
171
  const changeEvent = event as unknown as ChangeEvent<HTMLInputElement>;
165
172
  readFile(changeEvent.target.files).then(
@@ -174,6 +181,7 @@ const imageSchema: Plugin<ImageSchema> = {
174
181
  schema: {},
175
182
  defaultSchema: {
176
183
  type: 'image',
184
+ icon: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-image"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>',
177
185
  content: defaultValue,
178
186
  position: { x: 0, y: 0 },
179
187
  width: 40,
@@ -196,6 +204,7 @@ export const readOnlyImage: Plugin<ImageSchema> = {
196
204
  defaultSchema: {
197
205
  ...imageSchema.propPanel.defaultSchema,
198
206
  type: 'readOnlyImage',
207
+ icon: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-image-off"><line x1="2" x2="22" y1="2" y2="22"/><path d="M10.41 10.41a2 2 0 1 1-2.83-2.83"/><line x1="13.5" x2="6" y1="13.5" y2="21"/><line x1="18" x2="21" y1="12" y2="15"/><path d="M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59"/><path d="M21 15V5a2 2 0 0 0-2-2H9"/></svg>',
199
208
  readOnly: true,
200
209
  },
201
210
  },
@@ -1,5 +1,7 @@
1
1
  // ref: https://github.com/image-size/image-size ----------------------------
2
2
  // The following code is adapted from the image-size code. Unnecessary formats and dependencies on Node have been removed.
3
+ import { Buffer } from 'buffer';
4
+
3
5
  type IImage = {
4
6
  validate: (input: Uint8Array) => boolean;
5
7
  calculate: (input: Uint8Array) => { width: number; height: number } | undefined;
@@ -130,7 +132,14 @@ function detector(input: Uint8Array): imageType | undefined {
130
132
  return keys.find((key: imageType) => typeHandlers[key].validate(input));
131
133
  }
132
134
 
133
- export const imageSize = (imgBuffer: Buffer): { height: number; width: number } => {
135
+ export const getImageDimension = (value: string): { height: number; width: number } => {
136
+ const dataUriPrefix = ';base64,';
137
+ const idx = value.indexOf(dataUriPrefix);
138
+ const imgBase64 = value.substring(idx + dataUriPrefix.length, value.length);
139
+ return imageSize(Buffer.from(imgBase64, 'base64'));
140
+ };
141
+
142
+ const imageSize = (imgBuffer: Buffer): { height: number; width: number } => {
134
143
  const type = detector(imgBuffer);
135
144
 
136
145
  if (typeof type !== 'undefined' && type in typeHandlers) {
@@ -0,0 +1,55 @@
1
+ import { Schema, UIRenderProps } from '@pdfme/common';
2
+ import { getCacheKey } from './cacheKey';
3
+ import { ImageSchema } from './image';
4
+
5
+ export function isPdf(content: string): boolean {
6
+ return content.startsWith('data:application/pdf;');
7
+ }
8
+
9
+ /**
10
+ * convert pdf to blob image url
11
+ * @param content
12
+ */
13
+ export const pdfToImage = async ({
14
+ schema,
15
+ value,
16
+ _cache,
17
+ pdfJs,
18
+ }: UIRenderProps<ImageSchema>): Promise<string> => {
19
+ // using value from cache to prevent rerending pdf to image
20
+ const pdfImageCacheKey = getCacheKey(schema, value);
21
+ const imageSrc = _cache.get(pdfImageCacheKey);
22
+ if (imageSrc) return imageSrc;
23
+
24
+ const pdfDoc = await pdfJs.getDocument({ url: value }).promise;
25
+ const page = await pdfDoc.getPage(1);
26
+
27
+ const canvas = document.createElement('canvas');
28
+ const viewport = page.getViewport({ scale: 1 });
29
+ canvas.width = viewport.width;
30
+ canvas.height = viewport.height;
31
+ const canvasContext = canvas.getContext('2d')!;
32
+
33
+ await page.render({ canvasContext, viewport }).promise;
34
+ const image = await _canvasToObjectUrl(canvas);
35
+
36
+ _cache.set(pdfImageCacheKey, image);
37
+ return image;
38
+ };
39
+
40
+ /**
41
+ * convert canvas to blob url
42
+ * @param canvas
43
+ */
44
+ const _canvasToObjectUrl = async (canvas: HTMLCanvasElement): Promise<string> => {
45
+ return new Promise((resolve, reject) => {
46
+ canvas.toBlob(function (blob) {
47
+ if (!blob) {
48
+ reject('inavlid canvas');
49
+ } else {
50
+ const url = URL.createObjectURL(blob);
51
+ resolve(url);
52
+ }
53
+ });
54
+ });
55
+ };
@@ -73,6 +73,7 @@ const svgSchema: Plugin<SVGSchema> = {
73
73
  schema: {},
74
74
  defaultSchema: {
75
75
  type: 'svg',
76
+ icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-route"><circle cx="6" cy="19" r="3"/><path d="M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15"/><circle cx="18" cy="5" r="3"/></svg>',
76
77
  content: defaultValue,
77
78
  position: { x: 0, y: 0 },
78
79
  width: 40,
@@ -91,6 +92,7 @@ export const readOnlySvg: Plugin<SVGSchema> = {
91
92
  defaultSchema: {
92
93
  ...svgSchema.propPanel.defaultSchema,
93
94
  type: 'readOnlySvg',
95
+ icon: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-route-off"><circle cx="6" cy="19" r="3"/><path d="M9 19h8.5c.4 0 .9-.1 1.3-.2"/><path d="M5.2 5.2A3.5 3.53 0 0 0 6.5 12H12"/><path d="m2 2 20 20"/><path d="M21 15.3a3.5 3.5 0 0 0-3.3-3.3"/><path d="M15 5h-4.3"/><circle cx="18" cy="5" r="3"/></svg>',
94
96
  readOnly: true,
95
97
  },
96
98
  },