Package org.apache.pdfbox.encoding

Examples of org.apache.pdfbox.encoding.Encoding


      InputStream fontProgram,
      int clearTextLength,
      int eexecLength,
      String encodingName) throws IOException {

    Encoding encoding = getEncodingObject(encodingName);
    return createParserWithEncodingObject(fontProgram, clearTextLength, eexecLength, encoding);
  }
View Full Code Here


    Encoding encoding = getEncodingObject(encodingName);
    return createParserWithEncodingObject(fontProgram, clearTextLength, eexecLength, encoding);
  }

  private static Encoding getEncodingObject(String encodingName) {
    Encoding encoding = new StandardEncoding();
    if (FONT_DICTIONARY_VALUE_ENCODING_MAC.equals(encodingName)) {
      encoding = new MacRomanEncoding();
    } else if (FONT_DICTIONARY_VALUE_ENCODING_MAC_EXP.equals(encodingName)) {
      encoding = new MacRomanEncoding();
    } else if (FONT_DICTIONARY_VALUE_ENCODING_WIN.equals(encodingName)) {
View Full Code Here

      int innerFontCid = cid;


      if (cmap.getPlatformEncodingId() == 1 && cmap.getPlatformId() == 3) {
          try {
              Encoding fontEncoding = this.font.getFontEncoding();
              String character = fontEncoding.getCharacter(cid);
              if (character == null) {
                  return false;
              }

              char[] characterArray = character.toCharArray();
View Full Code Here

        // ---- check the encoding part.
        if (pFontDesc.isNonSymbolic()) {
          // ---- only MacRomanEncoding or WinAnsiEncoding are allowed for a non
          // symbolic font
          Encoding encodingValue = this.pFont.getFontEncoding();
          if (encodingValue == null
              || !(encodingValue instanceof MacRomanEncoding || encodingValue instanceof WinAnsiEncoding)) {
            this.fontContainer.addError(new ValidationResult.ValidationError(
                ValidationConstants.ERROR_FONTS_ENCODING,
                "The Encoding is invalid for the NonSymbolic TTF"));
View Full Code Here

    {
        float retval = 0;
        FontMetric metric = getAFM();
        if( metric != null )
        {
            Encoding encoding = getEncoding();
            String characterName = encoding.getName( code );
            retval = metric.getCharacterWidth( characterName );
        }
        return retval;
    }
View Full Code Here

        }
       
        // there is no cmap but probably an encoding with a suitable mapping
        if( retval == null )
        {
            Encoding encoding = getEncoding();
            if( encoding != null )
            {
                retval = encoding.getCharacter( getCodeFromArray( c, offset, length ) );
            }
            if( retval == null && (cmap == null || length == 2))
            {
                retval = getStringFromArray( c, offset, length );
            }
View Full Code Here

            {
                widths.add( zero );
            }
            // Encoding singleton to have acces to the chglyph name to
            // unicode cpoint point mapping of Adobe's glyphlist.txt
            Encoding glyphlist = WinAnsiEncoding.INSTANCE;

            // A character code is mapped to a glyph name via the provided
            // font encoding. Afterwards, the glyph name is translated to a
            // glyph ID.
            // For details, see PDFReference16.pdf, Section 5.5.5, p.401
            //
            for (Entry<Integer, String> e : codeToName.entrySet())
            {
                String name = e.getValue();
                // pdf code to unicode by glyph list.
                String c = glyphlist.getCharacter(name);
                int charCode = c.codePointAt(0);
                int gid = uniMap.getGlyphId(charCode);
                if (gid != 0)
                {
                    widths.set( e.getKey().intValue()-firstChar,widthValues[gid]*scaling );
View Full Code Here

    }

    protected void determineEncoding()
    {
        super.determineEncoding();
        Encoding fontEncoding = getFontEncoding();
        if(fontEncoding == null)
        {
            FontMetric metric = getAFM();
            if (metric != null)
            {
View Full Code Here

        cffFont.setCharset(pdfCharset);
        charStringsDict.clear();
        charStringsDict.putAll(pdfCharStringsDict);

       
        Encoding fontEncoding = getFontEncoding();
        Map<String, Integer> nameToCode = fontEncoding != null ? fontEncoding.getNameToCodeMap() : null;
        for (CFFFont.Mapping mapping : mappings)
        {
            int sid = mapping.getSID();
            String name = mapping.getName();
            String character = null;
            if (nameToCode != null && nameToCode.containsKey(name))
            {
                sid = nameToCode.get(name);
                character = fontEncoding.getCharacter(name);
            }
            if (character == null)
            {
                character = Encoding.getCharacterForName(name);
            }
View Full Code Here

    }

    private Map<Integer,String> loadEncoding(COSName name) throws IOException
    {
        Map<Integer,String> result = new LinkedHashMap<Integer,String>();
        Encoding encoding = EncodingManager.INSTANCE.getEncoding(name);
        for( Iterator<Map.Entry<Integer,String>> it = (encoding.getCodeToNameMap().entrySet()).iterator();
                    it.hasNext();)
        {
            Map.Entry<Integer,String> entry = it.next();
            result.put(entry.getKey(), (entry.getValue()));
        }
View Full Code Here

TOP

Related Classes of org.apache.pdfbox.encoding.Encoding

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.