INCOMPLETE: refactor signature pad and input into a single component

This commit is contained in:
Ephraim Atta-Duncan
2024-01-12 11:04:22 +00:00
parent 6ad3edb6c8
commit e17e4566cd
3 changed files with 137 additions and 24 deletions

View File

@ -40,10 +40,19 @@ export const insertFieldInPDF = async (pdf: PDFDocument, field: FieldWithSignatu
const fieldX = pageWidth * (Number(field.positionX) / 100);
const fieldY = pageHeight * (Number(field.positionY) / 100);
const font = await pdf.embedFont(isSignatureField ? fontCaveat : StandardFonts.Helvetica);
// const url =
// 'https://fonts.gstatic.com/s/dancingscript/v25/If2cXTr6YS-zF4S-kcSWSVi_sxjsohD9F50Ruu7BMSoHTQ.ttf';
const url = 'https://fonts.gstatic.com/s/caveat/v18/WnznHAc5bAfYB2QRah7pcpNvOx-pjfJ9SII.ttf';
const googleFont = await fetch(url).then(async (res) => res.arrayBuffer());
const font = await pdf.embedFont(isSignatureField ? googleFont : StandardFonts.Helvetica, {
subset: true,
features: { liga: false },
});
if (field.type === FieldType.SIGNATURE || field.type === FieldType.FREE_SIGNATURE) {
await pdf.embedFont(fontCaveat);
await pdf.embedFont(googleFont, { subset: true, features: { liga: false } });
}
const CUSTOM_TEXT = field.customText || field.Signature?.typedSignature || '';