[Docx] Generate "Primeros Auxilios"

master
Araozu 2023-09-15 16:28:51 -05:00
parent ab7b3f27b6
commit 6a535e6497
2 changed files with 279 additions and 0 deletions

View File

@ -0,0 +1,277 @@
import { cmText, createSimpleText, getImage, getQR } from "./utils";
import { CertData } from "./CertData";
const {
Document, Paragraph, PageOrientation,
FrameAnchorType,
TextRun,
AlignmentType,
BorderStyle,
} = window.docx;
const imgFondoDoc = getImage({
name: "fondo_certificado_manejo_defensivo.png",
height: 21.23,
width: 29.8,
horizontalOffset: 0,
verticalOffset: -0.05,
behindDocument: true,
});
const imgCIP = getImage({
name: "colegio_ingenieros_logo.png",
height: 2.15,
width: 2.15,
horizontalOffset: 26.52,
verticalOffset: 15.24,
});
const imgMTC = getImage({
name: "mtc_2_logo.png",
height: 0.94,
width: 5.14,
horizontalOffset: 1,
verticalOffset: 19.21,
});
const tCertificate = createSimpleText({
xPosition: 2.42,
yPosition: 4.2,
width: 11.05,
height: 1.72,
text: "CERTIFICADO",
size: 72,
font: "Times New Roman",
bold: true,
});
// Otorgado a
const tExpediteText = createSimpleText({
xPosition: -1.08,
yPosition: 5.4,
width: 3,
height: 0.7,
text: "Otorgado a:",
size: 22,
});
// PRIMEROS AUXILIOS
const tCourse = createSimpleText({
xPosition: -0.44,
yPosition: 8,
width: 20.92,
height: 1.5,
text: "PRIMEROS AUXILIOS",
size: 44,
bold: true,
});
// En temas de...
const tTopics = createSimpleText({
xPosition: -0.44,
yPosition: 9.4,
width: 20.92,
height: 1.5,
text: "En temas de: Tres Reglas de Seguridad Básicas (S.S.S.), Primeros Auxilios Psicológico, Inicio de la Cadena de Vida, RCP, Hemorragias Quemaduras, Fracturas, uso de férulas y vendajes, Maniobra de Heimlich, Traslado de Pacientes, Posición lateral de Seguridad PLS, Tratamientos por intoxicación asfixia o ahogamiento, Practicas en Técnicas de Control de Primeros Auxilios, equivalente a 04 horas lectivas.",
size: 22,
font: "Times New Roman",
alignment: AlignmentType.LEFT,
});
// Se expide certificado...
const tFinishLabel = createSimpleText({
xPosition: -0.44,
yPosition: 11.3,
width: 20.92,
height: 0.75,
text: "Se expide el presente certificado para los fines que se estime conveniente",
size: 22,
font: "Times New Roman",
alignment: AlignmentType.CENTER,
});
// MTC: R.D.N° ...
const tMTCLabel = createSimpleText({
xPosition: -1.51,
yPosition: 18,
width: 6,
height: 0.75,
text: "R.D.N° 092-2021-MTC/17.03",
size: 24,
font: "Calibri",
alignment: AlignmentType.LEFT,
color: "FFFFFF",
bold: true,
});
// Recuadro de foto
const photoSection = new Paragraph({
frame: {
position: {
x: cmText(23.35),
y: cmText(8.3),
},
width: cmText(2.81),
height: cmText(3.57),
anchor: {
horizontal: FrameAnchorType.MARGIN,
vertical: FrameAnchorType.MARGIN,
},
},
children: [],
border: {
top: {
style: BorderStyle.DASHED,
},
bottom: {
style: BorderStyle.DASHED,
},
left: {
style: BorderStyle.DASHED,
},
right: {
style: BorderStyle.DASHED,
},
},
alignment: AlignmentType.LEFT,
});
export async function primerosAuxiliosCert(props: CertData<null>): Promise<Document> {
const imgQR = await getQR({
iid: props.certIId,
dni: props.personDni,
height: 2.45,
width: 2.45,
horizontalOffset: 26.4,
verticalOffset: 17.65,
});
// FERNANDO ARAOZ
const tName = createSimpleText({
xPosition: -2.5,
yPosition: 6,
width: 23.13,
height: 1.5,
text: props.personFullName,
size: 52,
bold: true,
underline: {},
});
// Identificado con DNI...
const tContentPart1 = new Paragraph({
frame: {
position: {
x: cmText(-0.4),
y: cmText(7.3),
},
width: cmText(20.92),
height: cmText(1),
anchor: {
horizontal: FrameAnchorType.MARGIN,
vertical: FrameAnchorType.MARGIN,
},
},
children: [
new TextRun({
text: "Identificado con DNI N° ",
font: "Times New Roman",
size: 22,
}),
new TextRun({
text: props.personDni,
font: "Times New Roman",
size: 24,
bold: true,
}),
new TextRun({
text: ", al haber aprobado el curso de capacitación sobre:",
font: "Times New Roman",
size: 22,
}),
],
alignment: AlignmentType.LEFT,
});
// Fecha de Emision: ...
const certificateDate = new Paragraph({
frame: {
position: {
x: cmText(17),
y: cmText(15.5),
},
width: cmText(9),
height: cmText(1.4),
anchor: {
horizontal: FrameAnchorType.MARGIN,
vertical: FrameAnchorType.MARGIN,
},
},
children: [
new TextRun({
text: `Fecha de Emisión:\t${props.certDay} / ${props.certMonth} / ${props.certYear}`,
font: "Times New Roman",
size: 20,
}),
new TextRun({
text: `Fecha de Expiración:\t${props.certDay} / ${props.certMonth} / ${parseInt(props.certYear, 10) + 1}`,
font: "Times New Roman",
size: 20,
break: 1,
}),
],
alignment: AlignmentType.LEFT,
});
// N° XXXX-20XX-EEG
const tCertCode = createSimpleText({
xPosition: 23,
yPosition: 12,
width: 3.67,
height: 0.8,
text: `${props.certCode}-${props.certYear}-EEG`,
size: 20,
alignment: AlignmentType.CENTER,
});
const doc = new Document({
sections: [
{
properties: {
page: {
size: {
orientation: PageOrientation.LANDSCAPE,
},
},
},
children: [
tCertificate,
tExpediteText,
tName,
tContentPart1,
tCourse,
tTopics,
tFinishLabel,
certificateDate,
photoSection,
tCertCode,
tMTCLabel,
new Paragraph({
children: [
imgFondoDoc,
imgQR,
imgCIP,
imgMTC,
],
}),
],
},
],
});
// Return document as a buffer
return doc;
}

View File

@ -13,6 +13,7 @@ import { excavadoraHidraulica } from "./certs/EXCAVADORA_HIDRAULICA";
import { cargadorFrontal } from "./certs/CARGADOR_FRONTAL"; import { cargadorFrontal } from "./certs/CARGADOR_FRONTAL";
import { retroexcavadora } from "./certs/RETROEXCAVADORA"; import { retroexcavadora } from "./certs/RETROEXCAVADORA";
import { volquete } from "./certs/VOLQUETE"; import { volquete } from "./certs/VOLQUETE";
import { primerosAuxiliosCert } from "./certs/PRIMEROS_AUXILIOS";
declare global { declare global {
interface Window { interface Window {
@ -79,6 +80,7 @@ export const certGenerator: CertGenObj = Object.freeze({
"Cargador Frontal": certGeneratorGenerator(cargadorFrontal), "Cargador Frontal": certGeneratorGenerator(cargadorFrontal),
"Retroexcavadora": certGeneratorGenerator(retroexcavadora), "Retroexcavadora": certGeneratorGenerator(retroexcavadora),
"Volquete": certGeneratorGenerator(volquete), "Volquete": certGeneratorGenerator(volquete),
"Primeros Auxilios": certGeneratorGenerator(primerosAuxiliosCert),
}); });