@pdfme/schemas 3.1.5-dev.12 → 3.1.5-dev.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.
Files changed (128) hide show
  1. package/dist/cjs/__tests__/renderUtils.test.js +29 -8
  2. package/dist/cjs/__tests__/renderUtils.test.js.map +1 -1
  3. package/dist/cjs/src/barcodes/pdfRender.js +2 -2
  4. package/dist/cjs/src/barcodes/pdfRender.js.map +1 -1
  5. package/dist/cjs/src/barcodes/uiRender.js +3 -3
  6. package/dist/cjs/src/barcodes/uiRender.js.map +1 -1
  7. package/dist/cjs/src/graphics/image.js +122 -0
  8. package/dist/cjs/src/graphics/image.js.map +1 -0
  9. package/dist/cjs/src/index.js +13 -10
  10. package/dist/cjs/src/index.js.map +1 -1
  11. package/dist/cjs/src/{renderUtils.js → pdfRenderUtils.js} +2 -5
  12. package/dist/cjs/src/pdfRenderUtils.js.map +1 -0
  13. package/dist/cjs/src/shapes/line.js +57 -0
  14. package/dist/cjs/src/shapes/line.js.map +1 -0
  15. package/dist/cjs/src/shapes/rectAndEllipse.js +100 -0
  16. package/dist/cjs/src/shapes/rectAndEllipse.js.map +1 -0
  17. package/dist/cjs/src/text/pdfRender.js +5 -5
  18. package/dist/cjs/src/text/pdfRender.js.map +1 -1
  19. package/dist/cjs/src/text/uiRender.js +3 -3
  20. package/dist/cjs/src/text/uiRender.js.map +1 -1
  21. package/dist/cjs/src/uiRenderUtils.js +29 -0
  22. package/dist/cjs/src/uiRenderUtils.js.map +1 -0
  23. package/dist/esm/__tests__/renderUtils.test.js +22 -1
  24. package/dist/esm/__tests__/renderUtils.test.js.map +1 -1
  25. package/dist/esm/src/barcodes/pdfRender.js +1 -1
  26. package/dist/esm/src/barcodes/pdfRender.js.map +1 -1
  27. package/dist/esm/src/barcodes/uiRender.js +1 -1
  28. package/dist/esm/src/barcodes/uiRender.js.map +1 -1
  29. package/dist/esm/src/graphics/image.js +120 -0
  30. package/dist/esm/src/graphics/image.js.map +1 -0
  31. package/dist/esm/src/index.js +5 -4
  32. package/dist/esm/src/index.js.map +1 -1
  33. package/dist/esm/src/{renderUtils.js → pdfRenderUtils.js} +2 -5
  34. package/dist/esm/src/pdfRenderUtils.js.map +1 -0
  35. package/dist/esm/src/shapes/line.js +55 -0
  36. package/dist/esm/src/shapes/line.js.map +1 -0
  37. package/dist/esm/src/shapes/rectAndEllipse.js +97 -0
  38. package/dist/esm/src/shapes/rectAndEllipse.js.map +1 -0
  39. package/dist/esm/src/text/pdfRender.js +1 -1
  40. package/dist/esm/src/text/pdfRender.js.map +1 -1
  41. package/dist/esm/src/text/uiRender.js +1 -1
  42. package/dist/esm/src/text/uiRender.js.map +1 -1
  43. package/dist/esm/src/uiRenderUtils.js +25 -0
  44. package/dist/esm/src/uiRenderUtils.js.map +1 -0
  45. package/dist/types/src/{image/index.d.ts → graphics/image.d.ts} +3 -1
  46. package/dist/types/src/index.d.ts +5 -4
  47. package/dist/types/src/shapes/line.d.ts +6 -0
  48. package/dist/types/src/shapes/rectAndEllipse.d.ts +138 -0
  49. package/dist/types/src/uiRenderUtils.d.ts +1 -0
  50. package/package.json +1 -1
  51. package/src/barcodes/pdfRender.ts +1 -1
  52. package/src/barcodes/uiRender.ts +1 -1
  53. package/src/graphics/image.ts +151 -0
  54. package/src/index.ts +15 -4
  55. package/src/{renderUtils.ts → pdfRenderUtils.ts} +1 -4
  56. package/src/shapes/line.ts +67 -0
  57. package/src/shapes/rectAndEllipse.ts +110 -0
  58. package/src/text/pdfRender.ts +1 -1
  59. package/src/text/uiRender.ts +1 -1
  60. package/src/uiRenderUtils.ts +27 -0
  61. package/dist/cjs/src/image/index.js +0 -8
  62. package/dist/cjs/src/image/index.js.map +0 -1
  63. package/dist/cjs/src/image/pdfRender.js +0 -22
  64. package/dist/cjs/src/image/pdfRender.js.map +0 -1
  65. package/dist/cjs/src/image/propPanel.js +0 -19
  66. package/dist/cjs/src/image/propPanel.js.map +0 -1
  67. package/dist/cjs/src/image/types.js +0 -3
  68. package/dist/cjs/src/image/types.js.map +0 -1
  69. package/dist/cjs/src/image/uiRender.js +0 -113
  70. package/dist/cjs/src/image/uiRender.js.map +0 -1
  71. package/dist/cjs/src/line/constants.js +0 -5
  72. package/dist/cjs/src/line/constants.js.map +0 -1
  73. package/dist/cjs/src/line/index.js +0 -8
  74. package/dist/cjs/src/line/index.js.map +0 -1
  75. package/dist/cjs/src/line/pdfRender.js +0 -20
  76. package/dist/cjs/src/line/pdfRender.js.map +0 -1
  77. package/dist/cjs/src/line/propPanel.js +0 -35
  78. package/dist/cjs/src/line/propPanel.js.map +0 -1
  79. package/dist/cjs/src/line/types.js +0 -3
  80. package/dist/cjs/src/line/types.js.map +0 -1
  81. package/dist/cjs/src/line/uiRender.js +0 -14
  82. package/dist/cjs/src/line/uiRender.js.map +0 -1
  83. package/dist/cjs/src/renderUtils.js.map +0 -1
  84. package/dist/esm/src/image/index.js +0 -6
  85. package/dist/esm/src/image/index.js.map +0 -1
  86. package/dist/esm/src/image/pdfRender.js +0 -18
  87. package/dist/esm/src/image/pdfRender.js.map +0 -1
  88. package/dist/esm/src/image/propPanel.js +0 -16
  89. package/dist/esm/src/image/propPanel.js.map +0 -1
  90. package/dist/esm/src/image/types.js +0 -2
  91. package/dist/esm/src/image/types.js.map +0 -1
  92. package/dist/esm/src/image/uiRender.js +0 -109
  93. package/dist/esm/src/image/uiRender.js.map +0 -1
  94. package/dist/esm/src/line/constants.js +0 -2
  95. package/dist/esm/src/line/constants.js.map +0 -1
  96. package/dist/esm/src/line/index.js +0 -6
  97. package/dist/esm/src/line/index.js.map +0 -1
  98. package/dist/esm/src/line/pdfRender.js +0 -16
  99. package/dist/esm/src/line/pdfRender.js.map +0 -1
  100. package/dist/esm/src/line/propPanel.js +0 -32
  101. package/dist/esm/src/line/propPanel.js.map +0 -1
  102. package/dist/esm/src/line/types.js +0 -2
  103. package/dist/esm/src/line/types.js.map +0 -1
  104. package/dist/esm/src/line/uiRender.js +0 -10
  105. package/dist/esm/src/line/uiRender.js.map +0 -1
  106. package/dist/esm/src/renderUtils.js.map +0 -1
  107. package/dist/types/src/image/pdfRender.d.ts +0 -3
  108. package/dist/types/src/image/propPanel.d.ts +0 -3
  109. package/dist/types/src/image/types.d.ts +0 -3
  110. package/dist/types/src/image/uiRender.d.ts +0 -3
  111. package/dist/types/src/line/constants.d.ts +0 -1
  112. package/dist/types/src/line/index.d.ts +0 -4
  113. package/dist/types/src/line/pdfRender.d.ts +0 -3
  114. package/dist/types/src/line/propPanel.d.ts +0 -3
  115. package/dist/types/src/line/types.d.ts +0 -4
  116. package/dist/types/src/line/uiRender.d.ts +0 -3
  117. package/src/image/index.ts +0 -8
  118. package/src/image/pdfRender.ts +0 -29
  119. package/src/image/propPanel.ts +0 -19
  120. package/src/image/types.ts +0 -3
  121. package/src/image/uiRender.ts +0 -123
  122. package/src/line/constants.ts +0 -1
  123. package/src/line/index.ts +0 -8
  124. package/src/line/pdfRender.ts +0 -24
  125. package/src/line/propPanel.ts +0 -34
  126. package/src/line/types.ts +0 -5
  127. package/src/line/uiRender.ts +0 -12
  128. /package/dist/types/src/{renderUtils.d.ts → pdfRenderUtils.d.ts} +0 -0
