FIX for questionnaire - empty licences field & new 2024.05 PDF file

This commit is contained in:
merelendor 2024-05-07 17:24:15 +03:00
parent ee5e89f2fd
commit c65f91be91
2 changed files with 12 additions and 6 deletions

Binary file not shown.

View File

@ -147,7 +147,7 @@ export default async function handler(req, res)
var crm_jwt = jwt.sign({ acc_number: client_jwt_decoded.acc_number }, process.env.JWT_SECRET_CRM, { noTimestamp: true });
console.log("API", "download", "__dirname", __dirname);
const formPdfBytes = fs.readFileSync(`${ __dirname }/../../../../../lib/evo_anketa_v2_empty_licenses_20240208.pdf`);
const formPdfBytes = fs.readFileSync(`${ __dirname }/../../../../../lib/evo_anketa_v2_empty_licenses_20240503.pdf`);
const fontBytes = fs.readFileSync(`${ __dirname }/../../../../../lib/ubuntu_mono_regular.ttf`);
const pdfDoc = await PDFDocument.load(formPdfBytes);
@ -172,17 +172,23 @@ export default async function handler(req, res)
height: 26,
color: rgb(0.87, 0.87, 0.87),
});
if(questionnaire[group] !== null)
{
page.drawText(questionnaire[group], {
let licenses = questionnaire[group];
if(typeof licenses !== "string")
{
licenses = licenses.join(", ");
}
page.drawText(licenses, {
x: 152,
y: questionnaire[group].length > 500 ? 195 : (questionnaire[group].length > 400) ? 195 : 193,
size: questionnaire[group].length > 500 ? 4 : (questionnaire[group].length > 400) ? 5 : 6,
y: licenses.length > 500 ? 195 : (licenses.length > 400) ? 195 : 193,
size: licenses.length > 500 ? 4 : (licenses.length > 400) ? 5 : 6,
font: formFont,
color: rgb(0, 0, 0),
maxWidth: 412,
lineHeight: questionnaire[group].length > 500 ? 4 : (questionnaire[group].length > 400) ? 5 : 6,
lineHeight: licenses.length > 500 ? 4 : (licenses.length > 400) ? 5 : 6,
});
}
}