change questionnaire PDF generation font family to Ubuntu Mono

This commit is contained in:
merelendor 2023-11-15 12:55:34 +03:00
parent 954687dd15
commit f7639ab297
2 changed files with 32 additions and 2 deletions

BIN
lib/ubuntu_mono_regular.ttf Normal file

Binary file not shown.

View File

@ -144,7 +144,7 @@ export default async function handler(req, res)
console.log("API", "download", "__dirname", __dirname);
const formPdfBytes = fs.readFileSync(`${ __dirname }/../../../../../lib/evo_anketa_v2_empty_licenses.pdf`);
const fontBytes = fs.readFileSync(`${ __dirname }/../../../../../lib/roboto.ttf`);
const fontBytes = fs.readFileSync(`${ __dirname }/../../../../../lib/ubuntu_mono_regular.ttf`);
const pdfDoc = await PDFDocument.load(formPdfBytes);
pdfDoc.registerFontkit(fontkit);
@ -204,9 +204,39 @@ export default async function handler(req, res)
const { registration_address, } = questionnaire[group][p].identity_document;
if(good(registration_address.name))
{
let field_text_value = registration_address.name.toString().toUpperCase();
/*
let field_text_value = "";
for(let a = 0; a < 7; a++)
{
for(let b = 0; b < 10; b++)
{
field_text_value = field_text_value + b;
if(b === 5)
{
field_text_value = field_text_value + " ";
}
}
}
*/
//const rx = new RegExp(/(\S)-(\S)/gim);
//field_text_value = field_text_value.replace(rx, "$1- $2");
fields[group][p][field].bind = form.getTextField(fields[group][p][field].name);
console.log(`${ group }_${ p }_${ field }`, { is_scrollable: fields[group][p][field].bind.isScrollable() });
if(fields[group][p][field].size !== undefined) { fields[group][p][field].bind.setFontSize(fields[group][p][field].size); }
fields[group][p][field].bind.setText(registration_address.name.toString().toUpperCase());
/*
if(field_text_value.length < 70)
{
}
else if(field_text_value.length < 14)
{
}
*/
fields[group][p][field].bind.setText(field_text_value);
}
}
else