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

java.lang.StringIndexOutOfBoundsException in PDTrueTypeFont.getGIDForCharacterCode

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.0
    • Component/s: Parsing
    • Labels:
      None

      Description

      I get this exception with the attached file:

      java.lang.StringIndexOutOfBoundsException: String index out of range: 0
              at java.lang.String.codePointAt(Unknown Source)
              at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.getGIDForCharacterCode(PDTrueTypeFont.java:452)
              at org.apache.pdfbox.rendering.font.TTFGlyph2D.getGIDForCharacterCode(TTFGlyph2D.java:178)
              at org.apache.pdfbox.rendering.font.TTFGlyph2D.getPathForCharacterCode(TTFGlyph2D.java:150)
              at org.apache.pdfbox.rendering.PageDrawer.drawGlyph2D(PageDrawer.java:354)
              at org.apache.pdfbox.rendering.PageDrawer.processGlyph(PageDrawer.java:325)
      

      The cause is that Encoding.getCharacterForName(characterName) returns an empty string. This is because characterName is ".notdef". Adobe Reader displays a gap. This can be seen at "Alumni Weekend" and "health professions". A copy & paste into an editor shows that Adobe returns a hex 1 code. My change ignores the wrong code, outputs an error message and the file renders like in adobe reader.

        Attachments

          Activity

            People

            • Assignee:
              tilman Tilman Hausherr
              Reporter:
              tilman Tilman Hausherr
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: