You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have pdf form created with Adobe Acrobat Pro that contains some text fields. I have put a custom font (Inter) embed in the pdf file and I have selected that font to be the one on the text fields by default. When I type some text in the Acrobat, the text is nicely populated into the field. When, though, I set text using the library, the text is not properly vertically aligned. Instead, it goes on the top of the field. I will paste some of my code so you understand what I am doing and if there is anything I am doing it wrong.
`templateConfiguration.fields.forEach(field => {`
`const value = data.get(field);`
`const pdfField = form.getField(field) as PDFTextField;`
` pdfField.setFontSize(11);`
`pdfField.setText(value);`
` pdfField.updateAppearances(font);`
`// I have tried even this without success`
`//pdfField.defaultUpdateAppearances(font);`
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello all,
I have pdf form created with Adobe Acrobat Pro that contains some text fields. I have put a custom font (Inter) embed in the pdf file and I have selected that font to be the one on the text fields by default. When I type some text in the Acrobat, the text is nicely populated into the field. When, though, I set text using the library, the text is not properly vertically aligned. Instead, it goes on the top of the field. I will paste some of my code so you understand what I am doing and if there is anything I am doing it wrong.
Some code is following
const templateInBytes = await readFile(pdfTemplatePath);
const template = await PDFDocument.load(templateInBytes);
template.registerFontkit(fontkit);
const font = await template.embedFont(await loadFontWithType(fontHyphenVariant));
const form = template.getForm();
});
const newData = await template.save({ updateFieldAppearances: true });
Beta Was this translation helpful? Give feedback.
All reactions