From 1267bd11e32e2161e201af2f54a254af86085798 Mon Sep 17 00:00:00 2001 From: Fernando Date: Thu, 18 May 2023 12:45:47 -0500 Subject: [PATCH] [docx] Generate cert for MECANICABADICA --- .gitignore | 1 + src/certs/MECANICA_BASICA.ts | 117 ++++++++++++++++++++++++++++++++--- src/certs/utils.ts | 2 + 3 files changed, 113 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 3e58864..a40dd01 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ .rollup.cache +.env .env.production eegsac.zip diff --git a/src/certs/MECANICA_BASICA.ts b/src/certs/MECANICA_BASICA.ts index fc8766f..fcc1332 100644 --- a/src/certs/MECANICA_BASICA.ts +++ b/src/certs/MECANICA_BASICA.ts @@ -4,6 +4,7 @@ import { FrameAnchorType, TextRun, AlignmentType, + BorderStyle, } from "docx"; import * as QR from "qrcode"; import { Matpel, cm, cmText, cmToEmu, createSimpleText, getImage, getMatpelHours, getMatpelLabel, getQR } from "./utils"; @@ -56,7 +57,7 @@ const tExpediteText = createSimpleText({ // MECANICA BASICA const tCourse = createSimpleText({ - xPosition: 1.43, + xPosition: 1.7, yPosition: 7, width: 20.08, height: 1.5, @@ -67,13 +68,24 @@ const tCourse = createSimpleText({ // En los temas de... const tTopics = createSimpleText({ - xPosition: 1.43, - yPosition: 8.75, - width: 20.08, + xPosition: 1.7, + yPosition: 8.9, + width: 19.31, height: 1.5, - text: "En los temas de: Lineamientos del Ministerio de Transportes y Comunicaciones (MTC), Operatividad efectiva del equipo. Procedimiento de operación correcta. Equipamiento y mantenimiento preventivo, Medidas de Control y Tipos de IPERC, Cuidados de la maquina durante la operación, Uso de pedales y controles, Funcionamiento del motor", + text: "En los temas de: Lineamientos del Ministerio de Transportes y Comunicaciones (MTC), Operatividad efectiva del equipo. Procedimiento de operación correcta. Equipamiento y mantenimiento preventivo, Medidas de Control y Tipos de IPERC, Cuidados de la maquina durante la operación, Uso de pedales y controles, Funcionamiento del motor;", size: 22, - alignment: AlignmentType.LEFT, + alignment: AlignmentType.JUSTIFIED, +}); + +// Con una duracion de... +const tDuration = createSimpleText({ + xPosition: 1.7, + yPosition: 11, + width: 19.31, + height: 1, + text: "Con una duración de 12 horas lectivas.", + size: 22, + alignment: AlignmentType.JUSTIFIED, }); export async function mecanicaBasicaCert(props: CertData): Promise { @@ -85,6 +97,17 @@ export async function mecanicaBasicaCert(props: CertData): Promise verticalOffset: 17.01, }); + // N° XXXX-20XX-EEG + const tCertCode = createSimpleText({ + xPosition: -1.86, + yPosition: 1.8, + width: 3.67, + height: 0.8, + text: `N° ${props.certCode}-${props.certYear}-EEG`, + size: 20, + alignment: AlignmentType.CENTER, + }); + // FERNANDO ARAOZ const tName = createSimpleText({ xPosition: 0.38, @@ -101,7 +124,7 @@ export async function mecanicaBasicaCert(props: CertData): Promise const tContentPart1 = new Paragraph({ frame: { position: { - x: cmText(1.43), + x: cmText(1.7), y: cmText(6.16), }, width: cmText(20.08), @@ -132,6 +155,81 @@ export async function mecanicaBasicaCert(props: CertData): Promise alignment: AlignmentType.LEFT, }); + // Se expide certificado... + const tFinishLabel = createSimpleText({ + xPosition: 1.52, + yPosition: 11.65, + width: 20.1, + height: 0.8, + text: "Se expide el presente certificado para los fines que se estime conveniente", + size: 22, + alignment: AlignmentType.CENTER, + italics: true, + }); + + // Fecha de Emision: ... + const certificateDate = new Paragraph({ + frame: { + position: { + x: cmText(17.25), + y: cmText(17), + }, + width: cmText(7.5), + height: cmText(0.9), + anchor: { + horizontal: FrameAnchorType.MARGIN, + vertical: FrameAnchorType.MARGIN, + }, + }, + children: [ + new TextRun({ + text: `Fecha de Emisión:\t\t${props.certDay} / ${props.certMonth} / ${props.certYear}`, + font: "Arial", + size: 18, + }), + new TextRun({ + text: `Fecha de Expiración:\t\t${props.certDay} / ${props.certMonth} / ${parseInt(props.certYear, 10) + 1}`, + font: "Arial", + size: 18, + break: 1, + }), + ], + alignment: AlignmentType.LEFT, + }); + + // Recuadro de foto + const photoSection = new Paragraph({ + frame: { + position: { + x: cmText(-1.5), + y: cmText(-1.9), + }, + 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, + }); + + const doc = new Document({ sections: [ { @@ -143,12 +241,17 @@ export async function mecanicaBasicaCert(props: CertData): Promise }, }, children: [ + tCertCode, + photoSection, tCertificate, tExpediteText, tName, tContentPart1, tCourse, tTopics, + tFinishLabel, + tDuration, + certificateDate, new Paragraph({ children: [ imgFondoDoc, diff --git a/src/certs/utils.ts b/src/certs/utils.ts index f794053..db29c13 100644 --- a/src/certs/utils.ts +++ b/src/certs/utils.ts @@ -94,6 +94,7 @@ export function createSimpleText(data: { size: number, underline?: Record, alignment?: AlignmentType, + italics?: boolean, }): Paragraph { return new Paragraph({ @@ -116,6 +117,7 @@ export function createSimpleText(data: { font: data.font ?? "Arial", size: data.size, underline: data.underline, + italics: data.italics, }), ], alignment: data.alignment ?? AlignmentType.CENTER,