Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-2805

Incorrect CapHeight calculation and usage in form fields

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.0
    • Fix Version/s: None
    • Component/s: AcroForm, PDModel
    • Labels:
      None

      Description

      I discovered that the CapHeight value was being incorrectly calculated by TrueTypeEmbedder. Fixing this has a knock-on effect for CreateFormField, which uses that value for vertical text positioning, after the fix, it no longer works correctly.

      I took a look at this and the problem is that CapHeight isn't the right value to use when calculating text positioning for form fields. I've never seen the CapHeight used in a typographical setting and its use is unorthodox. I did an experiment by modifying the embedded CapHeight and I can confirm that Acrobat does not use it when calculating the position of form field text.

      The natural choice for text positioning in form fields would be to use either the depth of the font's bbox or the descender. Some experiments with Acrobat show that the bbox's depth yield the best results. There's still a slight difference of around 0.02pt which is unaccounted for when compared to Acrobat, but this is still an improvement on the previous, now broken code which used the CapHeight.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                jahewson John Hewson
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: