When I fill the PDF form it clears the font property of the field #1352
Unanswered
shevlad1104
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using pdf-lib to fill the PDF form through this code:
`const pdfDoc = await PDFDocument.load(existingPdfBytes);
pdfDoc.registerFontkit(fontkit);
const cambriaFont = await pdfDoc.embedFont(fs.readFileSync('./fonts/cambria-font-0346.ttf'));
const form = pdfDoc.getForm();
const fieldSecondName = form.getTextField('second_name');
fieldSecondName.setText('Bradburry');
fieldSecondName.updateAppearances(cambriaFont);`
It works well and fills the field with right font, but when I open PDF's form in Acrobat and look at properties of the processed field, the font property is empty, however it was filled before. You can see it in the attached image
My field has this font set before processing and after this processing it becomes clear.
This is a problem because user can open file and refill this field and it can set default font. But I need it to save my font.
So my question is how to make font property of the PDF's field save its value. Or may be I need to solve it from some other side. Thank you.
Here is pdfs before and after processing https://transfer.sh/%28/nSqwC9/input.pdf,/WxnfHo/output.pdf%29.zip
Beta Was this translation helpful? Give feedback.
All reactions