I generated a PDF with a row of chars M. Every M had consistent width, but the distance between each was changing: first couple was 2px, the fifth one had 3px, then the next four had 2px, the tenth 3px, etc.
Since there is absolutly no difference in any of the M's or any spaces inbetween in my code, only conclusion is that some width value could not scale properly in coordinate system generating an extra pixel every so often.
This is how PDF calculates how much to move horizontally when a glyph is painted:
When calcualting for a standard 96DPI display, each pixel is represented by 0.75 unit (checked and tested thoroughly).
Having that in mind, I need to make sure that Tx value is divisible by 0.75.
This is what I know:
- w0 is an integer originating from widths array (widths[])
- Tfs is a nubmer divisible by 0.75 (set by me)
- Th is 100 (default)
- Tc and Tw are both 0 (default)
So Tj/1000 needs to be an integer, meaning Tj needs to be divisible by 1000.
One way is to get and adjust the Tj value. Another approach to this is to acces the Tx value once it's calcualted and just change it to closest value divisible by 0.75.
How do I do this in iText?
Or is my whole assumption wrong?
Source: link (page 252)