diff --git a/lib/evo_anketa_v2_empty_licenses_20240503.pdf b/lib/evo_anketa_v2_empty_licenses_20240503.pdf new file mode 100644 index 0000000..466aeea Binary files /dev/null and b/lib/evo_anketa_v2_empty_licenses_20240503.pdf differ diff --git a/pages/api/questionnaire/download.js b/pages/api/questionnaire/download.js index 876036f..60d7e68 100644 --- a/pages/api/questionnaire/download.js +++ b/pages/api/questionnaire/download.js @@ -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, }); } }