@pdfme/schemas 3.1.5-dev.14 → 3.1.5-dev.16

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 (99) hide show
  1. package/dist/cjs/__tests__/{renderUtils.test.js → utils.test.js} +22 -17
  2. package/dist/cjs/__tests__/utils.test.js.map +1 -0
  3. package/dist/cjs/src/barcodes/index.js +2 -2
  4. package/dist/cjs/src/barcodes/index.js.map +1 -1
  5. package/dist/cjs/src/barcodes/pdfRender.js +2 -2
  6. package/dist/cjs/src/barcodes/pdfRender.js.map +1 -1
  7. package/dist/cjs/src/barcodes/propPanel.js +1 -1
  8. package/dist/cjs/src/barcodes/propPanel.js.map +1 -1
  9. package/dist/cjs/src/barcodes/uiRender.js +5 -29
  10. package/dist/cjs/src/barcodes/uiRender.js.map +1 -1
  11. package/dist/cjs/src/graphics/helper.js +115 -0
  12. package/dist/cjs/src/graphics/helper.js.map +1 -0
  13. package/dist/cjs/src/graphics/image.js +72 -15
  14. package/dist/cjs/src/graphics/image.js.map +1 -1
  15. package/dist/cjs/src/graphics/svg.js +96 -0
  16. package/dist/cjs/src/graphics/svg.js.map +1 -0
  17. package/dist/cjs/src/index.js +34 -6
  18. package/dist/cjs/src/index.js.map +1 -1
  19. package/dist/cjs/src/shapes/line.js +7 -7
  20. package/dist/cjs/src/shapes/line.js.map +1 -1
  21. package/dist/cjs/src/shapes/rectAndEllipse.js +5 -5
  22. package/dist/cjs/src/shapes/rectAndEllipse.js.map +1 -1
  23. package/dist/cjs/src/text/helper.js.map +1 -1
  24. package/dist/cjs/src/text/index.js +16 -2
  25. package/dist/cjs/src/text/index.js.map +1 -1
  26. package/dist/cjs/src/text/pdfRender.js +5 -5
  27. package/dist/cjs/src/text/pdfRender.js.map +1 -1
  28. package/dist/cjs/src/text/uiRender.js +3 -3
  29. package/dist/cjs/src/text/uiRender.js.map +1 -1
  30. package/dist/cjs/src/{pdfRenderUtils.js → utils.js} +54 -3
  31. package/dist/cjs/src/utils.js.map +1 -0
  32. package/dist/esm/__tests__/{renderUtils.test.js → utils.test.js} +14 -9
  33. package/dist/esm/__tests__/utils.test.js.map +1 -0
  34. package/dist/esm/src/barcodes/index.js +2 -2
  35. package/dist/esm/src/barcodes/index.js.map +1 -1
  36. package/dist/esm/src/barcodes/pdfRender.js +1 -1
  37. package/dist/esm/src/barcodes/pdfRender.js.map +1 -1
  38. package/dist/esm/src/barcodes/propPanel.js +1 -1
  39. package/dist/esm/src/barcodes/propPanel.js.map +1 -1
  40. package/dist/esm/src/barcodes/uiRender.js +4 -28
  41. package/dist/esm/src/barcodes/uiRender.js.map +1 -1
  42. package/dist/esm/src/graphics/helper.js +111 -0
  43. package/dist/esm/src/graphics/helper.js.map +1 -0
  44. package/dist/esm/src/graphics/image.js +69 -13
  45. package/dist/esm/src/graphics/image.js.map +1 -1
  46. package/dist/esm/src/graphics/svg.js +93 -0
  47. package/dist/esm/src/graphics/svg.js.map +1 -0
  48. package/dist/esm/src/index.js +5 -4
  49. package/dist/esm/src/index.js.map +1 -1
  50. package/dist/esm/src/shapes/line.js +3 -3
  51. package/dist/esm/src/shapes/line.js.map +1 -1
  52. package/dist/esm/src/shapes/rectAndEllipse.js +1 -1
  53. package/dist/esm/src/shapes/rectAndEllipse.js.map +1 -1
  54. package/dist/esm/src/text/helper.js.map +1 -1
  55. package/dist/esm/src/text/index.js +15 -2
  56. package/dist/esm/src/text/index.js.map +1 -1
  57. package/dist/esm/src/text/pdfRender.js +1 -1
  58. package/dist/esm/src/text/pdfRender.js.map +1 -1
  59. package/dist/esm/src/text/uiRender.js +2 -2
  60. package/dist/esm/src/text/uiRender.js.map +1 -1
  61. package/dist/esm/src/{pdfRenderUtils.js → utils.js} +51 -2
  62. package/dist/esm/src/utils.js.map +1 -0
  63. package/dist/types/src/barcodes/index.d.ts +2 -2
  64. package/dist/types/src/graphics/helper.d.ts +5 -0
  65. package/dist/types/src/graphics/image.d.ts +3 -2
  66. package/dist/types/src/graphics/svg.d.ts +6 -0
  67. package/dist/types/src/index.d.ts +5 -4
  68. package/dist/types/src/shapes/line.d.ts +2 -2
  69. package/dist/types/src/shapes/rectAndEllipse.d.ts +6 -0
  70. package/dist/types/src/text/index.d.ts +3 -2
  71. package/dist/types/src/text/pdfRender.d.ts +1 -1
  72. package/dist/types/src/{pdfRenderUtils.d.ts → utils.d.ts} +3 -1
  73. package/package.json +4 -3
  74. package/src/barcodes/index.ts +2 -2
  75. package/src/barcodes/pdfRender.ts +1 -1
  76. package/src/barcodes/propPanel.ts +1 -1
  77. package/src/barcodes/uiRender.ts +4 -32
  78. package/src/graphics/helper.ts +147 -0
  79. package/src/graphics/image.ts +78 -22
  80. package/src/graphics/svg.ts +98 -0
  81. package/src/index.ts +8 -3
  82. package/src/shapes/line.ts +3 -3
  83. package/src/shapes/rectAndEllipse.ts +1 -1
  84. package/src/text/helper.ts +0 -1
  85. package/src/text/index.ts +17 -2
  86. package/src/text/pdfRender.ts +2 -2
  87. package/src/text/uiRender.ts +2 -2
  88. package/src/{pdfRenderUtils.ts → utils.ts} +60 -1
  89. package/dist/cjs/__tests__/renderUtils.test.js.map +0 -1
  90. package/dist/cjs/src/pdfRenderUtils.js.map +0 -1
  91. package/dist/cjs/src/uiRenderUtils.js +0 -29
  92. package/dist/cjs/src/uiRenderUtils.js.map +0 -1
  93. package/dist/esm/__tests__/renderUtils.test.js.map +0 -1
  94. package/dist/esm/src/pdfRenderUtils.js.map +0 -1
  95. package/dist/esm/src/uiRenderUtils.js +0 -25
  96. package/dist/esm/src/uiRenderUtils.js.map +0 -1
  97. package/dist/types/src/uiRenderUtils.d.ts +0 -1
  98. package/src/uiRenderUtils.ts +0 -27
  99. /package/dist/types/__tests__/{renderUtils.test.d.ts → utils.test.d.ts} +0 -0
@@ -0,0 +1,147 @@
1
+ // ref: https://github.com/image-size/image-size ----------------------------
2
+ // The following code is adapted from the image-size code. Unnecessary formats and dependencies on Node have been removed.
3
+ type IImage = {
4
+ validate: (input: Uint8Array) => boolean;
5
+ calculate: (input: Uint8Array) => { width: number; height: number } | undefined;
6
+ };
7
+
8
+ const decoder = new TextDecoder();
9
+ const toUTF8String = (input: Uint8Array, start = 0, end = input.length) =>
10
+ decoder.decode(input.slice(start, end));
11
+
12
+ const toHexString = (input: Uint8Array, start = 0, end = input.length) =>
13
+ input.slice(start, end).reduce((memo, i) => memo + ('0' + i.toString(16)).slice(-2), '');
14
+
15
+ const readUInt16BE = (input: Uint8Array, offset = 0) => input[offset] * 2 ** 8 + input[offset + 1];
16
+
17
+ const readUInt32BE = (input: Uint8Array, offset = 0) =>
18
+ input[offset] * 2 ** 24 +
19
+ input[offset + 1] * 2 ** 16 +
20
+ input[offset + 2] * 2 ** 8 +
21
+ input[offset + 3];
22
+
23
+ const extractSize = (input: Uint8Array, index: number) => {
24
+ return {
25
+ height: readUInt16BE(input, index),
26
+ width: readUInt16BE(input, index + 2),
27
+ };
28
+ };
29
+
30
+ const validateInput = (input: Uint8Array, index: number): void => {
31
+ // index should be within buffer limits
32
+ if (index > input.length) {
33
+ throw new TypeError('Corrupt JPG, exceeded buffer limits');
34
+ }
35
+ // Every JPEG block must begin with a 0xFF
36
+ if (input[index] !== 0xff) {
37
+ throw new TypeError('Invalid JPG, marker table corrupted');
38
+ }
39
+ };
40
+
41
+ const JPG: IImage = {
42
+ validate: (input) => toHexString(input, 0, 2) === 'ffd8',
43
+
44
+ calculate(input) {
45
+ // Skip 4 chars, they are for signature
46
+ input = input.slice(4);
47
+
48
+ let next: number;
49
+ while (input.length) {
50
+ // read length of the next block
51
+ const i = readUInt16BE(input, 0);
52
+
53
+ // ensure correct format
54
+ validateInput(input, i);
55
+
56
+ // 0xFFC0 is baseline standard(SOF)
57
+ // 0xFFC1 is baseline optimized(SOF)
58
+ // 0xFFC2 is progressive(SOF2)
59
+ next = input[i + 1];
60
+ if (next === 0xc0 || next === 0xc1 || next === 0xc2) {
61
+ const size = extractSize(input, i + 5);
62
+
63
+ return size;
64
+ }
65
+
66
+ // move to the next block
67
+ input = input.slice(i + 2);
68
+ }
69
+
70
+ throw new TypeError('Invalid JPG, no size found');
71
+ },
72
+ };
73
+
74
+ const pngSignature = 'PNG\r\n\x1a\n';
75
+ const pngImageHeaderChunkName = 'IHDR';
76
+
77
+ // Used to detect "fried" png's: http://www.jongware.com/pngdefry.html
78
+ const pngFriedChunkName = 'CgBI';
79
+
80
+ const PNG: IImage = {
81
+ validate(input) {
82
+ if (pngSignature === toUTF8String(input, 1, 8)) {
83
+ let chunkName = toUTF8String(input, 12, 16);
84
+ if (chunkName === pngFriedChunkName) {
85
+ chunkName = toUTF8String(input, 28, 32);
86
+ }
87
+ if (chunkName !== pngImageHeaderChunkName) {
88
+ throw new TypeError('Invalid PNG');
89
+ }
90
+ return true;
91
+ }
92
+ return false;
93
+ },
94
+
95
+ calculate(input) {
96
+ if (toUTF8String(input, 12, 16) === pngFriedChunkName) {
97
+ return {
98
+ height: readUInt32BE(input, 36),
99
+ width: readUInt32BE(input, 32),
100
+ };
101
+ }
102
+ return {
103
+ height: readUInt32BE(input, 20),
104
+ width: readUInt32BE(input, 16),
105
+ };
106
+ },
107
+ };
108
+
109
+ const typeHandlers = {
110
+ jpg: JPG,
111
+ png: PNG,
112
+ };
113
+
114
+ type imageType = keyof typeof typeHandlers;
115
+
116
+ function detector(input: Uint8Array): imageType | undefined {
117
+ const firstBytes: { [byte: number]: imageType } = {
118
+ 0x89: 'png',
119
+ 0xff: 'jpg',
120
+ };
121
+ const byte = input[0];
122
+ if (byte in firstBytes) {
123
+ const type = firstBytes[byte];
124
+ if (type && typeHandlers[type].validate(input)) {
125
+ return type;
126
+ }
127
+ }
128
+
129
+ const keys = Object.keys(typeHandlers) as imageType[];
130
+ return keys.find((key: imageType) => typeHandlers[key].validate(input));
131
+ }
132
+
133
+ export const imageSize = (imgBuffer: Buffer): { height: number; width: number } => {
134
+ const type = detector(imgBuffer);
135
+
136
+ if (typeof type !== 'undefined' && type in typeHandlers) {
137
+ const size = typeHandlers[type].calculate(imgBuffer);
138
+ if (size !== undefined) {
139
+ return size;
140
+ }
141
+ }
142
+
143
+ throw new TypeError(
144
+ '[@pdfme/schemas/images] Unsupported file type: ' + (type === undefined ? 'undefined' : type)
145
+ );
146
+ };
147
+ // ----------------------------
@@ -1,41 +1,68 @@
1
1
  import type { ChangeEvent } from 'react';
2
+ import type { PDFImage } from '@pdfme/pdf-lib';
2
3
  import type { Plugin } from '@pdfme/common';
3
4
  import type { PDFRenderProps, Schema } from '@pdfme/common';
4
5
  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';
6
+ import { Buffer } from 'buffer';
7
+ import { UIRenderProps } from '@pdfme/common';
8
+ import { convertForPdfLayoutProps, addAlphaToHex, isEditable, readFile } from '../utils.js';
8
9
  import { DEFAULT_OPACITY } from '../constants.js';
10
+ import { imageSize } from './helper.js';
11
+
12
+ const px2mm = (px: number): number => {
13
+ // http://www.endmemo.com/sconvert/millimeterpixel.php
14
+ const ratio = 0.26458333333333;
15
+ return parseFloat(String(px)) * ratio;
16
+ };
9
17
 
10
18
  const getCacheKey = (schema: Schema, input: string) => `${schema.type}${input}`;
11
19
  const fullSize = { width: '100%', height: '100%' };
12
20
  const defaultValue =
13
- 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAu4AAALuAQMAAADL0wGJAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAGUExURbzAw+rv8fKruy0AAAPoSURBVHja7dwxbtwwEEBRCkKwRQodYftcYk+ROkcJz5NTsEuZK/AIKlIQAUEnke0VqQ0pA5zxWvFnZcD2s0CNuENxPOZBc0QDDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PD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diBiJFNHOsU6JIQbpLZ6ZynnAUHxY5M1N2NdCcSHE3deZAaLKbMkxxdF1pb/QoIordau+WxnkhIgXhXXt2jf4Mup8Cuu35vJNBwyo+MGK7Q8MmHxVIP4GV9tavXfD+pkDSOYTSmUCuqES2cgilxUDiXKPgE6sD3L+BeBVITKdxaws5gOcRlUh8hM3GSoNjAoX8iRgJ6VOeezaMmIpiykiehHiEe+aN/tmuYuMxktuby4NnxYitzchOjkrDLR6cZWCYMrIiXc7zoUnj3nX1s8ZUTbqc5eWhMeLpoibvkdJmemBejSPVeIn6V4ssr0nXo7QzNCxp+th4KVKEQXkmRvLQcaxcANKPXTO+eICkgWvIW0JkEDsWyB4hkgbuBRKRQexcIBFJA/cCichg5o5x7VUg6SCzTMN0YYikiSvIL1SNDGLnRg0i6ch2g2PeNUTSmQvIBwIknAtZLXgWiEgKY+sdckTfQ9J+Yte4eUOIhHJkQ4mJABGJSvvGeiT1F7aMyzH9KJL2biyN6zdUjUTlr6l54vZDj+qQWPrXmWEi5KUEJBa//26RGRMuP449+jEkprV8TLPGgenjx8uomkj0N73+g6V/XjknAAAAAElFTkSuQmCC';
14
22
 
15
23
  interface ImageSchema extends Schema {}
16
24
 
17
- const schema: Plugin<ImageSchema> = {
25
+ const imageSchema: Plugin<ImageSchema> = {
18
26
  pdf: async (arg: PDFRenderProps<ImageSchema>) => {
19
27
  const { value, schema, pdfDoc, page, _cache } = arg;
20
28
  if (!value || !value.startsWith('data:image/')) return;
21
29
 
22
30
  const inputImageCacheKey = getCacheKey(schema, value);
23
- let image = _cache.get(inputImageCacheKey);
31
+ let image = _cache.get(inputImageCacheKey) as PDFImage;
24
32
  if (!image) {
25
33
  const isPng = value.startsWith('data:image/png;');
26
34
  image = await (isPng ? pdfDoc.embedPng(value) : pdfDoc.embedJpg(value));
27
35
  _cache.set(inputImageCacheKey, image);
28
36
  }
29
37
 
30
- const pageHeight = page.getHeight();
31
- const {
32
- width,
33
- height,
34
- rotate,
35
- position: { x, y },
36
- opacity,
37
- } = convertForPdfLayoutProps({ schema, pageHeight });
38
+ const _schema = { ...schema, position: { ...schema.position } };
39
+ const dataUriPrefix = ';base64,';
40
+ const idx = value.indexOf(dataUriPrefix);
41
+ const imgBase64 = value.substring(idx + dataUriPrefix.length, value.length);
42
+ const dimension = imageSize(Buffer.from(imgBase64, 'base64'));
43
+
44
+ const imageWidth = px2mm(dimension.width);
45
+ const imageHeight = px2mm(dimension.height);
46
+ const boxWidth = _schema.width;
47
+ const boxHeight = _schema.height;
48
+
49
+ const imageRatio = imageWidth / imageHeight;
50
+ const boxRatio = boxWidth / boxHeight;
38
51
 
52
+ if (imageRatio > boxRatio) {
53
+ _schema.width = boxWidth;
54
+ _schema.height = boxWidth / imageRatio;
55
+ _schema.position.y += (boxHeight - _schema.height) / 2;
56
+ } else {
57
+ _schema.width = boxHeight * imageRatio;
58
+ _schema.height = boxHeight;
59
+ _schema.position.x += (boxWidth - _schema.width) / 2;
60
+ }
61
+
62
+ const pageHeight = page.getHeight();
63
+ const lProps = convertForPdfLayoutProps({ schema: _schema, pageHeight });
64
+ const { width, height, rotate, position, opacity } = lProps;
65
+ const { x, y } = position;
39
66
  page.drawImage(image, { x, y, rotate, width, height, opacity });
40
67
  },
41
68
  ui: (arg: UIRenderProps<ImageSchema>) => {
@@ -47,20 +74,20 @@ const schema: Plugin<ImageSchema> = {
47
74
  stopEditing,
48
75
  tabIndex,
49
76
  placeholder,
50
- schema,
51
77
  theme,
78
+ schema,
52
79
  } = arg;
53
- const editable = isEditable(mode);
80
+ const editable = isEditable(mode, schema);
54
81
  const isDefault = value === defaultValue;
55
82
 
56
- const size = { width: schema.width * ZOOM, height: schema.height * ZOOM };
57
-
58
83
  const container = document.createElement('div');
59
84
  const backgroundStyle = placeholder ? `url(${placeholder})` : 'none';
60
85
  const containerStyle: CSS.Properties = {
61
86
  ...fullSize,
62
87
  backgroundImage: value ? 'none' : backgroundStyle,
63
- backgroundSize: `${size.width}px ${size.height}px`,
88
+ backgroundSize: `contain`,
89
+ backgroundRepeat: 'no-repeat',
90
+ backgroundPosition: 'center',
64
91
  };
65
92
  Object.assign(container.style, containerStyle);
66
93
  container.addEventListener('click', (e) => {
@@ -73,7 +100,12 @@ const schema: Plugin<ImageSchema> = {
73
100
  // image tag
74
101
  if (value) {
75
102
  const img = document.createElement('img');
76
- const imgStyle: CSS.Properties = { height: '100%', width: '100%', borderRadius: 0 };
103
+ const imgStyle: CSS.Properties = {
104
+ height: '100%',
105
+ width: '100%',
106
+ borderRadius: 0,
107
+ objectFit: 'contain',
108
+ };
77
109
  Object.assign(img.style, imgStyle);
78
110
  img.src = value;
79
111
  container.appendChild(img);
@@ -120,7 +152,16 @@ const schema: Plugin<ImageSchema> = {
120
152
  Object.assign(label.style, labelStyle);
121
153
  container.appendChild(label);
122
154
  const input = document.createElement('input');
123
- const inputStyle: CSS.Properties = { ...fullSize, position: 'absolute', top: '50%' };
155
+ const inputStyle: CSS.Properties = {
156
+ ...fullSize,
157
+ position: 'absolute',
158
+ top: '50%',
159
+ left: '50%',
160
+ width: '180px',
161
+ height: '30px',
162
+ marginLeft: '-90px',
163
+ marginTop: '-15px',
164
+ };
124
165
  Object.assign(input.style, inputStyle);
125
166
  input.tabIndex = tabIndex || 0;
126
167
  input.type = 'file';
@@ -148,4 +189,19 @@ const schema: Plugin<ImageSchema> = {
148
189
  },
149
190
  },
150
191
  };
151
- export default schema;
192
+
193
+ export default imageSchema;
194
+
195
+ export const readOnlyImage: Plugin<ImageSchema> = {
196
+ pdf: imageSchema.pdf,
197
+ ui: imageSchema.ui,
198
+ propPanel: {
199
+ ...imageSchema.propPanel,
200
+ defaultSchema: {
201
+ ...imageSchema.propPanel.defaultSchema,
202
+ type: 'readOnlyImage',
203
+ readOnly: true,
204
+ readOnlyValue: defaultValue,
205
+ },
206
+ },
207
+ };
@@ -0,0 +1,98 @@
1
+ import { Plugin, Schema } from '@pdfme/common';
2
+ import { XMLValidator } from 'fast-xml-parser';
3
+ import { convertForPdfLayoutProps, isEditable, addAlphaToHex, createErrorElm } from '../utils.js';
4
+
5
+ const isValidSVG = (svgString: string) => XMLValidator.validate(svgString) === true;
6
+
7
+ const defaultValue = `<svg viewBox="0 0 488 600" version="1.1" xmlns="http://www.w3.org/2000/svg">
8
+ <g transform="matrix(1,0,0,1,-56,0)" fill="#000000" stroke="none">
9
+ <path d="M228.667,0L56,172.667L56.267,345.334L56.667,518L59.733,527.334C65.867,545.467 72.933,557.067 86,570.134C96.133,580.4 100,583.2 110.667,588.4C134.533,600.134 120,599.334 300,599.334C480,599.334 465.467,600.134 489.334,588.4C500,583.2 503.867,580.4 514,570.134C527.334,556.8 534.534,544.8 540.267,526.667L543.334,516.667L543.334,83.333L540.267,73.333C534.534,55.2 527.334,43.2 514,29.867C503.867,19.6 500,16.8 489.334,11.6C465.734,0 475.467,0.8 344.667,0.267L228.667,0ZM466.4,41.6C483.334,48.933 496.267,61.867 502.934,78.4L506,86L506,514L502.934,521.734C496,538.934 480.267,553.867 463.334,559.334C455.6,561.867 450.8,562 300,562C149.2,562 144.4,561.867 136.667,559.334C119.733,553.867 104,538.934 97.067,521.734L94,514L93.6,351.067L93.333,188.133L149.067,187.733L204.667,187.333L213.6,182.933C224.8,177.467 235.867,165.867 240.267,155.067C243.333,147.467 243.333,146.4 243.733,92.267L244.133,37.2L458,38L466.4,41.6ZM195.067,304C175.6,306.8 164,320.667 165.6,339.467C166,343.6 167.6,348.667 169.733,352.4C174.4,360.267 185.2,365.734 201.867,368.534C208.4,369.734 215.067,371.467 216.8,372.667C224,377.334 221.467,389.067 212.533,392C205.6,394.4 193.733,392.934 185.6,388.8C173.333,382.534 164,385.334 164,395.2C164,400.934 170.133,406.667 180.267,410.134C190.933,413.867 217.067,413.734 225.467,409.867C238.933,403.6 246.667,390 244.8,375.6C242.667,359.734 232.8,351.334 212.267,347.867C193.6,344.8 189.333,342.4 189.333,334.533C189.333,324.267 201.867,320.933 218.267,326.667C228.667,330.267 232.533,330.133 235.867,325.867C242.133,318 237.6,310.667 224.267,306.8C213.333,303.6 204.267,302.8 195.067,304ZM386,304.133C377.6,305.333 374,306.8 367.334,311.6C355.734,320.133 351.2,336.4 352.4,365.334C353.2,385.334 356,394.4 364.134,402.534C372.267,410.667 381.734,413.734 396.667,413.067C406.8,412.667 409.734,412 415.734,408.667C429.2,401.334 434.534,390.934 435.6,370.667C436.4,353.734 436,353.067 420.934,352.267C401.867,351.334 396,353.467 396,361.867C396,367.867 399.467,370.667 407.067,370.667C413.2,370.667 413.334,370.667 413.334,374.934C413.334,394 386.267,400.534 378.534,383.467C374.934,375.334 374.934,341.867 378.534,333.733C382,326.4 387.467,323.467 396.8,324.267C403.067,324.8 404.667,325.6 410.534,331.067C414.267,334.533 418.4,337.333 419.867,337.333C427.334,337.333 433.334,330.267 431.334,323.733C427.2,310.133 406.4,301.2 386,304.133ZM258.4,308C255.067,311.467 254.533,312.8 255.2,316.4C257.067,326.667 285.333,405.867 288.133,408.8C289.733,410.534 293.067,412.267 295.333,412.8C303.867,414.4 310.667,407.867 314.4,394.667C315.067,392.134 321.2,374.134 327.867,354.8C334.8,334.533 340,317.467 340,314.533C340,303.733 325.067,299.867 319.867,309.467C318.533,312.133 309.467,340.933 302.667,364C301.067,369.467 299.333,374.4 298.8,375.067C298.267,375.6 292.933,360.8 286.933,342C275.333,306 274.133,304 266.267,304C263.867,304 261.067,305.467 258.4,308Z" style="fill-rule:nonzero;"/>
10
+ </g>
11
+ </svg>`;
12
+
13
+ interface SVGSchema extends Schema {}
14
+
15
+ const svgSchema: Plugin<SVGSchema> = {
16
+ ui: (arg) => {
17
+ const { rootElement, value, mode, onChange, theme, schema } = arg;
18
+ const container = document.createElement(isEditable(mode, schema) ? 'textarea' : 'div');
19
+ container.style.width = '100%';
20
+ container.style.height = '100%';
21
+ container.style.boxSizing = 'border-box';
22
+ if (isEditable(mode, schema)) {
23
+ const textarea = container as HTMLTextAreaElement;
24
+ textarea.value = value;
25
+ textarea.style.position = 'absolute';
26
+ textarea.style.backgroundColor = addAlphaToHex(theme.colorPrimaryBg, 30);
27
+
28
+ if (isValidSVG(value)) {
29
+ const svgElement = new DOMParser().parseFromString(value, 'text/xml').childNodes[0];
30
+ if (svgElement instanceof SVGElement) {
31
+ svgElement.setAttribute('width', '100%');
32
+ svgElement.setAttribute('height', '100%');
33
+ svgElement.style.position = 'absolute';
34
+ }
35
+ rootElement.appendChild(svgElement);
36
+ } else if (value) {
37
+ const errorElm = createErrorElm();
38
+ errorElm.style.position = 'absolute';
39
+ rootElement.appendChild(errorElm);
40
+ }
41
+
42
+ textarea.addEventListener('change', (e: Event) => {
43
+ const newValue = (e.target as HTMLTextAreaElement).value;
44
+ onChange && onChange(newValue);
45
+ });
46
+ rootElement.appendChild(container);
47
+ textarea.setSelectionRange(value.length, value.length);
48
+ textarea.focus();
49
+ } else {
50
+ if (!value) return;
51
+ if (!isValidSVG(value)) {
52
+ rootElement.appendChild(createErrorElm());
53
+ return;
54
+ }
55
+ container.innerHTML = value;
56
+ const svgElement = container.childNodes[0];
57
+ if (svgElement instanceof SVGElement) {
58
+ svgElement.setAttribute('width', '100%');
59
+ svgElement.setAttribute('height', '100%');
60
+ rootElement.appendChild(container);
61
+ }
62
+ }
63
+ },
64
+ pdf: async (arg) => {
65
+ const { page, schema, value } = arg;
66
+ if (!value || !isValidSVG(value)) return;
67
+ const pageHeight = page.getHeight();
68
+ const { width, height, position } = convertForPdfLayoutProps({ schema, pageHeight });
69
+ const { x, y } = position;
70
+ await page.drawSvg(value, { x, y: y + height, width, height });
71
+ },
72
+ propPanel: {
73
+ schema: {},
74
+ defaultValue,
75
+ defaultSchema: {
76
+ type: 'svg',
77
+ position: { x: 0, y: 0 },
78
+ width: 40,
79
+ height: 40,
80
+ },
81
+ },
82
+ };
83
+
84
+ export default svgSchema;
85
+
86
+ export const readOnlySvg: Plugin<SVGSchema> = {
87
+ pdf: svgSchema.pdf,
88
+ ui: svgSchema.ui,
89
+ propPanel: {
90
+ ...svgSchema.propPanel,
91
+ defaultSchema: {
92
+ ...svgSchema.propPanel.defaultSchema,
93
+ type: 'readOnlySvg',
94
+ readOnly: true,
95
+ readOnlyValue: defaultValue,
96
+ },
97
+ },
98
+ };
package/src/index.ts CHANGED
@@ -1,15 +1,20 @@
1
- import text from './text/index.js';
2
- import image from './graphics/image.js';
1
+ import text, { readOnlyText } from './text/index.js';
2
+ import image, { readOnlyImage } from './graphics/image.js';
3
+ import svg, { readOnlySvg } from './graphics/svg.js';
3
4
  import barcodes from './barcodes/index.js';
4
5
  import line from './shapes/line.js';
5
6
  import { rectangle, ellipse } from './shapes/rectAndEllipse.js';
6
- import { convertForPdfLayoutProps, rotatePoint } from './pdfRenderUtils.js';
7
+ import { convertForPdfLayoutProps, rotatePoint } from './utils.js';
7
8
 
8
9
  const builtInPlugins = { Text: text };
9
10
 
10
11
  export {
11
12
  text,
13
+ readOnlyText,
12
14
  image,
15
+ readOnlyImage,
16
+ svg,
17
+ readOnlySvg,
13
18
  barcodes,
14
19
  line,
15
20
  rectangle,
@@ -1,5 +1,5 @@
1
1
  import type { Schema, Plugin, PDFRenderProps, UIRenderProps } from '@pdfme/common';
2
- import { rotatePoint, convertForPdfLayoutProps, hex2RgbColor } from '../pdfRenderUtils.js';
2
+ import { rotatePoint, convertForPdfLayoutProps, hex2RgbColor } from '../utils.js';
3
3
  import { HEX_COLOR_PATTERN } from '../constants.js';
4
4
 
5
5
  const DEFAULT_LINE_COLOR = '#000000';
@@ -8,7 +8,7 @@ interface LineSchema extends Schema {
8
8
  color: string;
9
9
  }
10
10
 
11
- const schema: Plugin<LineSchema> = {
11
+ const lineSchema: Plugin<LineSchema> = {
12
12
  pdf: (arg: PDFRenderProps<LineSchema>) => {
13
13
  const { page, schema } = arg;
14
14
  const pageHeight = page.getHeight();
@@ -64,4 +64,4 @@ const schema: Plugin<LineSchema> = {
64
64
  },
65
65
  },
66
66
  };
67
- export default schema;
67
+ export default lineSchema;
@@ -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 '../pdfRenderUtils.js';
3
+ import { hex2RgbColor, convertForPdfLayoutProps } from '../utils.js';
4
4
 
5
5
  interface Shape extends Schema {
6
6
  type: 'ellipse' | 'rectangle';
@@ -5,7 +5,6 @@ import {
5
5
  mm2pt,
6
6
  pt2mm,
7
7
  pt2px,
8
- Schema,
9
8
  Font,
10
9
  getFallbackFontName,
11
10
  getDefaultFont,
package/src/text/index.ts CHANGED
@@ -4,5 +4,20 @@ import { propPanel } from './propPanel.js';
4
4
  import { uiRender } from './uiRender.js';
5
5
  import type { TextSchema } from './types';
6
6
 
7
- const schema: Plugin<TextSchema> = { pdf: pdfRender, ui: uiRender, propPanel };
8
- export default schema;
7
+ const textSchema: Plugin<TextSchema> = { pdf: pdfRender, ui: uiRender, propPanel };
8
+
9
+ export default textSchema;
10
+
11
+ export const readOnlyText: Plugin<TextSchema> = {
12
+ pdf: textSchema.pdf,
13
+ ui: textSchema.ui,
14
+ propPanel: {
15
+ ...textSchema.propPanel,
16
+ defaultSchema: {
17
+ ...textSchema.propPanel.defaultSchema,
18
+ type: 'readOnlyText',
19
+ readOnly: true,
20
+ readOnlyValue: textSchema.propPanel.defaultValue,
21
+ },
22
+ },
23
+ };
@@ -1,6 +1,6 @@
1
1
  import { PDFFont, PDFDocument } from '@pdfme/pdf-lib';
2
- import { PDFRenderProps, Font, getDefaultFont, getFallbackFontName, mm2pt } from '@pdfme/common';
3
2
  import type { TextSchema, FontWidthCalcValues } from './types';
3
+ import { PDFRenderProps, Font, getDefaultFont, getFallbackFontName, mm2pt } from '@pdfme/common';
4
4
  import {
5
5
  VERTICAL_ALIGN_TOP,
6
6
  VERTICAL_ALIGN_MIDDLE,
@@ -20,7 +20,7 @@ import {
20
20
  getSplittedLines,
21
21
  widthOfTextAtSize,
22
22
  } from './helper.js';
23
- import { convertForPdfLayoutProps, rotatePoint, hex2RgbColor } from '../pdfRenderUtils.js';
23
+ import { convertForPdfLayoutProps, rotatePoint, hex2RgbColor } from '../utils.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 '../pdfRenderUtils.js';
21
+ import { addAlphaToHex, isEditable } from '../utils.js';
22
22
 
23
23
  const mapVerticalAlignToFlex = (verticalAlignmentValue: string | undefined) => {
24
24
  switch (verticalAlignmentValue) {
@@ -117,7 +117,7 @@ export const uiRender = async (arg: UIRenderProps<TextSchema>) => {
117
117
  const textBlock = document.createElement('div');
118
118
  Object.assign(textBlock.style, textBlockStyle);
119
119
 
120
- if (isEditable(mode)) {
120
+ if (isEditable(mode, schema)) {
121
121
  textBlock.contentEditable = 'plaintext-only';
122
122
  textBlock.tabIndex = tabIndex || 0;
123
123
  textBlock.innerText = value;
@@ -1,3 +1,4 @@
1
+ import type * as CSS from 'csstype';
1
2
  import { degrees, degreesToRadians, rgb } from '@pdfme/pdf-lib';
2
3
  import { Schema, mm2pt, Mode, isHexValid } from '@pdfme/common';
3
4
 
@@ -69,7 +70,8 @@ export const addAlphaToHex = (hex: string, alphaPercentage: number) => {
69
70
  return hex + alphaHex;
70
71
  };
71
72
 
72
- export const isEditable = (mode: Mode) => mode === 'form' || mode === 'designer';
73
+ export const isEditable = (mode: Mode, schema: Schema) =>
74
+ mode === 'designer' || (mode === 'form' && schema.readOnly !== true);
73
75
 
74
76
  const hex2rgb = (hex: string) => {
75
77
  if (hex.slice(0, 1) === '#') hex = hex.slice(1);
@@ -100,3 +102,60 @@ export const hex2RgbColor = (hexString: string | undefined) => {
100
102
 
101
103
  return undefined;
102
104
  };
105
+
106
+ export const readFile = (input: File | FileList | null): Promise<string | ArrayBuffer> =>
107
+ new Promise((resolve, reject) => {
108
+ const fileReader = new FileReader();
109
+
110
+ fileReader.onload = (e) => {
111
+ if (e.target?.result) {
112
+ resolve(e.target.result);
113
+ }
114
+ };
115
+
116
+ fileReader.onerror = (e) => {
117
+ reject(new Error('[@pdfme/schemas] File reading failed'));
118
+ };
119
+
120
+ let file: File | null = null;
121
+ if (input instanceof FileList && input.length > 0) {
122
+ file = input[0];
123
+ } else if (input instanceof File) {
124
+ file = input;
125
+ }
126
+
127
+ if (file) {
128
+ fileReader.readAsDataURL(file);
129
+ } else {
130
+ reject(new Error('[@pdfme/schemas] No files provided'));
131
+ }
132
+ });
133
+
134
+ export const createErrorElm = () => {
135
+ const container = document.createElement('div');
136
+ const containerStyle: CSS.Properties = {
137
+ display: 'flex',
138
+ alignItems: 'center',
139
+ justifyContent: 'center',
140
+ width: '100%',
141
+ height: '100%',
142
+ };
143
+ Object.assign(container.style, containerStyle);
144
+
145
+ const span = document.createElement('span');
146
+ const spanStyle: CSS.Properties = {
147
+ color: 'white',
148
+ background: 'red',
149
+ padding: '0.25rem',
150
+ fontSize: '12pt',
151
+ fontWeight: 'bold',
152
+ borderRadius: '2px',
153
+ fontFamily: "'Open Sans', sans-serif",
154
+ };
155
+ Object.assign(span.style, spanStyle);
156
+
157
+ span.textContent = 'ERROR';
158
+ container.appendChild(span);
159
+
160
+ return container;
161
+ };
@@ -1 +0,0 @@
1
- {"version":3,"file":"renderUtils.test.js","sourceRoot":"","sources":["../../../__tests__/renderUtils.test.ts"],"names":[],"mappings":";;AAAA,0CAAqD;AACrD,0DAA4F;AAE5F,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACnC,MAAM,GAAG,GAAG,SAAS,CAAC;QACtB,MAAM,QAAQ,GAAG,IAAA,6BAAY,EAAC,GAAG,CAAC,CAAC;QACnC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,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