update for license field in PDF
This commit is contained in:
parent
99c4ebffb0
commit
8168e9f39b
BIN
lib/evo_anketa_v2_empty_licenses.pdf
Normal file
BIN
lib/evo_anketa_v2_empty_licenses.pdf
Normal file
Binary file not shown.
@ -7,7 +7,7 @@ import jwt from 'jsonwebtoken';
|
||||
import { cors } from '../../../lib/cors';
|
||||
import { inspect } from 'util';
|
||||
import fs from 'fs';
|
||||
import { PDFDocument } from 'pdf-lib';
|
||||
import { PDFDocument, rgb } from 'pdf-lib';
|
||||
import fontkit from '@pdf-lib/fontkit';
|
||||
|
||||
const address = {
|
||||
@ -109,7 +109,7 @@ const fields = {
|
||||
fin_goals_trucks: { name: "nko_object_trucks", type: "text", bind: null, size: 6 },
|
||||
fin_goals_special: { name: "nko_object_special", type: "text", bind: null, size: 6 },
|
||||
},
|
||||
licenses: { name: "licenses", type: "text", bind: null, size: 6 },
|
||||
licenses: { name: "licenses", type: "text", bind: null, size: 4 },
|
||||
};
|
||||
|
||||
function good(value)
|
||||
@ -143,7 +143,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.pdf`);
|
||||
const formPdfBytes = fs.readFileSync(`${ __dirname }/../../../../../lib/evo_anketa_v2_empty_licenses.pdf`);
|
||||
const fontBytes = fs.readFileSync(`${ __dirname }/../../../../../lib/roboto.ttf`);
|
||||
|
||||
const pdfDoc = await PDFDocument.load(formPdfBytes);
|
||||
@ -156,9 +156,28 @@ export default async function handler(req, res)
|
||||
{
|
||||
if(group === "licenses")
|
||||
{
|
||||
fields[group].bind = form.getTextField(fields[group].name);
|
||||
if(fields[group].size !== undefined) { fields[group].bind.setFontSize(fields[group].size); }
|
||||
fields[group].bind.setText(`${ questionnaire[group] }`);
|
||||
//fields[group].bind = form.getTextField(fields[group].name);
|
||||
//if(fields[group].size !== undefined) { fields[group].bind.setFontSize(fields[group].size); }
|
||||
//fields[group].bind.setText(`${ questionnaire[group] }`);
|
||||
|
||||
const page = pdfDoc.getPage(1);
|
||||
page.drawRectangle({
|
||||
x: 150,
|
||||
y: 174,
|
||||
width: 412,
|
||||
height: 26,
|
||||
color: rgb(0.87, 0.87, 0.87),
|
||||
});
|
||||
|
||||
page.drawText(questionnaire[group], {
|
||||
x: 152,
|
||||
y: 195,
|
||||
size: fields[group].size,
|
||||
font: formFont,
|
||||
color: rgb(0, 0, 0),
|
||||
maxWidth: 412,
|
||||
lineHeight: 4,
|
||||
});
|
||||
}
|
||||
else if(group === "founder_persons")
|
||||
{
|
||||
@ -178,7 +197,7 @@ export default async function handler(req, res)
|
||||
const { placebirth, citizenship, doctype, seria, docnumber, code, issueby, issuedate, } = questionnaire[group][p].identity_document;
|
||||
fields[group][p][field].bind = form.getTextField(fields[group][p][field].name);
|
||||
if(fields[group][p][field].size !== undefined) { fields[group][p][field].bind.setFontSize(fields[group][p][field].size); }
|
||||
fields[group][p][field].bind.setText(`${ moment(birthdate).format("DD.MM.YYYY") }, ${ placebirth }, ${ citizenship.title }, ${ personal_doctypes[doctype].toString().toUpperCase() } ${ seria.toString() } ${ docnumber.toString() }, выдан ${ issueby.toString() }, ${ code.toString() } ${ moment(issuedate).format("DD.MM.YYYY") }`.toUpperCase());
|
||||
fields[group][p][field].bind.setText(`${ moment(birthdate).format("DD.MM.YYYY") }, ${ placebirth }, ${ citizenship.title }, ${ personal_doctypes[doctype].toString().toUpperCase() } ${ seria.toString() } ${ docnumber.toString() }, выдан ${ issueby.toString() } ${ moment(issuedate).format("DD.MM.YYYY") }, ${ code.toString() }`.toUpperCase());
|
||||
}
|
||||
else if(field === "registration")
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user