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

Unknown encoding for 'GBK-EUC-H'

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.8.0-incubator
    • 1.5.0
    • PDModel
    • Windows

    Description

      Unknown encoding for 'GBK-EUC-H' for chinese pdf document. To fix it.

      1.add method to org.apache.pdfbox.pdmodel.font.PDFont.java

      public String getEncodingName() {
      COSBase encoding = font.getDictionaryObject(COSName.ENCODING);
      if (encoding != null) {
      if (encoding instanceof COSName)

      { return ((COSName) encoding).getName(); }

      }
      return null;
      }

      2.modify encode method.
      from
      if( retval == null && cmap != null )

      { retval = cmap.lookup( c, offset, length ); }

      //if we havn't found a value yet and
      //we are still on the first byte and
      //there is no cmap or the cmap does not have 2 byte mappings then try to encode
      //using fallback methods.

      to

      if( retval == null && cmap != null )
      {
      String encodingStr = getEncodingName();
      if (encodingStr != null) {
      EncodingConverter converter = EncodingConversionManager.getConverter(encodingStr);
      if (converter != null)

      { if (length == 1) return null; retval = converter.convertBytes(c, offset, length, cmap); }

      else

      { retval = cmap.lookup( c, offset, length ); }

      } else

      { retval = cmap.lookup( c, offset, length ); }

      }
      //if we havn't found a value yet and
      //we are still on the first byte and
      //there is no cmap or the cmap does not have 2 byte mappings then try to encode
      //using fallback methods.

      Attachments

        1. PDFBOX612-1DE9A100d011.png
          573 kB
          Andreas Lehmkühler
        2. PDFBOX612-1DE9A100d01.txt
          4 kB
          Andreas Lehmkühler
        3. 1DE9A100d01.pdf
          12 kB
          Gang Luo

        Activity

          People

            lehmi Andreas Lehmkühler
            lgjut Gang Luo
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: