@pdfme/schemas 3.1.5-dev.13 → 3.1.5-dev.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/__tests__/{renderUtils.test.js → utils.test.js} +38 -12
- package/dist/cjs/__tests__/utils.test.js.map +1 -0
- package/dist/cjs/src/barcodes/pdfRender.js +2 -2
- package/dist/cjs/src/barcodes/pdfRender.js.map +1 -1
- package/dist/cjs/src/barcodes/uiRender.js +4 -28
- package/dist/cjs/src/barcodes/uiRender.js.map +1 -1
- package/dist/cjs/src/graphics/image.js +80 -13
- package/dist/cjs/src/graphics/image.js.map +1 -1
- package/dist/cjs/src/graphics/svg.js +82 -0
- package/dist/cjs/src/graphics/svg.js.map +1 -0
- package/dist/cjs/src/index.js +6 -4
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/shapes/line.js +5 -5
- package/dist/cjs/src/shapes/line.js.map +1 -1
- package/dist/cjs/src/shapes/rectAndEllipse.js +5 -5
- package/dist/cjs/src/shapes/rectAndEllipse.js.map +1 -1
- package/dist/cjs/src/text/helper.js.map +1 -1
- package/dist/cjs/src/text/pdfRender.js +5 -5
- package/dist/cjs/src/text/pdfRender.js.map +1 -1
- package/dist/cjs/src/text/uiRender.js +3 -3
- package/dist/cjs/src/text/uiRender.js.map +1 -1
- package/dist/cjs/src/{pdfRenderUtils.js → utils.js} +53 -2
- package/dist/cjs/src/utils.js.map +1 -0
- package/dist/esm/__tests__/{renderUtils.test.js → utils.test.js} +34 -8
- package/dist/esm/__tests__/utils.test.js.map +1 -0
- package/dist/esm/src/barcodes/pdfRender.js +1 -1
- package/dist/esm/src/barcodes/pdfRender.js.map +1 -1
- package/dist/esm/src/barcodes/uiRender.js +2 -26
- package/dist/esm/src/barcodes/uiRender.js.map +1 -1
- package/dist/esm/src/graphics/image.js +74 -10
- package/dist/esm/src/graphics/image.js.map +1 -1
- package/dist/esm/src/graphics/svg.js +80 -0
- package/dist/esm/src/graphics/svg.js.map +1 -0
- package/dist/esm/src/index.js +3 -2
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/shapes/line.js +1 -1
- package/dist/esm/src/shapes/line.js.map +1 -1
- package/dist/esm/src/shapes/rectAndEllipse.js +1 -1
- package/dist/esm/src/shapes/rectAndEllipse.js.map +1 -1
- package/dist/esm/src/text/helper.js.map +1 -1
- package/dist/esm/src/text/pdfRender.js +1 -1
- package/dist/esm/src/text/pdfRender.js.map +1 -1
- package/dist/esm/src/text/uiRender.js +1 -1
- package/dist/esm/src/text/uiRender.js.map +1 -1
- package/dist/esm/src/{pdfRenderUtils.js → utils.js} +50 -1
- package/dist/esm/src/utils.js.map +1 -0
- package/dist/types/src/graphics/svg.d.ts +5 -0
- package/dist/types/src/index.d.ts +3 -2
- package/dist/types/src/text/pdfRender.d.ts +1 -1
- package/dist/types/src/{pdfRenderUtils.d.ts → utils.d.ts} +2 -0
- package/package.json +6 -4
- package/src/barcodes/pdfRender.ts +1 -1
- package/src/barcodes/uiRender.ts +2 -30
- package/src/graphics/image.ts +86 -29
- package/src/graphics/svg.ts +84 -0
- package/src/index.ts +3 -1
- package/src/shapes/line.ts +1 -1
- package/src/shapes/rectAndEllipse.ts +1 -1
- package/src/text/helper.ts +0 -1
- package/src/text/pdfRender.ts +2 -2
- package/src/text/uiRender.ts +1 -1
- package/src/{pdfRenderUtils.ts → utils.ts} +58 -0
- package/dist/cjs/__tests__/renderUtils.test.js.map +0 -1
- package/dist/cjs/src/pdfRenderUtils.js.map +0 -1
- package/dist/cjs/src/uiRenderUtils.js +0 -29
- package/dist/cjs/src/uiRenderUtils.js.map +0 -1
- package/dist/esm/__tests__/renderUtils.test.js.map +0 -1
- package/dist/esm/src/pdfRenderUtils.js.map +0 -1
- package/dist/esm/src/uiRenderUtils.js +0 -25
- package/dist/esm/src/uiRenderUtils.js.map +0 -1
- package/dist/types/src/uiRenderUtils.d.ts +0 -1
- package/src/uiRenderUtils.ts +0 -27
- /package/dist/types/__tests__/{renderUtils.test.d.ts → utils.test.d.ts} +0 -0
package/src/graphics/image.ts
CHANGED
@@ -1,16 +1,50 @@
|
|
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
|
6
|
-
import {
|
7
|
-
import {
|
6
|
+
import sizeOf from 'image-size';
|
7
|
+
import { Buffer } from 'buffer';
|
8
|
+
import { UIRenderProps } from '@pdfme/common';
|
9
|
+
import {
|
10
|
+
convertForPdfLayoutProps,
|
11
|
+
addAlphaToHex,
|
12
|
+
isEditable,
|
13
|
+
readFile,
|
14
|
+
} from '../utils.js';
|
8
15
|
import { DEFAULT_OPACITY } from '../constants.js';
|
9
16
|
|
17
|
+
const px2mm = (px: number): number => {
|
18
|
+
// http://www.endmemo.com/sconvert/millimeterpixel.php
|
19
|
+
const ratio = 0.26458333333333;
|
20
|
+
return parseFloat(String(px)) * ratio;
|
21
|
+
};
|
22
|
+
|
23
|
+
const getDimension = (imgBuffer: Buffer): Promise<{ height: number; width: number }> => {
|
24
|
+
if (typeof window !== 'undefined') {
|
25
|
+
return new Promise((resolve, reject) => {
|
26
|
+
const blob = new Blob([imgBuffer]);
|
27
|
+
const url = URL.createObjectURL(blob);
|
28
|
+
const img = new Image();
|
29
|
+
img.onload = () => {
|
30
|
+
resolve({ width: img.width, height: img.height });
|
31
|
+
URL.revokeObjectURL(url);
|
32
|
+
};
|
33
|
+
img.onerror = (e) => {
|
34
|
+
reject(e);
|
35
|
+
};
|
36
|
+
img.src = url;
|
37
|
+
});
|
38
|
+
} else {
|
39
|
+
const dimensions = sizeOf(imgBuffer);
|
40
|
+
return Promise.resolve({ width: dimensions.width ?? 0, height: dimensions.height ?? 0 });
|
41
|
+
}
|
42
|
+
};
|
43
|
+
|
10
44
|
const getCacheKey = (schema: Schema, input: string) => `${schema.type}${input}`;
|
11
45
|
const fullSize = { width: '100%', height: '100%' };
|
12
46
|
const defaultValue =
|
13
|
-
'data:image/png;base64,
|
47
|
+
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUgAAAGQBAMAAAA+V+RCAAAAAXNSR0IArs4c6QAAABtQTFRFAAAAR3BMAAAAAAAAAAAAAAAAAAAAAAAAAAAAqmQqwQAAAAh0Uk5TDQAvVYGtxusE1uR9AAAKg0lEQVR42tTbwU7bQBDG8TWoPeOBPoBbdbhiVMGV0Kr0GChSe0RtRfccEOROnP0eu8ckTMHrjD27/h4Afvo7u4kUxZXbjuboZ+Hx9vrz+6J8eW5rJKPHhYfr46J/JHn0u/DnuHcko/eF71Ub0j6k3P1Rr0jGIHs4bkPah5RbnveHZMBQ6VKHlMqjnpCMAdfUApk8pNx91QeSMex+C2R2IYFwrkcyht6yEsjkIeXutEjG8AtnApldSGBRqJAMk10JZHYhgaZSIBlG+yWQipAGKZ0ipNmr0uUaEmiKLZEMw52tkLqQD7f6PT7iv1uskLqQV06/nQ9ffswhF+oVUhMS07KX7Xz6+8ot5BQhBVLF/Pry0XGKkAKpGp3IRz7pjmQMiSz3TvB8s85I8h2ReuWy6IpkDIws6UI8745I8oMjy10vnnc3JGN4ZPlRnO9OSPIWyL0LcZ93QTIskOXuXPz9eCR5G2R5io09dUEyjJD7c3kJudiQJkiZMtTxSIYZ8mAu/oGLDGmHLL9hfXfRSIYh8g3W18QiyVsh5VdtoYpEMsyQ8uhM4pDk7ZDyeU/jkAw7pHzesygkeUOkPN+LKCTDGsnP3nNcREhz5MHm8Y5AMkyRskvdjiRvi5Qvyst2JCMB8hBru2lFkjdGypty1opkpEDuY21PbUjy1kh5nS/akIwkyL2fWK0pXEtIc6Q83ssWJCMR8nTjNncxIe2Rh/FIRirkW6ytdjEh7ZHvopGMFEj5EWPiYkLaI/djkYyEyDlWu3SakOmRjIRIWkdOnSJkeiQjfyT5ESAZ+SPJjwDJyB9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6OFE7SSOn9omYIlKRr7E/2SdiBiJFNHOsU6JIQbpLZ6ZynnAUHxY5M1N2NdCcSHE3deZAaLKbMkxxdF1pb/QoIordau+WxnkhIgXhXXt2jf4Mup8Cuu35vJNBwyo+MGK7Q8MmHxVIP4GV9tavXfD+pkDSOYTSmUCuqES2cgilxUDiXKPgE6sD3L+BeBVITKdxaws5gOcRlUh8hM3GSoNjAoX8iRgJ6VOeezaMmIpiykiehHiEe+aN/tmuYuMxktuby4NnxYitzchOjkrDLR6cZWCYMrIiXc7zoUnj3nX1s8ZUTbqc5eWhMeLpoibvkdJmemBejSPVeIn6V4ssr0nXo7QzNCxp+th4KVKEQXkmRvLQcaxcANKPXTO+eICkgWvIW0JkEDsWyB4hkgbuBRKRQexcIBFJA/cCichg5o5x7VUg6SCzTMN0YYikiSvIL1SNDGLnRg0i6ch2g2PeNUTSmQvIBwIknAtZLXgWiEgKY+sdckTfQ9J+Yte4eUOIhHJkQ4mJABGJSvvGeiT1F7aMyzH9KJL2biyN6zdUjUTlr6l54vZDj+qQWPrXmWEi5KUEJBa//26RGRMuP449+jEkprV8TLPGgenjx8uomkj0N73+g6V/XjknAAAAAElFTkSuQmCC';
|
14
48
|
|
15
49
|
interface ImageSchema extends Schema {}
|
16
50
|
|
@@ -20,47 +54,56 @@ const schema: Plugin<ImageSchema> = {
|
|
20
54
|
if (!value || !value.startsWith('data:image/')) return;
|
21
55
|
|
22
56
|
const inputImageCacheKey = getCacheKey(schema, value);
|
23
|
-
let image = _cache.get(inputImageCacheKey);
|
57
|
+
let image = _cache.get(inputImageCacheKey) as PDFImage;
|
24
58
|
if (!image) {
|
25
59
|
const isPng = value.startsWith('data:image/png;');
|
26
60
|
image = await (isPng ? pdfDoc.embedPng(value) : pdfDoc.embedJpg(value));
|
27
61
|
_cache.set(inputImageCacheKey, image);
|
28
62
|
}
|
29
63
|
|
30
|
-
const
|
31
|
-
const
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
64
|
+
const _schema = { ...schema, position: { ...schema.position } };
|
65
|
+
const dataUriPrefix = ';base64,';
|
66
|
+
const idx = value.indexOf(dataUriPrefix);
|
67
|
+
const imgBase64 = value.substring(idx + dataUriPrefix.length, value.length);
|
68
|
+
const dimension = await getDimension(Buffer.from(imgBase64, 'base64'));
|
69
|
+
|
70
|
+
const imageWidth = px2mm(dimension.width);
|
71
|
+
const imageHeight = px2mm(dimension.height);
|
72
|
+
const boxWidth = _schema.width;
|
73
|
+
const boxHeight = _schema.height;
|
38
74
|
|
75
|
+
const imageRatio = imageWidth / imageHeight;
|
76
|
+
const boxRatio = boxWidth / boxHeight;
|
77
|
+
|
78
|
+
if (imageRatio > boxRatio) {
|
79
|
+
_schema.width = boxWidth;
|
80
|
+
_schema.height = boxWidth / imageRatio;
|
81
|
+
_schema.position.y += (boxHeight - _schema.height) / 2;
|
82
|
+
} else {
|
83
|
+
_schema.width = boxHeight * imageRatio;
|
84
|
+
_schema.height = boxHeight;
|
85
|
+
_schema.position.x += (boxWidth - _schema.width) / 2;
|
86
|
+
}
|
87
|
+
|
88
|
+
const pageHeight = page.getHeight();
|
89
|
+
const lProps = convertForPdfLayoutProps({ schema: _schema, pageHeight });
|
90
|
+
const { width, height, rotate, position, opacity } = lProps;
|
91
|
+
const { x, y } = position;
|
39
92
|
page.drawImage(image, { x, y, rotate, width, height, opacity });
|
40
93
|
},
|
41
94
|
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;
|
95
|
+
const { value, rootElement, mode, onChange, stopEditing, tabIndex, placeholder, theme } = arg;
|
53
96
|
const editable = isEditable(mode);
|
54
97
|
const isDefault = value === defaultValue;
|
55
98
|
|
56
|
-
const size = { width: schema.width * ZOOM, height: schema.height * ZOOM };
|
57
|
-
|
58
99
|
const container = document.createElement('div');
|
59
100
|
const backgroundStyle = placeholder ? `url(${placeholder})` : 'none';
|
60
101
|
const containerStyle: CSS.Properties = {
|
61
102
|
...fullSize,
|
62
103
|
backgroundImage: value ? 'none' : backgroundStyle,
|
63
|
-
backgroundSize:
|
104
|
+
backgroundSize: `contain`,
|
105
|
+
backgroundRepeat: 'no-repeat',
|
106
|
+
backgroundPosition: 'center',
|
64
107
|
};
|
65
108
|
Object.assign(container.style, containerStyle);
|
66
109
|
container.addEventListener('click', (e) => {
|
@@ -73,7 +116,12 @@ const schema: Plugin<ImageSchema> = {
|
|
73
116
|
// image tag
|
74
117
|
if (value) {
|
75
118
|
const img = document.createElement('img');
|
76
|
-
const imgStyle: CSS.Properties = {
|
119
|
+
const imgStyle: CSS.Properties = {
|
120
|
+
height: '100%',
|
121
|
+
width: '100%',
|
122
|
+
borderRadius: 0,
|
123
|
+
objectFit: 'contain',
|
124
|
+
};
|
77
125
|
Object.assign(img.style, imgStyle);
|
78
126
|
img.src = value;
|
79
127
|
container.appendChild(img);
|
@@ -120,7 +168,16 @@ const schema: Plugin<ImageSchema> = {
|
|
120
168
|
Object.assign(label.style, labelStyle);
|
121
169
|
container.appendChild(label);
|
122
170
|
const input = document.createElement('input');
|
123
|
-
const inputStyle: CSS.Properties = {
|
171
|
+
const inputStyle: CSS.Properties = {
|
172
|
+
...fullSize,
|
173
|
+
position: 'absolute',
|
174
|
+
top: '50%',
|
175
|
+
left: '50%',
|
176
|
+
width: '180px',
|
177
|
+
height: '30px',
|
178
|
+
marginLeft: '-90px',
|
179
|
+
marginTop: '-15px',
|
180
|
+
};
|
124
181
|
Object.assign(input.style, inputStyle);
|
125
182
|
input.tabIndex = tabIndex || 0;
|
126
183
|
input.type = 'file';
|
@@ -0,0 +1,84 @@
|
|
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 svgData = `<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 SVG extends Schema {}
|
14
|
+
|
15
|
+
const schema: Plugin<SVG> = {
|
16
|
+
ui: (arg) => {
|
17
|
+
const { rootElement, value, mode, onChange, theme } = arg;
|
18
|
+
const container = document.createElement(isEditable(mode) ? 'textarea' : 'div');
|
19
|
+
container.style.width = '100%';
|
20
|
+
container.style.height = '100%';
|
21
|
+
container.style.boxSizing = 'border-box';
|
22
|
+
if (isEditable(mode)) {
|
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: svgData,
|
75
|
+
defaultSchema: {
|
76
|
+
type: 'svg',
|
77
|
+
position: { x: 0, y: 0 },
|
78
|
+
width: 40,
|
79
|
+
height: 40,
|
80
|
+
},
|
81
|
+
},
|
82
|
+
};
|
83
|
+
|
84
|
+
export default schema;
|
package/src/index.ts
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
import text from './text/index.js';
|
2
2
|
import image from './graphics/image.js';
|
3
|
+
import svg 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 './
|
7
|
+
import { convertForPdfLayoutProps, rotatePoint } from './utils.js';
|
7
8
|
|
8
9
|
const builtInPlugins = { Text: text };
|
9
10
|
|
10
11
|
export {
|
11
12
|
text,
|
12
13
|
image,
|
14
|
+
svg,
|
13
15
|
barcodes,
|
14
16
|
line,
|
15
17
|
rectangle,
|
package/src/shapes/line.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { Schema, Plugin, PDFRenderProps, UIRenderProps } from '@pdfme/common';
|
2
|
-
import { rotatePoint, convertForPdfLayoutProps, hex2RgbColor } from '../
|
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';
|
@@ -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 '../
|
3
|
+
import { hex2RgbColor, convertForPdfLayoutProps } from '../utils.js';
|
4
4
|
|
5
5
|
interface Shape extends Schema {
|
6
6
|
type: 'ellipse' | 'rectangle';
|
package/src/text/helper.ts
CHANGED
package/src/text/pdfRender.ts
CHANGED
@@ -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 '../
|
23
|
+
import { convertForPdfLayoutProps, rotatePoint, hex2RgbColor } from '../utils.js';
|
24
24
|
|
25
25
|
const embedAndGetFontObj = async (arg: {
|
26
26
|
pdfDoc: PDFDocument;
|
package/src/text/uiRender.ts
CHANGED
@@ -18,7 +18,7 @@ import {
|
|
18
18
|
getFontKitFont,
|
19
19
|
getBrowserVerticalFontAdjustments,
|
20
20
|
} from './helper.js';
|
21
|
-
import { addAlphaToHex, isEditable } from '../
|
21
|
+
import { addAlphaToHex, isEditable } from '../utils.js';
|
22
22
|
|
23
23
|
const mapVerticalAlignToFlex = (verticalAlignmentValue: string | undefined) => {
|
24
24
|
switch (verticalAlignmentValue) {
|
@@ -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
|
|
@@ -100,3 +101,60 @@ export const hex2RgbColor = (hexString: string | undefined) => {
|
|
100
101
|
|
101
102
|
return undefined;
|
102
103
|
};
|
104
|
+
|
105
|
+
export const readFile = (input: File | FileList | null): Promise<string | ArrayBuffer> =>
|
106
|
+
new Promise((resolve, reject) => {
|
107
|
+
const fileReader = new FileReader();
|
108
|
+
|
109
|
+
fileReader.onload = (e) => {
|
110
|
+
if (e.target?.result) {
|
111
|
+
resolve(e.target.result);
|
112
|
+
}
|
113
|
+
};
|
114
|
+
|
115
|
+
fileReader.onerror = (e) => {
|
116
|
+
reject(new Error('[@pdfme/schemas] File reading failed'));
|
117
|
+
};
|
118
|
+
|
119
|
+
let file: File | null = null;
|
120
|
+
if (input instanceof FileList && input.length > 0) {
|
121
|
+
file = input[0];
|
122
|
+
} else if (input instanceof File) {
|
123
|
+
file = input;
|
124
|
+
}
|
125
|
+
|
126
|
+
if (file) {
|
127
|
+
fileReader.readAsDataURL(file);
|
128
|
+
} else {
|
129
|
+
reject(new Error('[@pdfme/schemas] No files provided'));
|
130
|
+
}
|
131
|
+
});
|
132
|
+
|
133
|
+
export const createErrorElm = () => {
|
134
|
+
const container = document.createElement('div');
|
135
|
+
const containerStyle: CSS.Properties = {
|
136
|
+
display: 'flex',
|
137
|
+
alignItems: 'center',
|
138
|
+
justifyContent: 'center',
|
139
|
+
width: '100%',
|
140
|
+
height: '100%',
|
141
|
+
};
|
142
|
+
Object.assign(container.style, containerStyle);
|
143
|
+
|
144
|
+
const span = document.createElement('span');
|
145
|
+
const spanStyle: CSS.Properties = {
|
146
|
+
color: 'white',
|
147
|
+
background: 'red',
|
148
|
+
padding: '0.25rem',
|
149
|
+
fontSize: '12pt',
|
150
|
+
fontWeight: 'bold',
|
151
|
+
borderRadius: '2px',
|
152
|
+
fontFamily: "'Open Sans', sans-serif",
|
153
|
+
};
|
154
|
+
Object.assign(span.style, spanStyle);
|
155
|
+
|
156
|
+
span.textContent = 'ERROR';
|
157
|
+
container.appendChild(span);
|
158
|
+
|
159
|
+
return container;
|
160
|
+
};
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"renderUtils.test.js","sourceRoot":"","sources":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,CAAC;QAErC,OAAO,IAAA,aAAG,EAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC;KACvC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAdW,QAAA,YAAY,gBAcvB"}
|
@@ -1,29 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.readFile = void 0;
|
4
|
-
const readFile = (input) => new Promise((resolve, reject) => {
|
5
|
-
const fileReader = new FileReader();
|
6
|
-
fileReader.onload = (e) => {
|
7
|
-
if (e.target?.result) {
|
8
|
-
resolve(e.target.result);
|
9
|
-
}
|
10
|
-
};
|
11
|
-
fileReader.onerror = (e) => {
|
12
|
-
reject(new Error('[@pdfme/schemas] File reading failed'));
|
13
|
-
};
|
14
|
-
let file = null;
|
15
|
-
if (input instanceof FileList && input.length > 0) {
|
16
|
-
file = input[0];
|
17
|
-
}
|
18
|
-
else if (input instanceof File) {
|
19
|
-
file = input;
|
20
|
-
}
|
21
|
-
if (file) {
|
22
|
-
fileReader.readAsDataURL(file);
|
23
|
-
}
|
24
|
-
else {
|
25
|
-
reject(new Error('[@pdfme/schemas] No files provided'));
|
26
|
-
}
|
27
|
-
});
|
28
|
-
exports.readFile = readFile;
|
29
|
-
//# sourceMappingURL=uiRenderUtils.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"uiRenderUtils.js","sourceRoot":"","sources":["../../../src/uiRenderUtils.ts"],"names":[],"mappings":";;;AAAO,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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CAAC,EAAE,CAAC,CAAC;gBACf,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAEpB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;AAC7F,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,SAA6B,EAAE,EAAE;IAC5D,IAAI,SAAS,EAAE;QACb,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;QAEtC,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,2BAA2B,SAAS,EAAE,CAAC,CAAC;SACzD;QAED,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;QAErC,OAAO,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC;KACvC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
|
@@ -1,25 +0,0 @@
|
|
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
|
@@ -1 +0,0 @@
|
|
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 +0,0 @@
|
|
1
|
-
export declare const readFile: (input: File | FileList | null) => Promise<string | ArrayBuffer>;
|
package/src/uiRenderUtils.ts
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
export const readFile = (input: File | FileList | null): Promise<string | ArrayBuffer> =>
|
2
|
-
new Promise((resolve, reject) => {
|
3
|
-
const fileReader = new FileReader();
|
4
|
-
|
5
|
-
fileReader.onload = (e) => {
|
6
|
-
if (e.target?.result) {
|
7
|
-
resolve(e.target.result);
|
8
|
-
}
|
9
|
-
};
|
10
|
-
|
11
|
-
fileReader.onerror = (e) => {
|
12
|
-
reject(new Error('[@pdfme/schemas] File reading failed'));
|
13
|
-
};
|
14
|
-
|
15
|
-
let file: File | null = null;
|
16
|
-
if (input instanceof FileList && input.length > 0) {
|
17
|
-
file = input[0];
|
18
|
-
} else if (input instanceof File) {
|
19
|
-
file = input;
|
20
|
-
}
|
21
|
-
|
22
|
-
if (file) {
|
23
|
-
fileReader.readAsDataURL(file);
|
24
|
-
} else {
|
25
|
-
reject(new Error('[@pdfme/schemas] No files provided'));
|
26
|
-
}
|
27
|
-
});
|
File without changes
|