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

Fix font subtype automatically

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.1
    • None
    • PDModel, Rendering

    Description

      Subtype is parsed as "Type0" by PDFBox, but parsed as "Type1" by Adobe Reader.
      This is not a bug of PDFBox.
      The reason is TCPDF 4.5.041 generate font AdobeSongStd-Light with bad subtype "Type0".
      It should be "Type1".

      I have test the following codes and they work.
      File: org/apache/pdfbox/pdmodel/font/PDFontFactory.java
      Method: public static PDFont createFont( COSDictionary dic ) throws IOException

      Original:
      else if( subType.equals( COSName.TYPE0 ) )
      {
      retval = new PDType0Font( dic );
      }

      Fixed:
      else if( subType.equals( COSName.TYPE0 ) )
      {
      COSName encoding = (COSName)dic.getDictionaryObject(COSName.ENCODING);
      retval = (encoding!=null) ? new PDType1Font( dic ) : new PDType0Font( dic );
      }

      With such patch PDFBox will act like Adobe Reader.

      Attachments

        1. adobe-screenshot.png
          227 kB
          Raymond Wu
        2. pdf-screenshot.png
          85 kB
          Raymond Wu
        3. page-08.pdf
          238 kB
          Raymond Wu

        Activity

          People

            Unassigned Unassigned
            raymondwu Raymond Wu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: