I am trying to change the font style and font family for the signature field in my PDF using PDF-Lib library in nodejs.Here is my code , but I am unable to change the font.
const {PDFDocument, degrees, rgb, StandardFonts} = require('pdf-lib');
const fontKit = require('@pdf-lib/fontkit');
const fs = require('fs');
var fontkit = require('fontkit');
const pdfDoc = await PDFDocument.load(await readFile('pdf24_merged.pdf'));
pdfDoc.registerFontkit(fontkit);
const timesRomanFont = await pdfDoc.embedFont(StandardFonts.TimesRomanBoldItalic)
const signature = form.getTextField('Datum und Unterschrift');
signature.setFontSize(25);
signature.setText(str);
signature.updateAppearances(timesRomanFont);
signature.defaultUpdateAppearances(timesRomanFont);
console.log(str);
I have tried one of the answers on stackoverflow but didn't work out for me.Can some suggest me changes so that I can change the font family and style to italics so that my signature field looks different from text on the rest of the fields?