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
we are using pdf-lib for the following scenario. We open a pdf template and then loop through each of the form fields and set the text accordingly.
How did you attempt to do it?
Initially we tried the direct approach which is to just change the text of the form field using setText.
What actually happened?
The issue is that even though the text gets correctly updated the font used is not the one set up by the template but rather a generic helvetica one. When we call
however this even though sets up the correct font renders it with incorrect characters (not random but shifted) and with a way larger text spacing (as you can see in the attached image)
The only way we were able to have it display correctly is to re-embed the fonts but this breaks our use-case scenario since pdf are provided at us as-is
What did you expect to happen?
Have the updated value of the form text field respect the font that is configured for the specific form field
How can we reproduce the issue?
Create a pdf tempate that includes a form field but use a custom embedded font for it. Then open the file with pdf-lib and change the field value through setText
Version
2.1.4
What environment are you running pdf-lib in?
Node
Checklist
My report includes a Short, Self Contained, Correct (Compilable) Example.
I have attached all PDFs, images, and other files needed to run my SSCCE.
Additional Notes
No response
The text was updated successfully, but these errors were encountered:
Looks like the font descriptor embedded in the pdf is wrong, or doesn't respect what pdf-lib expects. We don't know very well that part of the code. You'll have to investigate on your own, but we can provide feedback and merge a PR when ready.
What were you trying to do?
Hello all,
we are using pdf-lib for the following scenario. We open a pdf template and then loop through each of the form fields and set the text accordingly.
How did you attempt to do it?
Initially we tried the direct approach which is to just change the text of the form field using setText.
What actually happened?
The issue is that even though the text gets correctly updated the font used is not the one set up by the template but rather a generic helvetica one. When we call
field.acroField.dict.lookup(PDFName.of('DA'))?.toString();
the font that should be displayed is correctly set in the field.
We also were able to find the fontBytes by searching the context and then used this to load and embed the font
however this even though sets up the correct font renders it with incorrect characters (not random but shifted) and with a way larger text spacing (as you can see in the attached image)
The only way we were able to have it display correctly is to re-embed the fonts but this breaks our use-case scenario since pdf are provided at us as-is
What did you expect to happen?
Have the updated value of the form text field respect the font that is configured for the specific form field
How can we reproduce the issue?
Create a pdf tempate that includes a form field but use a custom embedded font for it. Then open the file with pdf-lib and change the field value through setText
Version
2.1.4
What environment are you running pdf-lib in?
Node
Checklist
Additional Notes
No response
The text was updated successfully, but these errors were encountered: