Try dynamic font

This commit is contained in:
Skylar Grant 2024-09-13 09:09:17 -04:00
parent 9363333b5a
commit a870a7119f
2 changed files with 17 additions and 15 deletions

View File

@ -23,16 +23,15 @@ module.exports = {
credentials(username, studentId) {
// Create the output text
const infoArray = [
`Username: ${username}`,
'',
'Email:',
`${username}@kvcc.me.edu`,
'',
`Student ID: ${studentId}`,
'',
'Note: the MyKV Portal uses your username to sign in, not email.',
receiptFooter
];
{ font: 'public/RobotoMono-Regular.ttf', text: `Username: ${username}` },
{ font: 'public/Outfit-Regular.ttf', text: '' },
{ font: 'public/Outfit-Regular.ttf', text: 'Email:' },
{ font: 'public/RobotoMono-Regular.ttf', text: `${username}@kvcc.me.edu` },
{ font: 'public/Outfit-Regular.ttf', text: '' },
{ font: 'public/RobotoMono-Regular.ttf', text: `Student ID: ${studentId}` },
{ font: 'public/Outfit-Regular.ttf', text: '' },
{ font: 'public/Outfit-Regular.ttf', text: 'Note: the MyKV Portal uses your username to sign in, not email.' },
]
return infoArray.join('\n');
},
maineCC() {
@ -59,7 +58,7 @@ module.exports = {
return infoArray.join('\n');
}
},
generatePdf(infoString) {
generatePdf(infoArray) {
return new Promise((resolve, reject) => {
// Define the path for the PDF file
const pdfFilePath = path.join(__dirname, '../public/output.pdf');
@ -92,9 +91,12 @@ module.exports = {
// Write the text from infoString
doc.fontSize(12)
doc.font('public/Outfit-Regular.ttf').text(infoString, {
for (row of infoArray) {
doc.moveDown();
doc.font(row.font).text(row.text, {
align: 'left',
});
}
// Finalize the PDF
doc.end();

Binary file not shown.