Try dynamic font
This commit is contained in:
parent
9363333b5a
commit
a870a7119f
@ -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');
|
||||
@ -91,10 +90,13 @@ module.exports = {
|
||||
doc.moveDown();
|
||||
|
||||
// Write the text from infoString
|
||||
doc.fontSize(12)
|
||||
doc.font('public/Outfit-Regular.ttf').text(infoString, {
|
||||
align: 'left',
|
||||
});
|
||||
doc.fontSize(12)
|
||||
for (row of infoArray) {
|
||||
doc.moveDown();
|
||||
doc.font(row.font).text(row.text, {
|
||||
align: 'left',
|
||||
});
|
||||
}
|
||||
|
||||
// Finalize the PDF
|
||||
doc.end();
|
||||
|
BIN
mccs-it/thermal/public/RobotoMono-Regular.ttf
Normal file
BIN
mccs-it/thermal/public/RobotoMono-Regular.ttf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user