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