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

pdmodel.font.PDSimpleFont hanging on TrueType font (ubuntu)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.0
    • 2.0.0
    • PDModel
    • None
    • Ubuntu 8.04 - Headless

    Description

      When calling PDPage.convertToImage(imagetype,resolution) , I have found a case where the application hangs. No error messages, no exceptions, no CPU spike, no I/O. The error had to do with some strange corruption of the awtFont, by the time it reached the method PDSimpleFont.drawString. Some pretty deep digging turned up that if a font with too few glyphs is sent into PDSimpleFont.writeFont, it will enter Graphics2D.drawString ... ne'er to return.

      If a check is done to count the glyphs and if they fall below a certain threshold, then just re-instantiate the Font, then all goes well. Typical numbers range from 70 to 1000+, so I've gone with an arbitrary value of 40. All goes well, and I can't measure any difference in performance (except that my app will actually return from attempting this doc!).

      Attached is a sample PDF which can re-create the problem, and a patch which seems to solve it sensibly.

      Attachments

        1. pdsimplefont_rebuildfont_fewglyphs.patch
          0.7 kB
          Craig Stires
        2. pdsimplefont_rebuildfont_fewglyphs_40.patch
          0.6 kB
          Craig Stires
        3. F001u_3_7j.pdf
          43 kB
          Craig Stires

        Issue Links

          Activity

            People

              lehmi Andreas Lehmkühler
              craig_s Craig Stires
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: