Il giorno mar 4 feb 2025 alle ore 20:32 Tilman Hausherr <
thaush...@t-online.de> ha scritto:

> 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
>

Thanks,

I think that in that way I have a double copy of the Montserrat-Regular.

Is it possible to fill the charwidth array with the correct size or read
the char width from the fullEmbed font?


Thanks,
Luca

Reply via email to