How to deal with missing characters in the default font of a text field?

We are using iText to create PDFs using a custom font and I am running into an issue with the unicode character 2120 (SM, Service Mark). The problem is the glyph is not in the custom font. Is there a way I can specify a fallback font for a field in a PDF? We tried adding a text field with Verdana so that the form had the secondary font embedded in it but that didn't seem to help.

Posted on StackOverflow on Nov 7, 2013 by El Hombre

First you just need to add substitutions fonts to the form:

AcroFields form = stamper.getAcroFields();

Now the font defined in the form has preference, but if that font can't show a specific glyph, it will look at bf1, then at bf2 and so on.

Ready to use iText?

Try our iText 7 Library and add-ons FREE for 30 days. Test your proof of concept, and see if our solution is right for you.

Get my FREE trial

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now