react-pdf-levelup 1.0.4 → 1.0.8
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.cjs +652 -0
- package/dist/index.d.cts +123 -0
- package/dist/index.d.ts +123 -0
- package/dist/index.js +575 -0
- package/package.json +8 -2
- package/fn/aggAlias.js +0 -21
- package/fn/moveComponents.js +0 -129
- package/fn/postinstall.js +0 -66
- package/fn/upVersion.js +0 -12
- package/fn/updateTsconfig.js +0 -10
- package/next.config.mjs +0 -6
- package/public/bg-login.jpg +0 -0
- package/public/codigo_guardado.js +0 -1
- package/public/css/style.css +0 -751
- package/public/dboard/logo.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/fonts/TimesNewerRoman-Bold.otf +0 -0
- package/public/fonts/TimesNewerRoman-BoldItalic.otf +0 -0
- package/public/fonts/TimesNewerRoman-Italic.otf +0 -0
- package/public/fonts/TimesNewerRoman-Regular.otf +0 -0
- package/public/header-pdf.jpg +0 -0
- package/public/home/bgHome.jpg +0 -0
- package/public/home/bgHome2.jpg +0 -0
- package/public/home/download.jpg +0 -0
- package/public/home/undraw_elements_re_25t9.svg +0 -1
- package/public/home/undraw_project_completed_re_jr7u.svg +0 -1
- package/public/home/undraw_shared_goals_re_jvqd.svg +0 -1
- package/public/home/undraw_spread_love_re_v3cl.svg +0 -1
- package/public/home/undraw_target_re_fi8j.svg +0 -1
- package/public/home/undraw_visionary_technology_re_jfp7.svg +0 -1
- package/public/logo.png +0 -0
- package/public/marca/logo.svg +0 -1
- package/src/components/PDF/components/DocumentoTemplate.tsx +0 -140
- package/src/components/PDF/components/PDFContent.tsx +0 -192
- package/src/components/PDF/core/Etiquetas.tsx +0 -152
- package/src/components/PDF/core/Grid.tsx +0 -101
- package/src/components/PDF/core/Img.tsx +0 -22
- package/src/components/PDF/core/LayoutPDF.tsx +0 -186
- package/src/components/PDF/core/Listas.tsx +0 -10
- package/src/components/PDF/core/MakePDF.tsx +0 -50
- package/src/components/PDF/core/PageElements.tsx +0 -50
- package/src/components/PDF/core/Position.tsx +0 -33
- package/src/components/PDF/core/Tablet.tsx +0 -121
- package/src/components/PDF/core/index.tsx +0 -56
- package/src/components/PDF/lib/pdfParser.ts +0 -620
- package/src/components/PDF/services/apiService.ts +0 -17
- package/src/components/PDF/templates/AllTemplate.tsx +0 -134
- package/src/components/PDF/templates/BusinessCardTemplate.tsx +0 -139
- package/src/components/PDF/templates/CertificateTemplate.tsx +0 -31
- package/src/components/PDF/templates/HeaderFooterTemplate.tsx +0 -61
- package/src/components/PDF/templates/InvoiceTemplate.tsx +0 -53
- package/src/components/PDF/templates/ProposalTemplate.tsx +0 -246
- package/src/components/PDF/templates/ReportTemplate.tsx +0 -57
- package/src/components/PDF/templates/ResumeTemplate.tsx +0 -170
- package/src/components/PDF/templates/TablasTemplate.tsx +0 -307
- package/src/components/PDF/templates/index.ts +0 -9
- package/src/components/PDF/view/ColorPicker.tsx +0 -147
- package/src/components/PDF/view/Header.tsx +0 -102
- package/src/components/PDF/view/HomePDF.tsx +0 -177
- package/src/components/PDF/view/SettingsPanel.tsx +0 -703
- package/src/pages/AllTemplate.tsx +0 -53
- package/src/pages/Documento2.tsx +0 -45
- package/src/pages/_app.tsx +0 -6
- package/src/pages/_document.tsx +0 -13
- package/src/pages/api/generatePDF.ts +0 -74
- package/src/pages/api/hello.ts +0 -13
- package/src/pages/api/readFile.ts +0 -18
- package/src/pages/api/readTemplateFile.ts +0 -26
- package/src/pages/api/save.ts +0 -22
- package/src/pages/api/saveFile.ts +0 -20
- package/src/pages/index.tsx +0 -13
- package/src/pages/template/[template].tsx +0 -250
- package/tsconfig.json +0 -63
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import type React from "react"
|
|
2
|
-
import { Text, StyleSheet, Link } from "@react-pdf/renderer"
|
|
3
|
-
|
|
4
|
-
interface TextProps {
|
|
5
|
-
children: React.ReactNode
|
|
6
|
-
style?: any
|
|
7
|
-
href?: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const styles = StyleSheet.create({
|
|
11
|
-
p: {
|
|
12
|
-
fontSize: 12,
|
|
13
|
-
marginBottom: 14,
|
|
14
|
-
lineHeight: 1.5,
|
|
15
|
-
},
|
|
16
|
-
h1: {
|
|
17
|
-
fontSize: 24,
|
|
18
|
-
fontWeight: "bold",
|
|
19
|
-
marginBottom: 12,
|
|
20
|
-
},
|
|
21
|
-
h2: {
|
|
22
|
-
fontSize: 20,
|
|
23
|
-
fontWeight: "bold",
|
|
24
|
-
marginBottom: 10,
|
|
25
|
-
},
|
|
26
|
-
h3: {
|
|
27
|
-
fontSize: 18,
|
|
28
|
-
fontWeight: "bold",
|
|
29
|
-
marginBottom: 8,
|
|
30
|
-
},
|
|
31
|
-
h4: {
|
|
32
|
-
fontSize: 16,
|
|
33
|
-
fontWeight: "bold",
|
|
34
|
-
marginBottom: 6,
|
|
35
|
-
},
|
|
36
|
-
h5: {
|
|
37
|
-
fontSize: 14,
|
|
38
|
-
fontWeight: "bold",
|
|
39
|
-
marginBottom: 4,
|
|
40
|
-
},
|
|
41
|
-
h6: {
|
|
42
|
-
fontSize: 12,
|
|
43
|
-
fontWeight: "bold",
|
|
44
|
-
marginBottom: 0,
|
|
45
|
-
},
|
|
46
|
-
strong: {
|
|
47
|
-
fontWeight: "bold",
|
|
48
|
-
},
|
|
49
|
-
em: {
|
|
50
|
-
fontStyle: "italic",
|
|
51
|
-
},
|
|
52
|
-
u: {
|
|
53
|
-
textDecoration: "underline",
|
|
54
|
-
},
|
|
55
|
-
small: {
|
|
56
|
-
fontSize: 10,
|
|
57
|
-
},
|
|
58
|
-
blockquote: {
|
|
59
|
-
marginLeft: 20,
|
|
60
|
-
marginRight: 20,
|
|
61
|
-
fontStyle: "italic",
|
|
62
|
-
borderLeft: "4px solid #ccc",
|
|
63
|
-
paddingLeft: 10,
|
|
64
|
-
},
|
|
65
|
-
mark: {
|
|
66
|
-
backgroundColor: "yellow",
|
|
67
|
-
},
|
|
68
|
-
A: {
|
|
69
|
-
color: "#3d65fd",
|
|
70
|
-
textDecoration: "none",
|
|
71
|
-
},
|
|
72
|
-
br: {
|
|
73
|
-
width: "100%",
|
|
74
|
-
height: 1,
|
|
75
|
-
marginTop: 7,
|
|
76
|
-
marginBottom: 7,
|
|
77
|
-
},
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
const P: React.FC<TextProps> = ({ children, style }) => {
|
|
81
|
-
return <Text style={[styles.p, style]}>{children}</Text>
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const H1: React.FC<TextProps> = ({ children, style }) => {
|
|
85
|
-
return <Text style={[styles.h1, style]}>{children}</Text>
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const H2: React.FC<TextProps> = ({ children, style }) => {
|
|
89
|
-
return <Text style={[styles.h2, style]}>{children}</Text>
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const H3: React.FC<TextProps> = ({ children, style }) => {
|
|
93
|
-
return <Text style={[styles.h3, style]}>{children}</Text>
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const H4: React.FC<TextProps> = ({ children, style }) => {
|
|
97
|
-
return <Text style={[styles.h4, style]}>{children}</Text>
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const H5: React.FC<TextProps> = ({ children, style }) => {
|
|
101
|
-
return <Text style={[styles.h5, style]}>{children}</Text>
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const H6: React.FC<TextProps> = ({ children, style }) => {
|
|
105
|
-
return <Text style={[styles.h6, style]}>{children}</Text>
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const Strong: React.FC<TextProps> = ({ children, style }) => {
|
|
109
|
-
return <Text style={[styles.strong, style]}>{children}</Text>
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const Em: React.FC<TextProps> = ({ children, style }) => {
|
|
113
|
-
return <Text style={[styles.em, style]}>{children}</Text>
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const U: React.FC<TextProps> = ({ children, style }) => {
|
|
117
|
-
return <Text style={[styles.u, style]}>{children}</Text>
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const Small: React.FC<TextProps> = ({ children, style }) => {
|
|
121
|
-
return <Text style={[styles.small, style]}>{children}</Text>
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const Blockquote: React.FC<TextProps> = ({ children, style }) => {
|
|
125
|
-
return <Text style={[styles.blockquote, style]}>{children}</Text>
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const Mark: React.FC<TextProps> = ({ children, style }) => {
|
|
129
|
-
return <Text style={[styles.mark, style]}>{children}</Text>
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const A: React.FC<TextProps> = ({ children, style, href }) => {
|
|
133
|
-
return (
|
|
134
|
-
<Link src={href} style={[styles.A, style]}>
|
|
135
|
-
{children}
|
|
136
|
-
</Link>
|
|
137
|
-
)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Add BR component for line breaks
|
|
141
|
-
const BR: React.FC<{ style?: any }> = ({ style }) => {
|
|
142
|
-
return <Text style={[styles.br, style]}>{"\n"}</Text>
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Agregar la etiqueta Span después de la etiqueta Mark
|
|
146
|
-
const Span: React.FC<TextProps> = ({ children, style }) => {
|
|
147
|
-
return <Text style={[style]}>{children}</Text>
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Exportar la etiqueta Span junto con las demás
|
|
151
|
-
export { P, A, H1, H2, H3, H4, H5, H6, Strong, Em, U, Small, Blockquote, Mark, Span, BR }
|
|
152
|
-
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import type React from "react"
|
|
2
|
-
import { View, StyleSheet } from "@react-pdf/renderer"
|
|
3
|
-
|
|
4
|
-
interface ContainerProps {
|
|
5
|
-
children: React.ReactNode
|
|
6
|
-
style?: any
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface RowProps {
|
|
10
|
-
children: React.ReactNode
|
|
11
|
-
style?: any
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface ColProps {
|
|
15
|
-
children: React.ReactNode
|
|
16
|
-
style?: any
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const styles = StyleSheet.create({
|
|
20
|
-
container: {
|
|
21
|
-
width: "100%",
|
|
22
|
-
paddingHorizontal: 20,
|
|
23
|
-
},
|
|
24
|
-
row: {
|
|
25
|
-
flexDirection: "row",
|
|
26
|
-
flexWrap: "wrap",
|
|
27
|
-
marginHorizontal: -5, // Negative margin to offset column padding
|
|
28
|
-
},
|
|
29
|
-
col: {
|
|
30
|
-
paddingHorizontal: 5,
|
|
31
|
-
},
|
|
32
|
-
col1: { width: "8.33%" },
|
|
33
|
-
col2: { width: "16.66%" },
|
|
34
|
-
col3: { width: "25%" },
|
|
35
|
-
col4: { width: "33.33%" },
|
|
36
|
-
col5: { width: "41.66%" },
|
|
37
|
-
col6: { width: "50%" },
|
|
38
|
-
col7: { width: "58.33%" },
|
|
39
|
-
col8: { width: "66.66%" },
|
|
40
|
-
col9: { width: "75%" },
|
|
41
|
-
col10: { width: "83.33%" },
|
|
42
|
-
col11: { width: "91.66%" },
|
|
43
|
-
col12: { width: "100%" },
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
export const Container: React.FC<ContainerProps> = ({ children, style }) => {
|
|
47
|
-
return <View style={[styles.container, style]}>{children}</View>
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export const Row: React.FC<RowProps> = ({ children, style }) => {
|
|
51
|
-
return <View style={[styles.row, style]}>{children}</View>
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export const Col1: React.FC<ColProps> = ({ children, style }) => {
|
|
55
|
-
return <View style={[styles.col, styles.col1, style]}>{children}</View>
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const Col2: React.FC<ColProps> = ({ children, style }) => {
|
|
59
|
-
return <View style={[styles.col, styles.col2, style]}>{children}</View>
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export const Col3: React.FC<ColProps> = ({ children, style }) => {
|
|
63
|
-
return <View style={[styles.col, styles.col3, style]}>{children}</View>
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export const Col4: React.FC<ColProps> = ({ children, style }) => {
|
|
67
|
-
return <View style={[styles.col, styles.col4, style]}>{children}</View>
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export const Col5: React.FC<ColProps> = ({ children, style }) => {
|
|
71
|
-
return <View style={[styles.col, styles.col5, style]}>{children}</View>
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export const Col6: React.FC<ColProps> = ({ children, style }) => {
|
|
75
|
-
return <View style={[styles.col, styles.col6, style]}>{children}</View>
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export const Col7: React.FC<ColProps> = ({ children, style }) => {
|
|
79
|
-
return <View style={[styles.col, styles.col7, style]}>{children}</View>
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export const Col8: React.FC<ColProps> = ({ children, style }) => {
|
|
83
|
-
return <View style={[styles.col, styles.col8, style]}>{children}</View>
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export const Col9: React.FC<ColProps> = ({ children, style }) => {
|
|
87
|
-
return <View style={[styles.col, styles.col9, style]}>{children}</View>
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export const Col10: React.FC<ColProps> = ({ children, style }) => {
|
|
91
|
-
return <View style={[styles.col, styles.col10, style]}>{children}</View>
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export const Col11: React.FC<ColProps> = ({ children, style }) => {
|
|
95
|
-
return <View style={[styles.col, styles.col11, style]}>{children}</View>
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export const Col12: React.FC<ColProps> = ({ children, style }) => {
|
|
99
|
-
return <View style={[styles.col, styles.col12, style]}>{children}</View>
|
|
100
|
-
}
|
|
101
|
-
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Image, StyleSheet } from '@react-pdf/renderer';
|
|
3
|
-
|
|
4
|
-
interface ImgProps {
|
|
5
|
-
src?: string;
|
|
6
|
-
alt?: string;
|
|
7
|
-
style?: any;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const styles = StyleSheet.create({
|
|
11
|
-
image: {
|
|
12
|
-
width: '100%',
|
|
13
|
-
height: 'auto',
|
|
14
|
-
marginBottom: 14,
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const Img: React.FC<ImgProps> = ({ src, alt, style }) => {
|
|
19
|
-
return <Image src={src} style={[styles.image, style]} />;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default Img;
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import type React from "react"
|
|
2
|
-
import { Page, Document, StyleSheet, Font, Text } from "@react-pdf/renderer"
|
|
3
|
-
|
|
4
|
-
Font.register({
|
|
5
|
-
family: "Times New Roman",
|
|
6
|
-
fonts: [
|
|
7
|
-
{ src: "/fonts/TimesNewerRoman-Regular.otf", fontWeight: 400, fontStyle: "normal" },
|
|
8
|
-
{ src: "/fonts/TimesNewerRoman-Bold.otf", fontWeight: 700, fontStyle: "normal" },
|
|
9
|
-
{ src: "/fonts/TimesNewerRoman-Italic.otf", fontWeight: 400, fontStyle: "italic" },
|
|
10
|
-
{ src: "/fonts/TimesNewerRoman-BoldItalic.otf", fontWeight: 700, fontStyle: "italic" }, // Bold Italic
|
|
11
|
-
],
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
// Definir dimensiones de papel en puntos (1 mm ≈ 2.83 puntos)
|
|
15
|
-
const PAPER_SIZES = {
|
|
16
|
-
A0: [2384, 3370], // 841 × 1189 mm
|
|
17
|
-
A1: [1684, 2384], // 594 × 841 mm
|
|
18
|
-
A2: [1191, 1684], // 420 × 594 mm
|
|
19
|
-
A3: [842, 1191], // 297 × 420 mm
|
|
20
|
-
A4: [595, 842], // 210 × 297 mm
|
|
21
|
-
A5: [420, 595], // 148 × 210 mm
|
|
22
|
-
A6: [298, 420], // 105 × 148 mm
|
|
23
|
-
A7: [210, 298], // 74 × 105 mm
|
|
24
|
-
A8: [147, 210], // 52 × 74 mm
|
|
25
|
-
A9: [105, 147], // 37 × 52 mm
|
|
26
|
-
A10: [74, 105], // 26 × 37 mm
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const styles = StyleSheet.create({
|
|
30
|
-
page: {
|
|
31
|
-
backgroundColor: "white",
|
|
32
|
-
padding: 72,
|
|
33
|
-
paddingBottom: 72 + 14,
|
|
34
|
-
fontFamily: "Times New Roman",
|
|
35
|
-
fontSize: 12,
|
|
36
|
-
lineHeight: 1.5,
|
|
37
|
-
position: "relative",
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
pageNumber: {
|
|
41
|
-
position: "absolute",
|
|
42
|
-
fontSize: 10,
|
|
43
|
-
top: 792 - 14,
|
|
44
|
-
left: 0,
|
|
45
|
-
right: 0,
|
|
46
|
-
textAlign: "center",
|
|
47
|
-
color: "grey",
|
|
48
|
-
},
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
interface LayoutPDFProps {
|
|
52
|
-
children: React.ReactNode
|
|
53
|
-
size?: string // 'A4', 'A5', 'LETTER', etc.
|
|
54
|
-
orientation?: "portrait" | "landscape"
|
|
55
|
-
backgroundColor?: string
|
|
56
|
-
showPageNumbers?: boolean
|
|
57
|
-
padding?: number | string
|
|
58
|
-
paddingTop?: number
|
|
59
|
-
paddingRight?: number
|
|
60
|
-
paddingBottom?: number
|
|
61
|
-
paddingLeft?: number
|
|
62
|
-
style?: any
|
|
63
|
-
width?: number // Custom width in points
|
|
64
|
-
height?: number // Custom height in points
|
|
65
|
-
fontFamily?: string
|
|
66
|
-
fontSize?: number
|
|
67
|
-
lineHeight?: number
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Update the LayoutPDF component to properly handle all props
|
|
71
|
-
const LayoutPDF: React.FC<LayoutPDFProps> = ({
|
|
72
|
-
children,
|
|
73
|
-
size = "A4",
|
|
74
|
-
orientation = "portrait",
|
|
75
|
-
backgroundColor = "white",
|
|
76
|
-
showPageNumbers = true,
|
|
77
|
-
padding = 72,
|
|
78
|
-
paddingTop,
|
|
79
|
-
paddingRight,
|
|
80
|
-
paddingBottom,
|
|
81
|
-
paddingLeft,
|
|
82
|
-
style = {},
|
|
83
|
-
width,
|
|
84
|
-
height,
|
|
85
|
-
fontFamily = "Helvetica",
|
|
86
|
-
fontSize = 12,
|
|
87
|
-
lineHeight = 1.5,
|
|
88
|
-
}) => {
|
|
89
|
-
// Create page style with all the props
|
|
90
|
-
const pageStyle = {
|
|
91
|
-
...styles.page,
|
|
92
|
-
backgroundColor,
|
|
93
|
-
fontFamily,
|
|
94
|
-
fontSize,
|
|
95
|
-
lineHeight,
|
|
96
|
-
...style,
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Handle padding
|
|
100
|
-
if (
|
|
101
|
-
paddingTop !== undefined ||
|
|
102
|
-
paddingRight !== undefined ||
|
|
103
|
-
paddingBottom !== undefined ||
|
|
104
|
-
paddingLeft !== undefined
|
|
105
|
-
) {
|
|
106
|
-
// Individual padding values
|
|
107
|
-
if (paddingTop !== undefined) pageStyle.paddingTop = paddingTop
|
|
108
|
-
if (paddingRight !== undefined) pageStyle.paddingRight = paddingRight
|
|
109
|
-
if (paddingBottom !== undefined) pageStyle.paddingBottom = paddingBottom
|
|
110
|
-
if (paddingLeft !== undefined) pageStyle.paddingLeft = paddingLeft
|
|
111
|
-
} else {
|
|
112
|
-
// Uniform padding
|
|
113
|
-
pageStyle.padding = padding
|
|
114
|
-
if (showPageNumbers) {
|
|
115
|
-
pageStyle.paddingBottom = Number(padding) + 14
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Determine the props to pass to the Page component
|
|
120
|
-
let pageProps: any = {}
|
|
121
|
-
|
|
122
|
-
// Check if we need to use custom paper size dimensions
|
|
123
|
-
const customSize = PAPER_SIZES[size.toUpperCase() as keyof typeof PAPER_SIZES]
|
|
124
|
-
|
|
125
|
-
if (customSize) {
|
|
126
|
-
// Use custom dimensions for the paper size
|
|
127
|
-
const [pageWidth, pageHeight] = customSize
|
|
128
|
-
|
|
129
|
-
if (orientation === "landscape") {
|
|
130
|
-
pageProps = {
|
|
131
|
-
style: pageStyle,
|
|
132
|
-
size: [pageHeight, pageWidth],
|
|
133
|
-
}
|
|
134
|
-
} else {
|
|
135
|
-
pageProps = {
|
|
136
|
-
style: pageStyle,
|
|
137
|
-
size: [pageWidth, pageHeight],
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
console.log(`Using custom size for ${size}: ${JSON.stringify(pageProps.size)}`)
|
|
142
|
-
} else if (width && height) {
|
|
143
|
-
// If explicit width and height are provided
|
|
144
|
-
pageProps = {
|
|
145
|
-
style: pageStyle,
|
|
146
|
-
size: [width, height],
|
|
147
|
-
}
|
|
148
|
-
} else {
|
|
149
|
-
// Use standard size and orientation
|
|
150
|
-
pageProps = {
|
|
151
|
-
size,
|
|
152
|
-
orientation,
|
|
153
|
-
style: pageStyle,
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Adjust page number position based on page size
|
|
158
|
-
let pageNumberStyle = { ...styles.pageNumber }
|
|
159
|
-
|
|
160
|
-
if (customSize) {
|
|
161
|
-
const [pageWidth, pageHeight] = customSize
|
|
162
|
-
const actualHeight = orientation === "landscape" ? pageWidth : pageHeight
|
|
163
|
-
pageNumberStyle = {
|
|
164
|
-
...pageNumberStyle,
|
|
165
|
-
top: actualHeight - 80,
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return (
|
|
170
|
-
<Document>
|
|
171
|
-
<Page {...pageProps}>
|
|
172
|
-
{children}
|
|
173
|
-
{(
|
|
174
|
-
<Text
|
|
175
|
-
style={pageNumberStyle}
|
|
176
|
-
render={({ pageNumber, totalPages }) => `${pageNumber} / ${totalPages}`}
|
|
177
|
-
fixed
|
|
178
|
-
/>
|
|
179
|
-
)}
|
|
180
|
-
</Page>
|
|
181
|
-
</Document>
|
|
182
|
-
)
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export default LayoutPDF
|
|
186
|
-
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import dynamic from 'next/dynamic';
|
|
3
|
-
import { BlobProvider } from "@react-pdf/renderer";
|
|
4
|
-
// import { BtnNormalBasic} from "@btn";
|
|
5
|
-
|
|
6
|
-
interface MakePDFProps {
|
|
7
|
-
namePDF?: string;
|
|
8
|
-
document: React.ReactElement;
|
|
9
|
-
children?: React.ReactNode;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const MakePDF: React.FC<MakePDFProps> = ({ namePDF = "documento.pdf", document, children = "Descargar PDF" }) => {
|
|
13
|
-
// Verifica si estamos en un entorno de navegador
|
|
14
|
-
if (typeof window === 'undefined') {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<BlobProvider document={document}>
|
|
20
|
-
{({ blob, url, loading, error }) => {
|
|
21
|
-
// Si el PDF aún se está generando, muestra un texto de carga
|
|
22
|
-
if (loading) {
|
|
23
|
-
return "Cargando documento...";
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Si hay un error, muéstralo
|
|
27
|
-
if (error) {
|
|
28
|
-
return `Error: ${error.message}`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Crea una URL para el blob
|
|
32
|
-
let pdfURL = "";
|
|
33
|
-
if (blob !== null) {
|
|
34
|
-
pdfURL = URL.createObjectURL(blob);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Cuando el PDF esté listo, muestra un enlace para descargarlo
|
|
38
|
-
return (
|
|
39
|
-
<div className="containerDownload">
|
|
40
|
-
<a href={pdfURL} download={namePDF}>
|
|
41
|
-
{children}
|
|
42
|
-
</a>
|
|
43
|
-
</div>
|
|
44
|
-
);
|
|
45
|
-
}}
|
|
46
|
-
</BlobProvider>
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export default dynamic(() => Promise.resolve(MakePDF), { ssr: false });
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type React from "react"
|
|
2
|
-
import { Text, View, StyleSheet } from "@react-pdf/renderer"
|
|
3
|
-
|
|
4
|
-
interface PageElementProps {
|
|
5
|
-
children: React.ReactNode
|
|
6
|
-
style?: any
|
|
7
|
-
fixed?: boolean
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const styles = StyleSheet.create({
|
|
11
|
-
header: {
|
|
12
|
-
position: "absolute",
|
|
13
|
-
top: 20,
|
|
14
|
-
left: 0,
|
|
15
|
-
right: 0,
|
|
16
|
-
textAlign: "center",
|
|
17
|
-
fontSize: 10,
|
|
18
|
-
color: "#666",
|
|
19
|
-
paddingHorizontal: 40,
|
|
20
|
-
},
|
|
21
|
-
footer: {
|
|
22
|
-
position: "absolute",
|
|
23
|
-
bottom: 20,
|
|
24
|
-
left: 0,
|
|
25
|
-
right: 0,
|
|
26
|
-
textAlign: "center",
|
|
27
|
-
fontSize: 10,
|
|
28
|
-
color: "#666",
|
|
29
|
-
paddingHorizontal: 40,
|
|
30
|
-
},
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
const Header: React.FC<PageElementProps> = ({ children, style, fixed = false }) => {
|
|
34
|
-
return (
|
|
35
|
-
<View style={[styles.header, style]} fixed={fixed}>
|
|
36
|
-
{typeof children === "string" ? <Text>{children}</Text> : children}
|
|
37
|
-
</View>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const Footer: React.FC<PageElementProps> = ({ children, style, fixed = false }) => {
|
|
42
|
-
return (
|
|
43
|
-
<View style={[styles.footer, style]} fixed={fixed}>
|
|
44
|
-
{typeof children === "string" ? <Text>{children}</Text> : children}
|
|
45
|
-
</View>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export { Header, Footer }
|
|
50
|
-
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { View, StyleSheet } from '@react-pdf/renderer';
|
|
3
|
-
|
|
4
|
-
interface PositionProps {
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
style?: any;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const styles = StyleSheet.create({
|
|
10
|
-
left: {
|
|
11
|
-
textAlign: 'left',
|
|
12
|
-
},
|
|
13
|
-
right: {
|
|
14
|
-
textAlign: 'right',
|
|
15
|
-
},
|
|
16
|
-
center: {
|
|
17
|
-
textAlign: 'center',
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const Left: React.FC<PositionProps> = ({ children, style }) => {
|
|
22
|
-
return <View style={[styles.left, style]}>{children}</View>;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const Right: React.FC<PositionProps> = ({ children, style }) => {
|
|
26
|
-
return <View style={[styles.right, style]}>{children}</View>;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const Center: React.FC<PositionProps> = ({ children, style }) => {
|
|
30
|
-
return <View style={[styles.center, style]}>{children}</View>;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export { Left, Right, Center };
|