Skip to content
Snippets Groups Projects
Commit 55fab72f authored by DenisDao57's avatar DenisDao57
Browse files

fix generate pdf

parent 568c8cb5
No related branches found
No related tags found
Loading
This commit is part of merge request !18. Comments created here will be created in the context of that merge request.
...@@ -5,6 +5,10 @@ import { InternshipEntity } from './entities/internship.entity'; ...@@ -5,6 +5,10 @@ import { InternshipEntity } from './entities/internship.entity';
import { PDFDocument, StandardFonts, rgb, degrees } from 'pdf-lib'; import { PDFDocument, StandardFonts, rgb, degrees } from 'pdf-lib';
import { readFileSync, writeFileSync } from 'fs'; import { readFileSync, writeFileSync } from 'fs';
import { join } from 'path'; import { join } from 'path';
import { v4 } from 'uuid';
import { timeStamp } from 'console';
import { STATE_SECRETARY_ESTABLISHES_INTERNSHIP_AGREEMENT } from 'src/shared/InternshipState';
import config from 'src/config';
...@@ -298,10 +302,11 @@ export class InternshipService { ...@@ -298,10 +302,11 @@ export class InternshipService {
// Serialize the PDFDocument to bytes (a Uint8Array) // Serialize the PDFDocument to bytes (a Uint8Array)
const pdfBytes = await pdfDoc.save(); const pdfBytes = await pdfDoc.save();
const newFileName = 'convention-' + id; const newFileName = v4();
const newFilePath = join(__dirname, '..', '..', 'files', newFileName + '.pdf'); const newFilePath = join(__dirname, '..', '..', 'files', newFileName + '.pdf');
writeFileSync(newFilePath, pdfBytes); writeFileSync(newFilePath, pdfBytes);
const resourceURI = `${config.server.uri}:${config.server.port}/resources/agreements/${newFileName}.pdf`;
this._internshipsDao.findByStudentIdAndUpdateTracking(id,STATE_SECRETARY_ESTABLISHES_INTERNSHIP_AGREEMENT,resourceURI);
return null; return null;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment