FIX for questionnaire - empty licences field & new 2024.05 PDF file
This commit is contained in:
parent
ee5e89f2fd
commit
c65f91be91
BIN
lib/evo_anketa_v2_empty_licenses_20240503.pdf
Normal file
BIN
lib/evo_anketa_v2_empty_licenses_20240503.pdf
Normal file
Binary file not shown.
@ -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 });
|
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);
|
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 fontBytes = fs.readFileSync(`${ __dirname }/../../../../../lib/ubuntu_mono_regular.ttf`);
|
||||||
|
|
||||||
const pdfDoc = await PDFDocument.load(formPdfBytes);
|
const pdfDoc = await PDFDocument.load(formPdfBytes);
|
||||||
@ -172,17 +172,23 @@ export default async function handler(req, res)
|
|||||||
height: 26,
|
height: 26,
|
||||||
color: rgb(0.87, 0.87, 0.87),
|
color: rgb(0.87, 0.87, 0.87),
|
||||||
});
|
});
|
||||||
|
|
||||||
if(questionnaire[group] !== null)
|
if(questionnaire[group] !== null)
|
||||||
{
|
{
|
||||||
page.drawText(questionnaire[group], {
|
let licenses = questionnaire[group];
|
||||||
|
if(typeof licenses !== "string")
|
||||||
|
{
|
||||||
|
licenses = licenses.join(", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
page.drawText(licenses, {
|
||||||
x: 152,
|
x: 152,
|
||||||
y: questionnaire[group].length > 500 ? 195 : (questionnaire[group].length > 400) ? 195 : 193,
|
y: licenses.length > 500 ? 195 : (licenses.length > 400) ? 195 : 193,
|
||||||
size: questionnaire[group].length > 500 ? 4 : (questionnaire[group].length > 400) ? 5 : 6,
|
size: licenses.length > 500 ? 4 : (licenses.length > 400) ? 5 : 6,
|
||||||
font: formFont,
|
font: formFont,
|
||||||
color: rgb(0, 0, 0),
|
color: rgb(0, 0, 0),
|
||||||
maxWidth: 412,
|
maxWidth: 412,
|
||||||
lineHeight: questionnaire[group].length > 500 ? 4 : (questionnaire[group].length > 400) ? 5 : 6,
|
lineHeight: licenses.length > 500 ? 4 : (licenses.length > 400) ? 5 : 6,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user