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

Fonts should not be cached by PDFStreamEngine

    XMLWordPrintableJSON

Details

    Description

      org.apache.pdfbox.util.PDFStreamEngine
      Fonts are cached using variable 'private Map documentFontCache = new HashMap();'
      which is used in method 'processSubStream()' and the call 'sr.fonts = resources.getFonts(documentFontCache);

      The problem is that PDF documents can store a limited range of 'firstChar' and 'lastChar' (maybe just a space char), and then expand that range at a later point within the same page. When the font is cached, those updates are ignored.

      In particular, test 'http://www.encana.com/investor/financial/shareholder/pdfs/info-circular-french.pdf, pg 1'.
      Using font caching, the widths of the characters in the upper right corner of the page are reported as zero, and the text extraction and text merging is compromised.
      Without font caching, the widths are correct. There are other examples that cause the same problem.

      To fix the problem change the call in method 'processSubStream()' to:
      sr.fonts = resources.getFonts(null);

      There was some effort put into font caching. Unfortunately, it should not be used on unknown documents.

      Attachments

        Issue Links

          Activity

            People

              lehmi Andreas Lehmkühler
              petercostello Peter Costello
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 1h
                  1h
                  Remaining:
                  Remaining Estimate - 1h
                  1h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified