softdinlibreriajs 12.0.34 → 12.0.35

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/GenerarPDF.js +0 -93
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "softdinlibreriajs",
3
- "version": "12.0.34",
3
+ "version": "12.0.35",
4
4
  "description": "Libreria Softdin",
5
5
  "main": "src/",
6
6
  "scripts": {
package/src/GenerarPDF.js DELETED
@@ -1,93 +0,0 @@
1
- import { jsPDF } from "jspdf";
2
-
3
- // Función para generar el PDF
4
- export const generarCertificadoLaboral = (form, logoBase64) => {
5
- console.log("Generando certificado laboral...");
6
- // Validaciones de entrada
7
- if (
8
- !form ||
9
- !form.report_header ||
10
- !form.description ||
11
- !form.signature ||
12
- !form.report_footer
13
- ) {
14
- console.error("Faltan datos en el formulario.");
15
- return;
16
- }
17
-
18
- const doc = new jsPDF({
19
- orientation: "portrait", // Orientación vertical
20
- unit: "mm", // Unidades en milímetros
21
- format: "letter", // Tamaño carta
22
- putOnlyUsedFonts: true,
23
- precision: 16, // Precisión flotante
24
- });
25
-
26
- // Encabezado: agregar logo si está habilitado
27
- const imgData = logoBase64.value;
28
- if (form.show_logo && imgData) {
29
- doc.addImage(imgData, "JPEG", 15, 10, 30, 30); // (imagen, tipo, x, y, ancho, alto)
30
- }
31
-
32
- // Agregar encabezado del reporte
33
- doc.setFontSize(16);
34
- const maxWidthHeader = form.show_logo ? 150 : 200;
35
- const linesHeader = doc.splitTextToSize(form.report_header, maxWidthHeader);
36
- let yPosition = 20; // Posición Y inicial
37
- linesHeader.forEach((line) => {
38
- doc.text(line, form.show_logo ? 120 : 100, yPosition, { align: "center" });
39
- yPosition += 8;
40
- });
41
-
42
- yPosition += 20; // Incrementar posición Y para el siguiente bloque
43
-
44
- // Información del certificado
45
- doc.setFontSize(20);
46
- doc.setFont("helvetica", "bold");
47
- const certText = "CERTIFICA";
48
- const certTextWidth = doc.getTextWidth(certText);
49
- const certX = (doc.getPageWidth() - certTextWidth) / 2; // Centrar el texto
50
- doc.text(certText, certX, yPosition);
51
-
52
- // Descripción del certificado
53
- doc.setFontSize(12);
54
- doc.setFont("helvetica", "normal");
55
- const linesDescription = doc.splitTextToSize(form.description, 180);
56
- yPosition += 20;
57
- linesDescription.forEach((line) => {
58
- doc.text(line, 20, yPosition);
59
- yPosition += 10;
60
- });
61
-
62
- // Firma
63
- const firmaLinea = "__________________________________";
64
- const firmaTextWidth = doc.getTextWidth(firmaLinea);
65
- const firmaX = (doc.getPageWidth() - firmaTextWidth) / 2;
66
- doc.text(firmaLinea, firmaX, 230);
67
-
68
- doc.setFont("helvetica", "bold");
69
- const linesSignature = doc.splitTextToSize(form.signature, 180);
70
- yPosition = 235;
71
- linesSignature.forEach((line) => {
72
- const textWidth = doc.getTextWidth(line);
73
- const textX = (doc.getPageWidth() - textWidth) / 2;
74
- doc.text(line, textX, yPosition);
75
- yPosition += 4;
76
- });
77
-
78
- // Pie de informe
79
- doc.setFont("helvetica", "normal");
80
- doc.setFontSize(8);
81
- const linesFooter = doc.splitTextToSize(form.report_footer, 180);
82
- yPosition = 255;
83
- linesFooter.forEach((line) => {
84
- const textWidth = doc.getTextWidth(line);
85
- const textX = (doc.getPageWidth() - textWidth) / 2;
86
- doc.text(line, textX, yPosition);
87
- yPosition += 4;
88
- });
89
-
90
- // Generar salida como URL blob
91
- const pdfOutput = doc.output("bloburl");
92
- return pdfOutput; // Devolver la URL del PDF generado
93
- };