react-pdf-levelup 3.1.54 → 3.1.59
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 +75 -2
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +74 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -56,6 +56,7 @@ __export(index_exports, {
|
|
|
56
56
|
H4: () => H4,
|
|
57
57
|
H5: () => H5,
|
|
58
58
|
H6: () => H6,
|
|
59
|
+
HR: () => HR,
|
|
59
60
|
Header: () => Header,
|
|
60
61
|
Img: () => Img_default,
|
|
61
62
|
ImgBg: () => ImgBg_default,
|
|
@@ -115,7 +116,8 @@ var LayoutPDF = ({
|
|
|
115
116
|
style = {},
|
|
116
117
|
pagination = true,
|
|
117
118
|
footer,
|
|
118
|
-
lines = footer ? 2 : 1
|
|
119
|
+
lines = footer ? 2 : 1,
|
|
120
|
+
rule = false
|
|
119
121
|
}) => {
|
|
120
122
|
const LINE_HEIGHT = 20;
|
|
121
123
|
const FOOTER_PADDING = 10;
|
|
@@ -236,6 +238,67 @@ var LayoutPDF = ({
|
|
|
236
238
|
const pdfOrientation = transformOrientation(safeOrientation);
|
|
237
239
|
const margins = getMargins(safeMargen, safeSize);
|
|
238
240
|
const footerTop = getFooterPosition(safeSize, pdfOrientation, footerHeight);
|
|
241
|
+
const renderGrid = () => {
|
|
242
|
+
if (!rule) return null;
|
|
243
|
+
const cmToPoints = 28.3465;
|
|
244
|
+
const pageDimensions = {
|
|
245
|
+
A0: { width: 841 * 2.834645669, height: 1189 * 2.834645669 },
|
|
246
|
+
A1: { width: 594 * 2.834645669, height: 841 * 2.834645669 },
|
|
247
|
+
A2: { width: 420 * 2.834645669, height: 594 * 2.834645669 },
|
|
248
|
+
A3: { width: 297 * 2.834645669, height: 420 * 2.834645669 },
|
|
249
|
+
A4: { width: 210 * 2.834645669, height: 297 * 2.834645669 },
|
|
250
|
+
A5: { width: 148 * 2.834645669, height: 210 * 2.834645669 },
|
|
251
|
+
A6: { width: 105 * 2.834645669, height: 148 * 2.834645669 },
|
|
252
|
+
A7: { width: 74 * 2.834645669, height: 105 * 2.834645669 },
|
|
253
|
+
A8: { width: 52 * 2.834645669, height: 74 * 2.834645669 },
|
|
254
|
+
A9: { width: 37 * 2.834645669, height: 52 * 2.834645669 },
|
|
255
|
+
LETTER: { width: 216 * 2.834645669, height: 279 * 2.834645669 },
|
|
256
|
+
LEGAL: { width: 216 * 2.834645669, height: 356 * 2.834645669 },
|
|
257
|
+
TABLOID: { width: 279 * 2.834645669, height: 432 * 2.834645669 }
|
|
258
|
+
};
|
|
259
|
+
const dimensions = pageDimensions[safeSize.toUpperCase()] || pageDimensions.A4;
|
|
260
|
+
const pageWidth = pdfOrientation === "landscape" ? dimensions.height : dimensions.width;
|
|
261
|
+
const pageHeight = pdfOrientation === "landscape" ? dimensions.width : dimensions.height;
|
|
262
|
+
const horizontalLines = [];
|
|
263
|
+
const verticalLines = [];
|
|
264
|
+
for (let i = 0; i <= Math.ceil(pageHeight / cmToPoints); i++) {
|
|
265
|
+
horizontalLines.push(
|
|
266
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
267
|
+
import_renderer.View,
|
|
268
|
+
{
|
|
269
|
+
key: `h-${i}`,
|
|
270
|
+
style: {
|
|
271
|
+
position: "absolute",
|
|
272
|
+
top: i * cmToPoints,
|
|
273
|
+
left: 0,
|
|
274
|
+
right: 0,
|
|
275
|
+
height: i % 5 === 0 ? 1 : 0.5,
|
|
276
|
+
backgroundColor: i % 5 === 0 ? "rgba(255, 0, 0, 0.8)" : "rgba(100, 100, 100, 0.5)"
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
)
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
for (let i = 0; i <= Math.ceil(pageWidth / cmToPoints); i++) {
|
|
283
|
+
verticalLines.push(
|
|
284
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
285
|
+
import_renderer.View,
|
|
286
|
+
{
|
|
287
|
+
key: `v-${i}`,
|
|
288
|
+
style: {
|
|
289
|
+
position: "absolute",
|
|
290
|
+
left: i * cmToPoints,
|
|
291
|
+
top: 0,
|
|
292
|
+
bottom: 0,
|
|
293
|
+
width: i % 5 === 0 ? 1 : 0.5,
|
|
294
|
+
backgroundColor: i % 5 === 0 ? "rgba(255, 0, 0, 0.8)" : "rgba(100, 100, 100, 0.5)"
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
)
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
return /* @__PURE__ */ import_react.default.createElement(import_renderer.View, { style: { position: "absolute", top: 0, left: 0, right: 0, bottom: 0 }, fixed: true }, horizontalLines, verticalLines);
|
|
301
|
+
};
|
|
239
302
|
const pageStyle = {
|
|
240
303
|
...styles.page,
|
|
241
304
|
backgroundColor: safeBackgroundColor,
|
|
@@ -254,7 +317,7 @@ var LayoutPDF = ({
|
|
|
254
317
|
fontSize: 10,
|
|
255
318
|
color: "grey"
|
|
256
319
|
};
|
|
257
|
-
return /* @__PURE__ */ import_react.default.createElement(import_renderer.Document, null, /* @__PURE__ */ import_react.default.createElement(import_renderer.Page, { size: safeSize, orientation: pdfOrientation, style: pageStyle, wrap: true }, /* @__PURE__ */ import_react.default.createElement(import_renderer.View, { style: { paddingBottom: footerHeight } }, children), pagination ? /* @__PURE__ */ import_react.default.createElement(import_renderer.View, { style: footerStyle, fixed: true }, footer, /* @__PURE__ */ import_react.default.createElement(import_renderer.Text, { style: { fontSize: footerStyle.fontSize }, render: ({ pageNumber, totalPages }) => `${pageNumber} / ${totalPages}` })) : null));
|
|
320
|
+
return /* @__PURE__ */ import_react.default.createElement(import_renderer.Document, null, /* @__PURE__ */ import_react.default.createElement(import_renderer.Page, { size: safeSize, orientation: pdfOrientation, style: pageStyle, wrap: true }, renderGrid(), /* @__PURE__ */ import_react.default.createElement(import_renderer.View, { style: { paddingBottom: footerHeight } }, children), pagination ? /* @__PURE__ */ import_react.default.createElement(import_renderer.View, { style: footerStyle, fixed: true }, footer, /* @__PURE__ */ import_react.default.createElement(import_renderer.Text, { style: { fontSize: footerStyle.fontSize }, render: ({ pageNumber, totalPages }) => `${pageNumber} / ${totalPages}` })) : null));
|
|
258
321
|
};
|
|
259
322
|
var LayoutPDF_default = LayoutPDF;
|
|
260
323
|
|
|
@@ -377,6 +440,12 @@ var styles4 = import_renderer4.StyleSheet.create({
|
|
|
377
440
|
fontSize: 10,
|
|
378
441
|
color: "#666",
|
|
379
442
|
paddingHorizontal: 40
|
|
443
|
+
},
|
|
444
|
+
hr: {
|
|
445
|
+
width: "100%",
|
|
446
|
+
borderTop: "1px solid #000",
|
|
447
|
+
marginTop: 8,
|
|
448
|
+
marginBottom: 8
|
|
380
449
|
}
|
|
381
450
|
});
|
|
382
451
|
var P = ({ children, style }) => {
|
|
@@ -424,6 +493,9 @@ var A = ({ children, style, href }) => {
|
|
|
424
493
|
var BR = ({ style }) => {
|
|
425
494
|
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, { style: [styles4.br, style] }, "\n");
|
|
426
495
|
};
|
|
496
|
+
var HR = ({ style }) => {
|
|
497
|
+
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.View, { style: [styles4.hr, style] });
|
|
498
|
+
};
|
|
427
499
|
var Span = ({ children, style }) => {
|
|
428
500
|
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, { style: [style] }, children);
|
|
429
501
|
};
|
|
@@ -1027,6 +1099,7 @@ var ImgBg_default = ImgBg;
|
|
|
1027
1099
|
H4,
|
|
1028
1100
|
H5,
|
|
1029
1101
|
H6,
|
|
1102
|
+
HR,
|
|
1030
1103
|
Header,
|
|
1031
1104
|
Img,
|
|
1032
1105
|
ImgBg,
|
package/dist/index.d.cts
CHANGED
|
@@ -9,9 +9,10 @@ interface LayoutPDFProps {
|
|
|
9
9
|
padding?: number;
|
|
10
10
|
margen?: "apa" | "normal" | "estrecho" | "ancho";
|
|
11
11
|
style?: any;
|
|
12
|
-
pagination:
|
|
12
|
+
pagination: boolean;
|
|
13
13
|
footer?: React$1.ReactNode;
|
|
14
14
|
lines?: number;
|
|
15
|
+
rule?: boolean;
|
|
15
16
|
}
|
|
16
17
|
declare const LayoutPDF: React$1.FC<LayoutPDFProps>;
|
|
17
18
|
|
|
@@ -60,6 +61,9 @@ declare const A: React$1.FC<TextProps>;
|
|
|
60
61
|
declare const BR: React$1.FC<{
|
|
61
62
|
style?: any;
|
|
62
63
|
}>;
|
|
64
|
+
declare const HR: React$1.FC<{
|
|
65
|
+
style?: any;
|
|
66
|
+
}>;
|
|
63
67
|
declare const Span: React$1.FC<TextProps>;
|
|
64
68
|
declare const Header: React$1.FC<HeaderProps>;
|
|
65
69
|
declare const Div: React$1.FC<DivProps>;
|
|
@@ -177,4 +181,4 @@ interface ImgBgProps {
|
|
|
177
181
|
}
|
|
178
182
|
declare const ImgBg: React$1.FC<ImgBgProps>;
|
|
179
183
|
|
|
180
|
-
export { A, BR, Blockquote, Center, Col1, Col10, Col11, Col12, Col2, Col3, Col4, Col5, Col6, Col7, Col8, Col9, Container, Div, Em, H1, H2, H3, H4, H5, H6, Header, Img, ImgBg, LI, LayoutPDF, Left, Mark, OL, P, QR, Right, Row, Small, Span, Strong, Table, Tbody, Td, Th, Thead, Tr, U, UL, decodeBase64Pdf, generatePDF };
|
|
184
|
+
export { A, BR, Blockquote, Center, Col1, Col10, Col11, Col12, Col2, Col3, Col4, Col5, Col6, Col7, Col8, Col9, Container, Div, Em, H1, H2, H3, H4, H5, H6, HR, Header, Img, ImgBg, LI, LayoutPDF, Left, Mark, OL, P, QR, Right, Row, Small, Span, Strong, Table, Tbody, Td, Th, Thead, Tr, U, UL, decodeBase64Pdf, generatePDF };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,9 +9,10 @@ interface LayoutPDFProps {
|
|
|
9
9
|
padding?: number;
|
|
10
10
|
margen?: "apa" | "normal" | "estrecho" | "ancho";
|
|
11
11
|
style?: any;
|
|
12
|
-
pagination:
|
|
12
|
+
pagination: boolean;
|
|
13
13
|
footer?: React$1.ReactNode;
|
|
14
14
|
lines?: number;
|
|
15
|
+
rule?: boolean;
|
|
15
16
|
}
|
|
16
17
|
declare const LayoutPDF: React$1.FC<LayoutPDFProps>;
|
|
17
18
|
|
|
@@ -60,6 +61,9 @@ declare const A: React$1.FC<TextProps>;
|
|
|
60
61
|
declare const BR: React$1.FC<{
|
|
61
62
|
style?: any;
|
|
62
63
|
}>;
|
|
64
|
+
declare const HR: React$1.FC<{
|
|
65
|
+
style?: any;
|
|
66
|
+
}>;
|
|
63
67
|
declare const Span: React$1.FC<TextProps>;
|
|
64
68
|
declare const Header: React$1.FC<HeaderProps>;
|
|
65
69
|
declare const Div: React$1.FC<DivProps>;
|
|
@@ -177,4 +181,4 @@ interface ImgBgProps {
|
|
|
177
181
|
}
|
|
178
182
|
declare const ImgBg: React$1.FC<ImgBgProps>;
|
|
179
183
|
|
|
180
|
-
export { A, BR, Blockquote, Center, Col1, Col10, Col11, Col12, Col2, Col3, Col4, Col5, Col6, Col7, Col8, Col9, Container, Div, Em, H1, H2, H3, H4, H5, H6, Header, Img, ImgBg, LI, LayoutPDF, Left, Mark, OL, P, QR, Right, Row, Small, Span, Strong, Table, Tbody, Td, Th, Thead, Tr, U, UL, decodeBase64Pdf, generatePDF };
|
|
184
|
+
export { A, BR, Blockquote, Center, Col1, Col10, Col11, Col12, Col2, Col3, Col4, Col5, Col6, Col7, Col8, Col9, Container, Div, Em, H1, H2, H3, H4, H5, H6, HR, Header, Img, ImgBg, LI, LayoutPDF, Left, Mark, OL, P, QR, Right, Row, Small, Span, Strong, Table, Tbody, Td, Th, Thead, Tr, U, UL, decodeBase64Pdf, generatePDF };
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,8 @@ var LayoutPDF = ({
|
|
|
25
25
|
style = {},
|
|
26
26
|
pagination = true,
|
|
27
27
|
footer,
|
|
28
|
-
lines = footer ? 2 : 1
|
|
28
|
+
lines = footer ? 2 : 1,
|
|
29
|
+
rule = false
|
|
29
30
|
}) => {
|
|
30
31
|
const LINE_HEIGHT = 20;
|
|
31
32
|
const FOOTER_PADDING = 10;
|
|
@@ -146,6 +147,67 @@ var LayoutPDF = ({
|
|
|
146
147
|
const pdfOrientation = transformOrientation(safeOrientation);
|
|
147
148
|
const margins = getMargins(safeMargen, safeSize);
|
|
148
149
|
const footerTop = getFooterPosition(safeSize, pdfOrientation, footerHeight);
|
|
150
|
+
const renderGrid = () => {
|
|
151
|
+
if (!rule) return null;
|
|
152
|
+
const cmToPoints = 28.3465;
|
|
153
|
+
const pageDimensions = {
|
|
154
|
+
A0: { width: 841 * 2.834645669, height: 1189 * 2.834645669 },
|
|
155
|
+
A1: { width: 594 * 2.834645669, height: 841 * 2.834645669 },
|
|
156
|
+
A2: { width: 420 * 2.834645669, height: 594 * 2.834645669 },
|
|
157
|
+
A3: { width: 297 * 2.834645669, height: 420 * 2.834645669 },
|
|
158
|
+
A4: { width: 210 * 2.834645669, height: 297 * 2.834645669 },
|
|
159
|
+
A5: { width: 148 * 2.834645669, height: 210 * 2.834645669 },
|
|
160
|
+
A6: { width: 105 * 2.834645669, height: 148 * 2.834645669 },
|
|
161
|
+
A7: { width: 74 * 2.834645669, height: 105 * 2.834645669 },
|
|
162
|
+
A8: { width: 52 * 2.834645669, height: 74 * 2.834645669 },
|
|
163
|
+
A9: { width: 37 * 2.834645669, height: 52 * 2.834645669 },
|
|
164
|
+
LETTER: { width: 216 * 2.834645669, height: 279 * 2.834645669 },
|
|
165
|
+
LEGAL: { width: 216 * 2.834645669, height: 356 * 2.834645669 },
|
|
166
|
+
TABLOID: { width: 279 * 2.834645669, height: 432 * 2.834645669 }
|
|
167
|
+
};
|
|
168
|
+
const dimensions = pageDimensions[safeSize.toUpperCase()] || pageDimensions.A4;
|
|
169
|
+
const pageWidth = pdfOrientation === "landscape" ? dimensions.height : dimensions.width;
|
|
170
|
+
const pageHeight = pdfOrientation === "landscape" ? dimensions.width : dimensions.height;
|
|
171
|
+
const horizontalLines = [];
|
|
172
|
+
const verticalLines = [];
|
|
173
|
+
for (let i = 0; i <= Math.ceil(pageHeight / cmToPoints); i++) {
|
|
174
|
+
horizontalLines.push(
|
|
175
|
+
/* @__PURE__ */ React.createElement(
|
|
176
|
+
View,
|
|
177
|
+
{
|
|
178
|
+
key: `h-${i}`,
|
|
179
|
+
style: {
|
|
180
|
+
position: "absolute",
|
|
181
|
+
top: i * cmToPoints,
|
|
182
|
+
left: 0,
|
|
183
|
+
right: 0,
|
|
184
|
+
height: i % 5 === 0 ? 1 : 0.5,
|
|
185
|
+
backgroundColor: i % 5 === 0 ? "rgba(255, 0, 0, 0.8)" : "rgba(100, 100, 100, 0.5)"
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
for (let i = 0; i <= Math.ceil(pageWidth / cmToPoints); i++) {
|
|
192
|
+
verticalLines.push(
|
|
193
|
+
/* @__PURE__ */ React.createElement(
|
|
194
|
+
View,
|
|
195
|
+
{
|
|
196
|
+
key: `v-${i}`,
|
|
197
|
+
style: {
|
|
198
|
+
position: "absolute",
|
|
199
|
+
left: i * cmToPoints,
|
|
200
|
+
top: 0,
|
|
201
|
+
bottom: 0,
|
|
202
|
+
width: i % 5 === 0 ? 1 : 0.5,
|
|
203
|
+
backgroundColor: i % 5 === 0 ? "rgba(255, 0, 0, 0.8)" : "rgba(100, 100, 100, 0.5)"
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
return /* @__PURE__ */ React.createElement(View, { style: { position: "absolute", top: 0, left: 0, right: 0, bottom: 0 }, fixed: true }, horizontalLines, verticalLines);
|
|
210
|
+
};
|
|
149
211
|
const pageStyle = {
|
|
150
212
|
...styles.page,
|
|
151
213
|
backgroundColor: safeBackgroundColor,
|
|
@@ -164,7 +226,7 @@ var LayoutPDF = ({
|
|
|
164
226
|
fontSize: 10,
|
|
165
227
|
color: "grey"
|
|
166
228
|
};
|
|
167
|
-
return /* @__PURE__ */ React.createElement(Document, null, /* @__PURE__ */ React.createElement(Page, { size: safeSize, orientation: pdfOrientation, style: pageStyle, wrap: true }, /* @__PURE__ */ React.createElement(View, { style: { paddingBottom: footerHeight } }, children), pagination ? /* @__PURE__ */ React.createElement(View, { style: footerStyle, fixed: true }, footer, /* @__PURE__ */ React.createElement(Text, { style: { fontSize: footerStyle.fontSize }, render: ({ pageNumber, totalPages }) => `${pageNumber} / ${totalPages}` })) : null));
|
|
229
|
+
return /* @__PURE__ */ React.createElement(Document, null, /* @__PURE__ */ React.createElement(Page, { size: safeSize, orientation: pdfOrientation, style: pageStyle, wrap: true }, renderGrid(), /* @__PURE__ */ React.createElement(View, { style: { paddingBottom: footerHeight } }, children), pagination ? /* @__PURE__ */ React.createElement(View, { style: footerStyle, fixed: true }, footer, /* @__PURE__ */ React.createElement(Text, { style: { fontSize: footerStyle.fontSize }, render: ({ pageNumber, totalPages }) => `${pageNumber} / ${totalPages}` })) : null));
|
|
168
230
|
};
|
|
169
231
|
var LayoutPDF_default = LayoutPDF;
|
|
170
232
|
|
|
@@ -287,6 +349,12 @@ var styles4 = StyleSheet4.create({
|
|
|
287
349
|
fontSize: 10,
|
|
288
350
|
color: "#666",
|
|
289
351
|
paddingHorizontal: 40
|
|
352
|
+
},
|
|
353
|
+
hr: {
|
|
354
|
+
width: "100%",
|
|
355
|
+
borderTop: "1px solid #000",
|
|
356
|
+
marginTop: 8,
|
|
357
|
+
marginBottom: 8
|
|
290
358
|
}
|
|
291
359
|
});
|
|
292
360
|
var P = ({ children, style }) => {
|
|
@@ -334,6 +402,9 @@ var A = ({ children, style, href }) => {
|
|
|
334
402
|
var BR = ({ style }) => {
|
|
335
403
|
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.br, style] }, "\n");
|
|
336
404
|
};
|
|
405
|
+
var HR = ({ style }) => {
|
|
406
|
+
return /* @__PURE__ */ React4.createElement(View3, { style: [styles4.hr, style] });
|
|
407
|
+
};
|
|
337
408
|
var Span = ({ children, style }) => {
|
|
338
409
|
return /* @__PURE__ */ React4.createElement(Text2, { style: [style] }, children);
|
|
339
410
|
};
|
|
@@ -936,6 +1007,7 @@ export {
|
|
|
936
1007
|
H4,
|
|
937
1008
|
H5,
|
|
938
1009
|
H6,
|
|
1010
|
+
HR,
|
|
939
1011
|
Header,
|
|
940
1012
|
Img_default as Img,
|
|
941
1013
|
ImgBg_default as ImgBg,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-pdf-levelup",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.59",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"qrcode": "^1.5.4",
|
|
27
|
-
"react-pdf-levelup": "^3.1.
|
|
27
|
+
"react-pdf-levelup": "^3.1.54"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {}
|
|
30
30
|
}
|