I think I got it. When the widths are missing, PDFBox uses a default value of 1000. As you noticed, there were only some widths, for the characters in "Ciao".

So the solution is to get a clean font for the field. Here's how:

1) download the font from google

https://fonts.google.com/specimen/Montserrat

2) extract the file Montserrat-Regular.ttf

3) add this code: after getting the acroform object and before changing the field:

            PDResources defaultResources = form.getDefaultResources();
            PDFont font = PDType0Font.load(doc, new FileInputStream("XXXX/Montserrat-Regular.ttf"), *false*);
defaultResources.put(COSName.getPDFName("Montserrat-Regular"), font);

Here's how it looks now:

Hope this helps!

Tilman

Reply via email to