@@ -1,7 +1,7 @@
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
3
  import { calculateDynamicFontSize, getFontKitFont, getBrowserVerticalFontAdjustments, } from './helper.js';
4
- import { addAlphaToHex, isEditable } from '../renderUtils.js';
4
+ import { addAlphaToHex, isEditable } from '../pdfRenderUtils.js';
5
5
  const mapVerticalAlignToFlex = (verticalAlignmentValue) => {
6
6
  switch (verticalAlignmentValue) {
7
7
  case VERTICAL_ALIGN_TOP:
@@ -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,iCAAiC,GAClC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,sBAAsB,GAAG,CAAC,sBAA0C,EAAE,EAAE;IAC5E,QAAQ,sBAAsB,EAAE;QAC9B,KAAK,kBAAkB;YACrB,OAAO,YAAY,CAAC;QACtB,KAAK,qBAAqB;YACxB,OAAO,QAAQ,CAAC;QAClB,KAAK,qBAAqB;YACxB,OAAO,UAAU,CAAC;KACrB;IACD,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAE,MAAc,EAAE,sBAA8B,EAAE,EAAE;IAC3F,IAAI,CAAC,KAAK;QAAE,OAAO,aAAa,CAAC;IACjC,IAAI,MAAM,CAAC,eAAe;QAAE,OAAO,MAAM,CAAC,eAAyB,CAAC;IACpE,OAAO,sBAAsB,CAAC;AAChC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,GAA8B,EAAE,EAAE;IAC/D,MAAM,EACJ,KAAK,EACL,MAAM,EACN,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,WAAW,EACX,OAAO,EACP,KAAK,EACL,MAAM,GACP,GAAG,GAAG,CAAC;IACR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A,IAAI,CAAC,EAAE,CAAC,CAAC;QAEZ,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;KAClC;AACH,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ export const readFile = (input) => new Promise((resolve, reject) => {
2
+ const fileReader = new FileReader();
3
+ fileReader.onload = (e) => {
4
+ if (e.target?.result) {
5
+ resolve(e.target.result);
6
+ }
7
+ };
8
+ fileReader.onerror = (e) => {
9
+ reject(new Error('[@pdfme/schemas] File reading failed'));
10
+ };
11
+ let file = null;
12
+ if (input instanceof FileList && input.length > 0) {
13
+ file = input[0];
14
+ }
15
+ else if (input instanceof File) {
16
+ file = input;
17
+ }
18
+ if (file) {
19
+ fileReader.readAsDataURL(file);
20
+ }
21
+ else {
22
+ reject(new Error('[@pdfme/schemas] No files provided'));
23
+ }
24
+ });
25
+ //# sourceMappingURL=uiRenderUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uiRenderUtils.js","sourceRoot":"","sources":["../../../src/uiRenderUtils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAA6B,EAAiC,EAAE,CACvF,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IAC9B,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;IAEpC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE;QACxB,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE;YACpB,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SAC1B;IACH,CAAC,CAAC;IAEF,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE,EAAE;QACzB,MAAM,CAAC,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC;IAEF,IAAI,IAAI,GAAgB,IAAI,CAAC;IAC7B,IAAI,KAAK,YAAY,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QACjD,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;KACjB;SAAM,IAAI,KAAK,YAAY,IAAI,EAAE;QAChC,IAAI,GAAG,KAAK,CAAC;KACd;IAED,IAAI,IAAI,EAAE;QACR,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;KAChC;SAAM;QACL,MAAM,CAAC,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC,CAAC;KACzD;AACH,CAAC,CAAC,CAAC"}
@@ -1,4 +1,6 @@
1
1
  import type { Plugin } from '@pdfme/common';
2
- import type { ImageSchema } from './types';
2
+ import type { Schema } from '@pdfme/common';
3
+ interface ImageSchema extends Schema {
4
+ }
3
5
  declare const schema: Plugin<ImageSchema>;
4
6
  export default schema;
@@ -1,9 +1,10 @@
1
1
  import text from './text/index.js';
2
- import image from './image/index.js';
2
+ import image from './graphics/image.js';
3
3
  import barcodes from './barcodes/index.js';
4
- import line from './line/index.js';
5
- import { convertForPdfLayoutProps, rotatePoint } from './renderUtils.js';
4
+ import line from './shapes/line.js';
5
+ import { rectangle, ellipse } from './shapes/rectAndEllipse.js';
6
+ import { convertForPdfLayoutProps, rotatePoint } from './pdfRenderUtils.js';
6
7
  declare const builtInPlugins: {
7
8
  Text: import("@pdfme/common").Plugin<import("./text/types.js").TextSchema>;
8
9
  };
9
- export { text, image, barcodes, line, builtInPlugins, convertForPdfLayoutProps, rotatePoint };
10
+ export { text, image, barcodes, line, rectangle, ellipse, builtInPlugins, convertForPdfLayoutProps, rotatePoint, };
@@ -0,0 +1,6 @@
1
+ import type { Schema, Plugin } from '@pdfme/common';
2
+ interface LineSchema extends Schema {
3
+ color: string;
4
+ }
5
+ declare const schema: Plugin<LineSchema>;
6
+ export default schema;
@@ -0,0 +1,138 @@
1
+ import { Schema } from '@pdfme/common';
2
+ interface Shape extends Schema {
3
+ type: 'ellipse' | 'rectangle';
4
+ borderWidth: number;
5
+ borderColor: string;
6
+ color: string;
7
+ }
8
+ export declare const rectangle: {
9
+ propPanel: {
10
+ defaultSchema: {
11
+ type: "ellipse" | "rectangle";
12
+ borderWidth: number;
13
+ borderColor: string;
14
+ color: string;
15
+ position: {
16
+ x: number;
17
+ y: number;
18
+ };
19
+ width: number;
20
+ height: number;
21
+ readOnly?: boolean | undefined;
22
+ rotate?: number | undefined;
23
+ opacity?: number | undefined;
24
+ };
25
+ schema: ((propPanelProps: Omit<{
26
+ rootElement: HTMLDivElement;
27
+ activeSchema: {
28
+ width: number;
29
+ height: number;
30
+ type: string;
31
+ position: {
32
+ x: number;
33
+ y: number;
34
+ };
35
+ data: string;
36
+ id: string;
37
+ key: string;
38
+ opacity?: number | undefined;
39
+ rotate?: number | undefined;
40
+ readOnly?: boolean | undefined;
41
+ };
42
+ activeElements: HTMLElement[];
43
+ changeSchemas: import("@pdfme/common").ChangeSchemas;
44
+ schemas: {
45
+ width: number;
46
+ height: number;
47
+ type: string;
48
+ position: {
49
+ x: number;
50
+ y: number;
51
+ };
52
+ data: string;
53
+ id: string;
54
+ key: string;
55
+ opacity?: number | undefined;
56
+ rotate?: number | undefined;
57
+ readOnly?: boolean | undefined;
58
+ }[];
59
+ pageSize: {
60
+ width: number;
61
+ height: number;
62
+ };
63
+ options: import("@pdfme/common").UIOptions;
64
+ theme: import("antd").GlobalToken;
65
+ i18n: (key: string) => string;
66
+ }, "rootElement">) => Record<string, Partial<import("form-render").SchemaBase>>) | Record<string, Partial<import("form-render").SchemaBase>>;
67
+ widgets?: Record<string, (props: import("@pdfme/common").PropPanelWidgetProps) => void> | undefined;
68
+ defaultValue: string;
69
+ };
70
+ pdf: (arg: import("@pdfme/common").PDFRenderProps<Shape>) => void | Promise<void>;
71
+ ui: (arg: import("@pdfme/common").UIRenderProps<Shape>) => void | Promise<void>;
72
+ };
73
+ export declare const ellipse: {
74
+ propPanel: {
75
+ defaultSchema: {
76
+ type: "ellipse" | "rectangle";
77
+ borderWidth: number;
78
+ borderColor: string;
79
+ color: string;
80
+ position: {
81
+ x: number;
82
+ y: number;
83
+ };
84
+ width: number;
85
+ height: number;
86
+ readOnly?: boolean | undefined;
87
+ rotate?: number | undefined;
88
+ opacity?: number | undefined;
89
+ };
90
+ schema: ((propPanelProps: Omit<{
91
+ rootElement: HTMLDivElement;
92
+ activeSchema: {
93
+ width: number;
94
+ height: number;
95
+ type: string;
96
+ position: {
97
+ x: number;
98
+ y: number;
99
+ };
100
+ data: string;
101
+ id: string;
102
+ key: string;
103
+ opacity?: number | undefined;
104
+ rotate?: number | undefined;
105
+ readOnly?: boolean | undefined;
106
+ };
107
+ activeElements: HTMLElement[];
108
+ changeSchemas: import("@pdfme/common").ChangeSchemas;
109
+ schemas: {
110
+ width: number;
111
+ height: number;
112
+ type: string;
113
+ position: {
114
+ x: number;
115
+ y: number;
116
+ };
117
+ data: string;
118
+ id: string;
119
+ key: string;
120
+ opacity?: number | undefined;
121
+ rotate?: number | undefined;
122
+ readOnly?: boolean | undefined;
123
+ }[];
124
+ pageSize: {
125
+ width: number;
126
+ height: number;
127
+ };
128
+ options: import("@pdfme/common").UIOptions;
129
+ theme: import("antd").GlobalToken;
130
+ i18n: (key: string) => string;
131
+ }, "rootElement">) => Record<string, Partial<import("form-render").SchemaBase>>) | Record<string, Partial<import("form-render").SchemaBase>>;
132
+ widgets?: Record<string, (props: import("@pdfme/common").PropPanelWidgetProps) => void> | undefined;
133
+ defaultValue: string;
134
+ };
135
+ pdf: (arg: import("@pdfme/common").PDFRenderProps<Shape>) => void | Promise<void>;
136
+ ui: (arg: import("@pdfme/common").UIRenderProps<Shape>) => void | Promise<void>;
137
+ };
138
+ export {};
@@ -0,0 +1 @@
1
+ export declare const readFile: (input: File | FileList | null) => Promise<string | ArrayBuffer>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/schemas",
3
- "version": "3.1.5-dev.12",
3
+ "version": "3.1.5-dev.14",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
@@ -1,5 +1,5 @@
1
1
  import { PDFRenderProps } from '@pdfme/common';
2
- import { convertForPdfLayoutProps } from '../renderUtils.js';
2
+ import { convertForPdfLayoutProps } from '../pdfRenderUtils.js';
3
3
  import type { BarcodeSchema } from './types';
4
4
  import { createBarCode, validateBarcodeInput } from './helper.js';
5
5
 
@@ -2,7 +2,7 @@ import type * as CSS from 'csstype';
2
2
  import { UIRenderProps } from '@pdfme/common';
3
3
  import type { BarcodeSchema } from './types';
4
4
  import { validateBarcodeInput, createBarCode } from './helper.js';
5
- import { addAlphaToHex, isEditable } from '../renderUtils.js';
5
+ import { addAlphaToHex, isEditable } from '../pdfRenderUtils.js';
6
6
 
7
7
  const fullSize = { width: '100%', height: '100%' };
8
8
 
@@ -0,0 +1,151 @@
1
+ import type { ChangeEvent } from 'react';
2
+ import type { Plugin } from '@pdfme/common';
3
+ import type { PDFRenderProps, Schema } from '@pdfme/common';
4
+ import type * as CSS from 'csstype';
5
+ import { UIRenderProps, ZOOM } from '@pdfme/common';
6
+ import { convertForPdfLayoutProps, addAlphaToHex, isEditable } from '../pdfRenderUtils.js';
7
+ import { readFile } from '../uiRenderUtils.js';
8
+ import { DEFAULT_OPACITY } from '../constants.js';
9
+
10
+ const getCacheKey = (schema: Schema, input: string) => `${schema.type}${input}`;
11
+ const fullSize = { width: '100%', height: '100%' };
12
+ const defaultValue =
13
+ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAu4AAALuAQMAAADL0wGJAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAGUExURbzAw+rv8fKruy0AAAPoSURBVHja7dwxbtwwEEBRCkKwRQodYftcYk+ROkcJz5NTsEuZK/AIKlIQAUEnke0VqQ0pA5zxWvFnZcD2s0CNuENxPOZBc0QDDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8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h4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHl+d/A9cKjmiL040TAAAAAElFTkSuQmCC';
14
+
15
+ interface ImageSchema extends Schema {}
16
+
17
+ const schema: Plugin<ImageSchema> = {
18
+ pdf: async (arg: PDFRenderProps<ImageSchema>) => {
19
+ const { value, schema, pdfDoc, page, _cache } = arg;
20
+ if (!value || !value.startsWith('data:image/')) return;
21
+
22
+ const inputImageCacheKey = getCacheKey(schema, value);
23
+ let image = _cache.get(inputImageCacheKey);
24
+ if (!image) {
25
+ const isPng = value.startsWith('data:image/png;');
26
+ image = await (isPng ? pdfDoc.embedPng(value) : pdfDoc.embedJpg(value));
27
+ _cache.set(inputImageCacheKey, image);
28
+ }
29
+
30
+ const pageHeight = page.getHeight();
31
+ const {
32
+ width,
33
+ height,
34
+ rotate,
35
+ position: { x, y },
36
+ opacity,
37
+ } = convertForPdfLayoutProps({ schema, pageHeight });
38
+
39
+ page.drawImage(image, { x, y, rotate, width, height, opacity });
40
+ },
41
+ ui: (arg: UIRenderProps<ImageSchema>) => {
42
+ const {
43
+ value,
44
+ rootElement,
45
+ mode,
46
+ onChange,
47
+ stopEditing,
48
+ tabIndex,
49
+ placeholder,
50
+ schema,
51
+ theme,
52
+ } = arg;
53
+ const editable = isEditable(mode);
54
+ const isDefault = value === defaultValue;
55
+
56
+ const size = { width: schema.width * ZOOM, height: schema.height * ZOOM };
57
+
58
+ const container = document.createElement('div');
59
+ const backgroundStyle = placeholder ? `url(${placeholder})` : 'none';
60
+ const containerStyle: CSS.Properties = {
61
+ ...fullSize,
62
+ backgroundImage: value ? 'none' : backgroundStyle,
63
+ backgroundSize: `${size.width}px ${size.height}px`,
64
+ };
65
+ Object.assign(container.style, containerStyle);
66
+ container.addEventListener('click', (e) => {
67
+ if (editable) {
68
+ e.stopPropagation();
69
+ }
70
+ });
71
+ rootElement.appendChild(container);
72
+
73
+ // image tag
74
+ if (value) {
75
+ const img = document.createElement('img');
76
+ const imgStyle: CSS.Properties = { height: '100%', width: '100%', borderRadius: 0 };
77
+ Object.assign(img.style, imgStyle);
78
+ img.src = value;
79
+ container.appendChild(img);
80
+ }
81
+
82
+ // remove button
83
+ if (value && !isDefault && editable) {
84
+ const button = document.createElement('button');
85
+ button.textContent = 'x';
86
+ const buttonStyle: CSS.Properties = {
87
+ position: 'absolute',
88
+ top: 0,
89
+ left: 0,
90
+ zIndex: 1,
91
+ display: 'flex',
92
+ justifyContent: 'center',
93
+ alignItems: 'center',
94
+ color: '#333',
95
+ background: '#f2f2f2',
96
+ borderRadius: '2px',
97
+ border: '1px solid #767676',
98
+ cursor: 'pointer',
99
+ height: '24px',
100
+ width: '24px',
101
+ };
102
+ Object.assign(button.style, buttonStyle);
103
+ button.addEventListener('click', () => {
104
+ onChange && onChange('');
105
+ });
106
+ container.appendChild(button);
107
+ }
108
+
109
+ // file input
110
+ if ((!value || isDefault) && editable) {
111
+ const label = document.createElement('label');
112
+ const labelStyle: CSS.Properties = {
113
+ ...fullSize,
114
+ display: editable ? 'flex' : 'none',
115
+ position: 'absolute',
116
+ top: 0,
117
+ backgroundColor: editable || value ? addAlphaToHex(theme.colorPrimaryBg, 30) : 'none',
118
+ cursor: 'pointer',
119
+ };
120
+ Object.assign(label.style, labelStyle);
121
+ container.appendChild(label);
122
+ const input = document.createElement('input');
123
+ const inputStyle: CSS.Properties = { ...fullSize, position: 'absolute', top: '50%' };
124
+ Object.assign(input.style, inputStyle);
125
+ input.tabIndex = tabIndex || 0;
126
+ input.type = 'file';
127
+ input.accept = 'image/jpeg, image/png';
128
+ input.addEventListener('change', (event: Event) => {
129
+ const changeEvent = event as unknown as ChangeEvent<HTMLInputElement>;
130
+ readFile(changeEvent.target.files).then((result) => onChange && onChange(result as string));
131
+ });
132
+ input.addEventListener('blur', () => stopEditing && stopEditing());
133
+ label.appendChild(input);
134
+ }
135
+ },
136
+ propPanel: {
137
+ schema: {},
138
+ defaultValue,
139
+ defaultSchema: {
140
+ type: 'image',
141
+ position: { x: 0, y: 0 },
142
+ width: 40,
143
+ height: 40,
144
+ // If the value of "rotate" is set to undefined or not set at all, rotation will be disabled in the UI.
145
+ // Check this document: https://pdfme.com//docs/custom-schemas#learning-how-to-create-from-pdfmeschemas-code
146
+ rotate: 0,
147
+ opacity: DEFAULT_OPACITY,
148
+ },
149
+ },
150
+ };
151
+ export default schema;
package/src/index.ts CHANGED
@@ -1,9 +1,20 @@
1
1
  import text from './text/index.js';
2
- import image from './image/index.js';
2
+ import image from './graphics/image.js';
3
3
  import barcodes from './barcodes/index.js';
4
- import line from './line/index.js';
5
- import { convertForPdfLayoutProps, rotatePoint } from './renderUtils.js';
4
+ import line from './shapes/line.js';
5
+ import { rectangle, ellipse } from './shapes/rectAndEllipse.js';
6
+ import { convertForPdfLayoutProps, rotatePoint } from './pdfRenderUtils.js';
6
7
 
7
8
  const builtInPlugins = { Text: text };
8
9
 
9
- export { text, image, barcodes, line, builtInPlugins, convertForPdfLayoutProps, rotatePoint };
10
+ export {
11
+ text,
12
+ image,
13
+ barcodes,
14
+ line,
15
+ rectangle,
16
+ ellipse,
17
+ builtInPlugins,
18
+ convertForPdfLayoutProps,
19
+ rotatePoint,
20
+ };
@@ -32,10 +32,7 @@ export const convertForPdfLayoutProps = ({
32
32
  }
33
33
 
34
34
  return {
35
- position: {
36
- x: x,
37
- y: y,
38
- },
35
+ position: { x, y },
39
36
  height: height,
40
37
  width: width,
41
38
  rotate: degrees(rotateDegrees),
@@ -0,0 +1,67 @@
1
+ import type { Schema, Plugin, PDFRenderProps, UIRenderProps } from '@pdfme/common';
2
+ import { rotatePoint, convertForPdfLayoutProps, hex2RgbColor } from '../pdfRenderUtils.js';
3
+ import { HEX_COLOR_PATTERN } from '../constants.js';
4
+
5
+ const DEFAULT_LINE_COLOR = '#000000';
6
+
7
+ interface LineSchema extends Schema {
8
+ color: string;
9
+ }
10
+
11
+ const schema: Plugin<LineSchema> = {
12
+ pdf: (arg: PDFRenderProps<LineSchema>) => {
13
+ const { page, schema } = arg;
14
+ const pageHeight = page.getHeight();
15
+ const {
16
+ width,
17
+ height,
18
+ rotate,
19
+ position: { x, y },
20
+ opacity,
21
+ } = convertForPdfLayoutProps({ schema, pageHeight, applyRotateTranslate: false });
22
+ const pivot = { x: x + width / 2, y: y + height / 2 };
23
+ page.drawLine({
24
+ start: rotatePoint({ x, y: y + height / 2 }, pivot, rotate.angle),
25
+ end: rotatePoint({ x: x + width, y: y + height / 2 }, pivot, rotate.angle),
26
+ thickness: height,
27
+ color: hex2RgbColor(schema.color ?? DEFAULT_LINE_COLOR),
28
+ opacity: opacity,
29
+ });
30
+ },
31
+ ui: (arg: UIRenderProps<LineSchema>) => {
32
+ const { schema, rootElement } = arg;
33
+ const div = document.createElement('div');
34
+ div.style.backgroundColor = schema.color ?? DEFAULT_LINE_COLOR;
35
+ div.style.width = '100%';
36
+ div.style.height = '100%';
37
+ rootElement.appendChild(div);
38
+ },
39
+ propPanel: {
40
+ schema: ({ i18n }) => ({
41
+ color: {
42
+ title: i18n('schemas.color'),
43
+ type: 'string',
44
+ widget: 'color',
45
+ required: true,
46
+ rules: [
47
+ {
48
+ pattern: HEX_COLOR_PATTERN,
49
+ message: i18n('hexColorPrompt'),
50
+ },
51
+ ],
52
+ },
53
+ }),
54
+ defaultValue: '',
55
+ defaultSchema: {
56
+ type: 'line',
57
+ position: { x: 0, y: 0 },
58
+ width: 50,
59
+ height: 1,
60
+ rotate: 0,
61
+ opacity: 1,
62
+ readOnly: true,
63
+ color: DEFAULT_LINE_COLOR,
64
+ },
65
+ },
66
+ };
67
+ export default schema;
@@ -0,0 +1,110 @@
1
+ import { Plugin, Schema, mm2pt } from '@pdfme/common';
2
+ import { HEX_COLOR_PATTERN } from '../constants.js';
3
+ import { hex2RgbColor, convertForPdfLayoutProps } from '../pdfRenderUtils.js';
4
+
5
+ interface Shape extends Schema {
6
+ type: 'ellipse' | 'rectangle';
7
+ borderWidth: number;
8
+ borderColor: string;
9
+ color: string;
10
+ }
11
+
12
+ const shape: Plugin<Shape> = {
13
+ ui: (arg) => {
14
+ const { schema, rootElement } = arg;
15
+ const div = document.createElement('div');
16
+ div.style.width = '100%';
17
+ div.style.height = '100%';
18
+ div.style.boxSizing = 'border-box';
19
+ if (schema.type === 'ellipse') {
20
+ div.style.borderRadius = '50%';
21
+ }
22
+ div.style.borderWidth = `${schema.borderWidth ?? 0}mm`;
23
+ div.style.borderStyle = schema.borderWidth && schema.borderColor ? 'solid' : 'none';
24
+ div.style.borderColor = schema.borderColor ?? 'transparent';
25
+ div.style.backgroundColor = schema.color ?? 'transparent';
26
+
27
+ rootElement.appendChild(div);
28
+ },
29
+ pdf: (arg) => {
30
+ const { schema, page } = arg;
31
+ const pageHeight = page.getHeight();
32
+ const cArg = { schema, pageHeight };
33
+ const { position, width, height, rotate, opacity } = convertForPdfLayoutProps(cArg);
34
+ const {
35
+ position: { x: x4Ellipse, y: y4Ellipse },
36
+ } = convertForPdfLayoutProps({ ...cArg, applyRotateTranslate: false });
37
+ const borderWidth = schema.borderWidth ? mm2pt(schema.borderWidth) : 0;
38
+
39
+ const drawOptions = {
40
+ rotate,
41
+ borderWidth,
42
+ borderColor: hex2RgbColor(schema.borderColor),
43
+ color: hex2RgbColor(schema.color),
44
+ opacity,
45
+ borderOpacity: opacity,
46
+ };
47
+ if (schema.type === 'ellipse') {
48
+ page.drawEllipse({
49
+ x: x4Ellipse + width / 2,
50
+ y: y4Ellipse + height / 2,
51
+ xScale: width / 2 - borderWidth / 2,
52
+ yScale: height / 2 - borderWidth / 2,
53
+ ...drawOptions,
54
+ });
55
+ } else if (schema.type === 'rectangle') {
56
+ page.drawRectangle({
57
+ x: position.x + borderWidth / 2,
58
+ y: position.y + borderWidth / 2,
59
+ width: width - borderWidth,
60
+ height: height - borderWidth,
61
+ ...drawOptions,
62
+ });
63
+ }
64
+ },
65
+ propPanel: {
66
+ schema: ({ i18n }) => ({
67
+ borderWidth: {
68
+ title: i18n('schemas.borderWidth'),
69
+ type: 'number',
70
+ widget: 'inputNumber',
71
+ min: 0,
72
+ step: 1,
73
+ },
74
+ borderColor: {
75
+ title: i18n('schemas.borderColor'),
76
+ type: 'string',
77
+ widget: 'color',
78
+ rules: [{ pattern: HEX_COLOR_PATTERN, message: i18n('hexColorPrompt') }],
79
+ },
80
+ color: {
81
+ title: i18n('schemas.color'),
82
+ type: 'string',
83
+ widget: 'color',
84
+ rules: [{ pattern: HEX_COLOR_PATTERN, message: i18n('hexColorPrompt') }],
85
+ },
86
+ }),
87
+ defaultValue: '',
88
+ defaultSchema: {
89
+ type: 'rectangle',
90
+ position: { x: 0, y: 0 },
91
+ width: 62.5,
92
+ height: 37.5,
93
+ rotate: 0,
94
+ opacity: 1,
95
+ borderWidth: 5,
96
+ borderColor: '#000000',
97
+ color: '#ffffff',
98
+ readOnly: true,
99
+ },
100
+ },
101
+ };
102
+
103
+ const getPropPanelSchema = (type: 'rectangle' | 'ellipse') => ({
104
+ ...shape.propPanel,
105
+ defaultSchema: { ...shape.propPanel.defaultSchema, type },
106
+ });
107
+
108
+ export const rectangle = { ...shape, propPanel: getPropPanelSchema('rectangle') };
109
+
110
+ export const ellipse = { ...shape, propPanel: getPropPanelSchema('ellipse') };
@@ -20,7 +20,7 @@ import {
20
20
  getSplittedLines,
21
21
  widthOfTextAtSize,
22
22
  } from './helper.js';
23
- import { convertForPdfLayoutProps, rotatePoint, hex2RgbColor } from '../renderUtils.js';
23
+ import { convertForPdfLayoutProps, rotatePoint, hex2RgbColor } from '../pdfRenderUtils.js';
24
24
 
25
25
  const embedAndGetFontObj = async (arg: {
26
26
  pdfDoc: PDFDocument;
@@ -18,7 +18,7 @@ import {
18
18
  getFontKitFont,
19
19
  getBrowserVerticalFontAdjustments,
20
20
  } from './helper.js';
21
- import { addAlphaToHex, isEditable } from '../renderUtils.js';
21
+ import { addAlphaToHex, isEditable } from '../pdfRenderUtils.js';
22
22
 
23
23
  const mapVerticalAlignToFlex = (verticalAlignmentValue: string | undefined) => {
24
24
  switch (verticalAlignmentValue) {