Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Original font is not mantained when a form is filled #1538

Open
2 tasks done
gioppoluca opened this issue Nov 4, 2023 · 1 comment
Open
2 tasks done

Original font is not mantained when a form is filled #1538

gioppoluca opened this issue Nov 4, 2023 · 1 comment

Comments

@gioppoluca
Copy link

What were you trying to do?

I'm using the acroform's fields to fill an existing PDF module.
The resulting module looses the original font of the module and gets Helvetica.

How did you attempt to do it?

field.setText();

What actually happened?

The resulting module looses the original font of the module and gets Helvetica.

What did you expect to happen?

The field keeps its original font.
Also I'm unable to retrieve the used font from any available API.

How can we reproduce the issue?

I use LibreOffice to create a module, assign a different font and create the PDF.
Also tried to modify the PDF with acrobat and altering the font again, with no luck.
You can see the PDF here: https://github.com/gioppoluca/sheet-export/blob/master/mappings/dnd5e/experimental/latest/5e-model.pdf

Version

1.17.1

What environment are you running pdf-lib in?

Browser

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

Is there an API to retrieve the original font used?

@dcbr
Copy link

dcbr commented Dec 31, 2023

I encountered the same issue and found following solution when the font was previously embedded using pdf-lib. See also my comment here.

// Get embedded font using code from above comment
field.setText(newText);
field.updateAppearances(font);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants