@pdfme/ui 1.0.3 → 1.0.4
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/index.js +1 -1
- package/dist/index.js.LICENSE.txt +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/helper.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/Preview/index.tsx +5 -2
- package/src/components/Root.tsx +0 -1
- package/src/components/Schemas/SchemaUI.tsx +1 -0
- package/src/components/Schemas/TextSchema.tsx +0 -1
- package/src/helper.ts +7 -0
package/dist/types/helper.d.ts
CHANGED
@@ -19,6 +19,7 @@ export declare const initShortCuts: (arg: {
|
|
19
19
|
}) => void;
|
20
20
|
export declare const destroyShortCuts: () => void;
|
21
21
|
export declare const readFiles: (files: FileList | null, type: 'text' | 'dataURL' | 'arrayBuffer') => Promise<string | ArrayBuffer>;
|
22
|
+
export declare const px2mm: (px: number) => number;
|
22
23
|
export declare const getPdfPageSizes: (pdfBlob: Blob) => Promise<{
|
23
24
|
height: number;
|
24
25
|
width: number;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pdfme/ui",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.4",
|
4
4
|
"author": "hand-dot",
|
5
5
|
"license": "MIT",
|
6
6
|
"description": "TypeScript base PDF generator and React base UI. Open source, developed by the community, and completely free to use under the MIT license!",
|
@@ -8,7 +8,7 @@ import Error from '../Error';
|
|
8
8
|
import Paper from '../Paper';
|
9
9
|
import SchemaUI from '../Schemas/SchemaUI';
|
10
10
|
import { useUIPreProcessor, useScrollPageCursor } from '../../hooks';
|
11
|
-
import { templateSchemas2SchemasList } from '../../helper';
|
11
|
+
import { templateSchemas2SchemasList, px2mm } from '../../helper';
|
12
12
|
|
13
13
|
const Preview = ({ template, inputs, size, onChangeInput }: PreviewReactProps) => {
|
14
14
|
const { backgrounds, pageSizes, scale, error } = useUIPreProcessor({
|
@@ -54,8 +54,11 @@ const Preview = ({ template, inputs, size, onChangeInput }: PreviewReactProps) =
|
|
54
54
|
<Root ref={rootRef} size={size} scale={scale}>
|
55
55
|
<div
|
56
56
|
style={{
|
57
|
-
height:
|
57
|
+
height:
|
58
|
+
pageSizes.reduce((acc, cur) => acc + (cur.height + px2mm(RULER_HEIGHT)) * scale, 0) +
|
59
|
+
'mm',
|
58
60
|
width: '100%',
|
61
|
+
top: 0,
|
59
62
|
position: 'absolute',
|
60
63
|
}}
|
61
64
|
>
|
package/src/components/Root.tsx
CHANGED
@@ -32,7 +32,6 @@ const TextSchemaUI = (
|
|
32
32
|
wordBreak: 'break-all',
|
33
33
|
background: 'transparent',
|
34
34
|
border: 'none',
|
35
|
-
outline: 'none',
|
36
35
|
color: schema.fontColor ? schema.fontColor : DEFAULT_FONT_COLOR,
|
37
36
|
backgroundColor: schema.data && schema.backgroundColor ? schema.backgroundColor : 'transparent',
|
38
37
|
};
|
package/src/helper.ts
CHANGED
@@ -233,6 +233,13 @@ const pt2mm = (pt: number) => {
|
|
233
233
|
return parseFloat(String(pt)) * mmRatio;
|
234
234
|
};
|
235
235
|
|
236
|
+
export const px2mm = (px: number) => {
|
237
|
+
// http://www.unitconversion.org/typography/millimeters-to-pixels-y-conversion.html
|
238
|
+
const mmRatio = 0.264583333;
|
239
|
+
|
240
|
+
return parseFloat(String(px)) * mmRatio;
|
241
|
+
};
|
242
|
+
|
236
243
|
export const getPdfPageSizes = async (pdfBlob: Blob) => {
|
237
244
|
const url = URL.createObjectURL(pdfBlob);
|
238
245
|
const pdfDoc = await getDocument({ url }).promise;
|