Package org.apache.pdfbox.encoding

Examples of org.apache.pdfbox.encoding.EncodingManager


     */
    public Encoding getEncoding() throws IOException
    {
        if( fontEncoding == null )
        {
            EncodingManager manager = getEncodingManager();
            COSBase encoding = getEncodingObject(); //font.getDictionaryObject( COSName.ENCODING );
            if( encoding == null )
            {
                FontMetric metric = getAFM();
                if( metric != null )
                {
                    fontEncoding = new AFMEncoding( metric );
                }
                if( fontEncoding == null )
                {
                    fontEncoding = manager.getStandardEncoding();
                }
            }
            /**
             * Si la cl� /Encoding existe dans le dictionnaire fonte il y a deux possibilit�s :
             * 1er cas : elle est associ� � une reference contenant un dictionnaire de type encoding.
             * Ce dictionnaire PDF est repr�sent� par un DictionaryEncoding.
             * If the /Encoding Key does exist in the font dictionary, there are two cases :
             * case one : The value associated with /Encoding is a reference to a dictionary.
             * This dictionary is represented by an instance of DictionaryEncoding class
             */
            else if( encoding instanceof COSDictionary )
            {
                COSDictionary encodingDic = (COSDictionary)encoding;
                //Let's see if the encoding dictionary has a base encoding
                //If it does not then we will attempt to get it from the font
                //file
                COSName baseEncodingName = (COSName) encodingDic.getDictionaryObject(
                    COSName.BASE_ENCODING);
                //on ajoute une entr�e /BaseEncoding dans /Encoding uniquement si elle en est absente
                //if not find in Encoding dictinary target, we try to find it from else where
                if( baseEncodingName == null)
                {
                    COSName fontEncodingFromFile = getEncodingFromFont();
                    encodingDic.setItem(
                        COSName.BASE_ENCODING,
                        fontEncodingFromFile );
                }
                fontEncoding = new DictionaryEncoding( encodingDic );
            }
            else if( encoding instanceof COSName )
            {
                if( !encoding.equals( COSName.IDENTITY_H ) )
                {
                    fontEncoding = manager.getEncoding( (COSName)encoding );
                }
            }
            else
            {
                throw new IOException( "Unexpected encoding type:" + encoding.getClass().getName() );
View Full Code Here


   
    private static EncodingManager encodingManager = null;
   
    protected static EncodingManager getEncodingManager(){
        if(encodingManager == null){
            encodingManager = new EncodingManager();
        }
        return encodingManager;
    }
View Full Code Here

    }

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

     */
    public Encoding getEncoding() throws IOException
    {
        if( fontEncoding == null )
        {
            EncodingManager manager = getEncodingManager();
            COSBase encoding = getEncodingObject(); //font.getDictionaryObject( COSName.ENCODING );
            if( encoding == null )
            {
                FontMetric metric = getAFM();
                if( metric != null )
                {
                    fontEncoding = new AFMEncoding( metric );
                }
                if( fontEncoding == null )
                {
                    fontEncoding = manager.getStandardEncoding();
                }
            }
            /**
             * Si la cl� /Encoding existe dans le dictionnaire fonte il y a deux possibilit�s :
             * 1er cas : elle est associ� � une reference contenant un dictionnaire de type encoding.
             * Ce dictionnaire PDF est repr�sent� par un DictionaryEncoding.
             * If the /Encoding Key does exist in the font dictionary, there are two cases :
             * case one : The value associated with /Encoding is a reference to a dictionary.
             * This dictionary is represented by an instance of DictionaryEncoding class
             */
            else if( encoding instanceof COSDictionary )
            {
                COSDictionary encodingDic = (COSDictionary)encoding;
                //Let's see if the encoding dictionary has a base encoding
                //If it does not then we will attempt to get it from the font
                //file
                COSName baseEncodingName = (COSName) encodingDic.getDictionaryObject(
                    COSName.BASE_ENCODING);
                //on ajoute une entr�e /BaseEncoding dans /Encoding uniquement si elle en est absente
                //if not find in Encoding dictinary target, we try to find it from else where
                if( baseEncodingName == null)
                {
                    COSName fontEncodingFromFile = getEncodingFromFont();
                    encodingDic.setItem(
                        COSName.BASE_ENCODING,
                        fontEncodingFromFile );
                }
                fontEncoding = new DictionaryEncoding( encodingDic );
            }
            else if( encoding instanceof COSName )
            {
                if( !encoding.equals( COSName.IDENTITY_H ) )
                {
                    fontEncoding = manager.getEncoding( (COSName)encoding );
                }
            }
            else
            {
                throw new IOException( "Unexpected encoding type:" + encoding.getClass().getName() );
View Full Code Here

   
    private static EncodingManager encodingManager = null;
   
    protected static EncodingManager getEncodingManager(){
        if(encodingManager == null){
            encodingManager = new EncodingManager();
        }
        return encodingManager;
    }
View Full Code Here

     *
     * @param fontEncoding
     */
    private void checkEncodingAsString(COSBase fontEncoding)
    {
        EncodingManager emng = new EncodingManager();
        // Encoding is a Name, check if it is an Existing Encoding
        String enc = COSUtils.getAsString(fontEncoding, cosDocument);
        try
        {
            this.encoding = emng.getEncoding(COSName.getPDFName(enc));
        }
        catch (IOException e)
        {
            // the encoding doesn't exist
            this.fontContainer.push(new ValidationError(ERROR_FONTS_ENCODING));
View Full Code Here

   * @return
   */
  private boolean checkEncoding() {
    COSDocument cDoc = this.handler.getDocument().getDocument();

    EncodingManager emng = new EncodingManager();
    if (COSUtils.isString(this.fontEncoding, cDoc)) {
      // ---- Encoding is a Name, check if it is an Existing Encoding
      String enc = COSUtils.getAsString(this.fontEncoding, cDoc);
      try {
        type3Encoding = emng.getEncoding(COSName.getPDFName(enc));
      } catch (IOException e) {
        // ---- the encoding doesn't exist
        this.fontContainer.addError(new ValidationError(ERROR_FONTS_ENCODING));
        return false;
      }
View Full Code Here

     *
     * @param fontEncoding
     */
    private void checkEncodingAsString(COSBase fontEncoding)
    {
        EncodingManager emng = new EncodingManager();
        // Encoding is a Name, check if it is an Existing Encoding
        String enc = COSUtils.getAsString(fontEncoding, cosDocument);
        try
        {
            this.encoding = emng.getEncoding(COSName.getPDFName(enc));
        }
        catch (IOException e)
        {
            // the encoding doesn't exist
            this.fontContainer.push(new ValidationError(ERROR_FONTS_ENCODING));
View Full Code Here

    }

    private Map<Integer,String> loadEncoding(COSName name) throws IOException
    {
        Map<Integer,String> result = new LinkedHashMap<Integer,String>();
        EncodingManager encodingManager = new EncodingManager();
        Encoding encoding = encodingManager.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

     *
     * @throws IOException If there is an error getting the encoding.
     */
    public Encoding getEncoding() throws IOException
    {
        EncodingManager manager = new EncodingManager();
        if( fontEncoding == null )
        {
            COSBase encoding = font.getDictionaryObject( COSName.ENCODING );
            if( encoding == null )
            {
                FontMetric metric = getAFM();
                if( metric != null )
                {
                    fontEncoding = new AFMEncoding( metric );
                }
                if( fontEncoding == null )
                {
                    fontEncoding = manager.getStandardEncoding();
                }
            }
            /**
             * Si la cl� /Encoding existe dans le dictionnaire fonte il y a deux possibilit�s :
             * 1er cas : elle est associ� � une reference contenant un dictionnaire de type encoding.
             * Ce dictionnaire PDF est repr�sent� par un DictionaryEncoding.
             * If the /Encoding Key does exist in the font dictionary, there are two cases :
             * case one : The value associated with /Encoding is a reference to a dictionary.
             * This dictionary is represented by an instance of DictionaryEncoding class
             */
            else if( encoding instanceof COSDictionary )
            {
                COSDictionary encodingDic = (COSDictionary)encoding;
                //Let's see if the encoding dictionary has a base encoding
                //If it does not then we will attempt to get it from the font
                //file
                COSName baseEncodingName = (COSName) encodingDic.getDictionaryObject(
                    COSName.BASE_ENCODING);
                //on ajoute une entr�e /BaseEncoding dans /Encoding uniquement si elle en est absente
                //if not find in Encoding dictinary target, we try to find it from else where
                if( baseEncodingName == null)
                {
                    COSName fontEncodingFromFile = getEncodingFromFont();
                    encodingDic.setItem(
                        COSName.BASE_ENCODING,
                        fontEncodingFromFile );
                }
                fontEncoding = new DictionaryEncoding( encodingDic );
            }
            else if( encoding instanceof COSName )
            {
                if( !encoding.equals( COSName.IDENTITY_H ) )
                {
                    fontEncoding = manager.getEncoding( (COSName)encoding );
                }
            }
            else
            {
                throw new IOException( "Unexpected encoding type:" + encoding.getClass().getName() );
View Full Code Here

TOP

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

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.