Package org.apache.pdfbox.encoding

Examples of org.apache.pdfbox.encoding.Type1Encoding


                   
                    // this section parses the font program stream searching for a /Encoding entry
                    // if it contains an array of values a Type1Encoding will be returned
                    // if it encoding contains an encoding name the corresponding Encoding will be returned
                    String line = "";
                    Type1Encoding encoding = null;
                    while( (line = in.readLine()) != null)
                    {
                        if (extractEncoding)
                        {
                            if (line.startsWith("currentdict end")) {
                                if (encoding != null)
                                    setFontEncoding(encoding);
                                break;
                            }
                            if (line.startsWith("/Encoding"))
                            {
                                if(line.contains("array"))
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    int arraySize = Integer.parseInt(st.nextToken());
                                    encoding = new Type1Encoding(arraySize);
                                }
                                // if there is already an encoding, we don't need to
                                // assign another one
                                else if (getFontEncoding() == null)
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    String type1Encoding = st.nextToken();
                                    setFontEncoding(
                                        EncodingManager.INSTANCE.getEncoding(
                                                COSName.getPDFName(type1Encoding)));
                                    break;
                                }
                            }
                            else if (line.startsWith("dup")) {
                                StringTokenizer st = new StringTokenizer(line.replaceAll("/"," /"));
                                // ignore the first token
                                st.nextElement();
                                try
                                {
                                    int index = Integer.parseInt(st.nextToken());
                                    String name = st.nextToken();
                                    if(encoding == null)
                                    {
                                        log.warn("Unable to get character encoding. " +
                                                "Encoding definition found without /Encoding line.");
                                    }
                                    else
                                    {
                                        encoding.addCharacterEncoding(index, name.replace("/", ""));
                                    }
                                }
                                catch(NumberFormatException exception)
                                {
                                    // there are (tex?)-some fonts containing postscript code like the following,
View Full Code Here


                   
                    // this section parses the font program stream searching for a /Encoding entry
                    // if it contains an array of values a Type1Encoding will be returned
                    // if it encoding contains an encoding name the corresponding Encoding will be returned
                    String line = "";
                    Type1Encoding encoding = null;
                    while( (line = in.readLine()) != null)
                    {
                        if (extractEncoding)
                        {
                            if (line.startsWith("currentdict end")) {
                                if (encoding != null)
                                    setFontEncoding(encoding);
                                break;
                            }
                            if (line.startsWith("/Encoding"))
                            {
                                if(line.contains("array"))
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    int arraySize = Integer.parseInt(st.nextToken());
                                    encoding = new Type1Encoding(arraySize);
                                }
                                // if there is already an encoding, we don't need to
                                // assign another one
                                else if (getFontEncoding() == null)
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    String type1Encoding = st.nextToken();
                                    setFontEncoding(
                                        EncodingManager.INSTANCE.getEncoding(
                                                COSName.getPDFName(type1Encoding)));
                                    break;
                                }
                            }
                            else if (line.startsWith("dup")) {
                                StringTokenizer st = new StringTokenizer(line.replaceAll("/"," /"));
                                // ignore the first token
                                st.nextElement();
                                try
                                {
                                    int index = Integer.parseInt(st.nextToken());
                                    String name = st.nextToken();
                                    if(encoding == null)
                                    {
                                        log.warn("Unable to get character encoding. " +
                                                "Encoding definition found without /Encoding line.");
                                    }
                                    else
                                    {
                                        encoding.addCharacterEncoding(index, name.replace("/", ""));
                                    }
                                }
                                catch(NumberFormatException exception)
                                {
                                    // there are (tex?)-some fonts containing postscript code like the following,
View Full Code Here

                   
                    // this section parses the font program stream searching for a /Encoding entry
                    // if it contains an array of values a Type1Encoding will be returned
                    // if it encoding contains an encoding name the corresponding Encoding will be returned
                    String line = "";
                    Type1Encoding encoding = null;
                    while( (line = in.readLine()) != null)
                    {
                        if (extractEncoding)
                        {
                            if (line.startsWith("currentdict end")) {
                                if (encoding != null)
                                    setFontEncoding(encoding);
                                break;
                            }
                            if (line.startsWith("/Encoding"))
                            {
                                if(line.contains("array"))
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    int arraySize = Integer.parseInt(st.nextToken());
                                    encoding = new Type1Encoding(arraySize);
                                }
                                // if there is already an encoding, we don't need to
                                // assign another one
                                else if (getFontEncoding() == null)
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    String type1Encoding = st.nextToken();
                                    setFontEncoding(
                                        EncodingManager.INSTANCE.getEncoding(
                                                COSName.getPDFName(type1Encoding)));
                                    break;
                                }
                            }
                            else if (line.startsWith("dup")) {
                                StringTokenizer st = new StringTokenizer(line.replaceAll("/"," /"));
                                // ignore the first token
                                st.nextElement();
                                int index = Integer.parseInt(st.nextToken());
                                String name = st.nextToken();
                                if(encoding == null)
                                    log.warn("Unable to get character encoding.  Encoding defintion found without /Encoding line.");
                                else
                                    encoding.addCharacterEncoding(index, name.replace("/", ""));
                            }
                        }
                        // according to the pdf reference, all font matrices should be same, except for type 3 fonts.
                        // but obviously there are some type1 fonts with different matrix values, see pdf sample
                        // attached to PDFBOX-935
View Full Code Here

                   
                    // this section parses the font program stream searching for a /Encoding entry
                    // if it contains an array of values a Type1Encoding will be returned
                    // if it encoding contains an encoding name the corresponding Encoding will be returned
                    String line = "";
                    Type1Encoding encoding = null;
                    while( (line = in.readLine()) != null)
                    {
                        if (extractEncoding)
                        {
                            if (line.startsWith("currentdict end")) {
                                if (encoding != null)
                                    setFontEncoding(encoding);
                                break;
                            }
                            if (line.startsWith("/Encoding"))
                            {
                                if(line.contains("array"))
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    int arraySize = Integer.parseInt(st.nextToken());
                                    encoding = new Type1Encoding(arraySize);
                                }
                                // if there is already an encoding, we don't need to
                                // assign another one
                                else if (getFontEncoding() == null)
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    String type1Encoding = st.nextToken();
                                    setFontEncoding(
                                        EncodingManager.INSTANCE.getEncoding(
                                                COSName.getPDFName(type1Encoding)));
                                    break;
                                }
                            }
                            else if (line.startsWith("dup")) {
                                StringTokenizer st = new StringTokenizer(line.replaceAll("/"," /"));
                                // ignore the first token
                                st.nextElement();
                                int index = Integer.parseInt(st.nextToken());
                                String name = st.nextToken();
                                if(encoding == null)
                                    log.warn("Unable to get character encoding.  Encoding defintion found without /Encoding line.");
                                else
                                    encoding.addCharacterEncoding(index, name.replace("/", ""));
                            }
                        }
                        // according to the pdf reference, all font matrices should be same, except for type 3 fonts.
                        // but obviously there are some type1 fonts with different matrix values, see pdf sample
                        // attached to PDFBOX-935
View Full Code Here

                   
                    // this section parses the font program stream searching for a /Encoding entry
                    // if it contains an array of values a Type1Encoding will be returned
                    // if it encoding contains an encoding name the corresponding Encoding will be returned
                    String line = "";
                    Type1Encoding encoding = null;
                    while( (line = in.readLine()) != null)
                    {
                        if (extractEncoding)
                        {
                            if (line.startsWith("currentdict end")) {
                                if (encoding != null)
                                    setFontEncoding(encoding);
                                break;
                            }
                            if (line.startsWith("/Encoding"))
                            {
                                if(line.contains("array"))
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    int arraySize = Integer.parseInt(st.nextToken());
                                    encoding = new Type1Encoding(arraySize);
                                }
                                // if there is already an encoding, we don't need to
                                // assign another one
                                else if (getFontEncoding() == null)
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    String type1Encoding = st.nextToken();
                                    setFontEncoding(
                                        EncodingManager.INSTANCE.getEncoding(
                                                COSName.getPDFName(type1Encoding)));
                                    break;
                                }
                            }
                            else if (line.startsWith("dup")) {
                                StringTokenizer st = new StringTokenizer(line.replaceAll("/"," /"));
                                // ignore the first token
                                st.nextElement();
                                int index = Integer.parseInt(st.nextToken());
                                String name = st.nextToken();
                                if(encoding == null)
                                    log.warn("Unable to get character encoding.  Encoding defintion found without /Encoding line.");
                                else
                                    encoding.addCharacterEncoding(index, name.replace("/", ""));
                            }
                        }
                        // according to the pdf reference, all font matrices should be same, except for type 3 fonts.
                        // but obviously there are some type1 fonts with different matrix values, see pdf sample
                        // attached to PDFBOX-935
View Full Code Here

                       
                        // this section parses the font program stream searching for a /Encoding entry
                        // if it contains an array of values a Type1Encoding will be returned
                        // if it encoding contains an encoding name the corresponding Encoding will be returned
                        String line = "";
                        Type1Encoding encoding = null;
                        while( (line = in.readLine()) != null)
                        {
                            if (line.startsWith("currentdict end")) {
                                if (encoding != null)
                                    fontEncoding = encoding;
                                break;
                            }
                            if (line.startsWith("/Encoding"))
                            {
                                if(line.endsWith("array"))
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    int arraySize = Integer.parseInt(st.nextToken());
                                    encoding = new Type1Encoding(arraySize);
                                }
                                // if there is already an encoding, we don't need to
                                // assign another one
                                else if (fontEncoding == null)
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    String type1Encoding = st.nextToken();
                                    fontEncoding =
                                        EncodingManager.INSTANCE.getEncoding(
                                                COSName.getPDFName(type1Encoding));
                                    break;
                                }
                            }
                            else if (line.startsWith("dup")) {
                                StringTokenizer st = new StringTokenizer(line);
                                // ignore the first token
                                st.nextElement();
                                int index = Integer.parseInt(st.nextToken());
                                String name = st.nextToken();
                                encoding.addCharacterEncoding(index, name.replace("/", ""));
                            }
                        }
                        in.close();
                    }
                    catch(IOException exception)
View Full Code Here

                   
                    // this section parses the font program stream searching for a /Encoding entry
                    // if it contains an array of values a Type1Encoding will be returned
                    // if it encoding contains an encoding name the corresponding Encoding will be returned
                    String line = "";
                    Type1Encoding encoding = null;
                    while( (line = in.readLine()) != null)
                    {
                        if (extractEncoding)
                        {
                            if (line.startsWith("currentdict end")) {
                                if (encoding != null)
                                    setFontEncoding(encoding);
                                break;
                            }
                            if (line.startsWith("/Encoding"))
                            {
                                if(line.contains("array"))
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    int arraySize = Integer.parseInt(st.nextToken());
                                    encoding = new Type1Encoding(arraySize);
                                }
                                // if there is already an encoding, we don't need to
                                // assign another one
                                else if (getFontEncoding() == null)
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    String type1Encoding = st.nextToken();
                                    setFontEncoding(
                                        EncodingManager.INSTANCE.getEncoding(
                                                COSName.getPDFName(type1Encoding)));
                                    break;
                                }
                            }
                            else if (line.startsWith("dup")) {
                                StringTokenizer st = new StringTokenizer(line.replaceAll("/"," /"));
                                // ignore the first token
                                st.nextElement();
                                try
                                {
                                    int index = Integer.parseInt(st.nextToken());
                                    String name = st.nextToken();
                                    if(encoding == null)
                                    {
                                        log.warn("Unable to get character encoding. Encoding defintion found without /Encoding line.");
                                    }
                                    else
                                    {
                                        encoding.addCharacterEncoding(index, name.replace("/", ""));
                                    }
                                }
                                catch(NumberFormatException exception)
                                {
                                    // there are (tex?)-some fonts containing postscript code like the following,
View Full Code Here

                   
                    // this section parses the font program stream searching for a /Encoding entry
                    // if it contains an array of values a Type1Encoding will be returned
                    // if it encoding contains an encoding name the corresponding Encoding will be returned
                    String line = "";
                    Type1Encoding encoding = null;
                    while( (line = in.readLine()) != null)
                    {
                        if (extractEncoding)
                        {
                            if (line.startsWith("currentdict end")) {
                                if (encoding != null)
                                    setFontEncoding(encoding);
                                break;
                            }
                            if (line.startsWith("/Encoding"))
                            {
                                if(line.contains("array"))
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    int arraySize = Integer.parseInt(st.nextToken());
                                    encoding = new Type1Encoding(arraySize);
                                }
                                // if there is already an encoding, we don't need to
                                // assign another one
                                else if (getFontEncoding() == null)
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    String type1Encoding = st.nextToken();
                                    setFontEncoding(
                                        EncodingManager.INSTANCE.getEncoding(
                                                COSName.getPDFName(type1Encoding)));
                                    break;
                                }
                            }
                            else if (line.startsWith("dup")) {
                                StringTokenizer st = new StringTokenizer(line.replaceAll("/"," /"));
                                // ignore the first token
                                st.nextElement();
                                try
                                {
                                    int index = Integer.parseInt(st.nextToken());
                                    String name = st.nextToken();
                                    if(encoding == null)
                                    {
                                        log.warn("Unable to get character encoding. " +
                                                "Encoding definition found without /Encoding line.");
                                    }
                                    else
                                    {
                                        encoding.addCharacterEncoding(index, name.replace("/", ""));
                                    }
                                }
                                catch(NumberFormatException exception)
                                {
                                    // there are (tex?)-some fonts containing postscript code like the following,
View Full Code Here

                   
                    // this section parses the font program stream searching for a /Encoding entry
                    // if it contains an array of values a Type1Encoding will be returned
                    // if it encoding contains an encoding name the corresponding Encoding will be returned
                    String line = "";
                    Type1Encoding encoding = null;
                    while( (line = in.readLine()) != null)
                    {
                        if (extractEncoding)
                        {
                            if (line.startsWith("currentdict end")) {
                                if (encoding != null)
                                    setFontEncoding(encoding);
                                break;
                            }
                            if (line.startsWith("/Encoding"))
                            {
                                if(line.contains("array"))
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    int arraySize = Integer.parseInt(st.nextToken());
                                    encoding = new Type1Encoding(arraySize);
                                }
                                // if there is already an encoding, we don't need to
                                // assign another one
                                else if (getFontEncoding() == null)
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    String type1Encoding = st.nextToken();
                                    setFontEncoding(
                                        EncodingManager.INSTANCE.getEncoding(
                                                COSName.getPDFName(type1Encoding)));
                                    break;
                                }
                            }
                            else if (line.startsWith("dup")) {
                                StringTokenizer st = new StringTokenizer(line.replaceAll("/"," /"));
                                // ignore the first token
                                st.nextElement();
                                try
                                {
                                    int index = Integer.parseInt(st.nextToken());
                                    String name = st.nextToken();
                                    if(encoding == null)
                                    {
                                        log.warn("Unable to get character encoding. " +
                                                "Encoding definition found without /Encoding line.");
                                    }
                                    else
                                    {
                                        encoding.addCharacterEncoding(index, name.replace("/", ""));
                                    }
                                }
                                catch(NumberFormatException exception)
                                {
                                    // there are (tex?)-some fonts containing postscript code like the following,
View Full Code Here

                       
                        // this section parses the font program stream searching for a /Encoding entry
                        // if it contains an array of values a Type1Encoding will be returned
                        // if it encoding contains an encoding name the corresponding Encoding will be returned
                        String line = "";
                        Type1Encoding encoding = null;
                        while( (line = in.readLine()) != null)
                        {
                            if (line.startsWith("currentdict end")) {
                                if (encoding != null)
                                    fontEncoding = encoding;
                                break;
                            }
                            if (line.startsWith("/Encoding"))
                            {
                                if(line.contains("array"))
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    int arraySize = Integer.parseInt(st.nextToken());
                                    encoding = new Type1Encoding(arraySize);
                                }
                                // if there is already an encoding, we don't need to
                                // assign another one
                                else if (fontEncoding == null)
                                {
                                    StringTokenizer st = new StringTokenizer(line);
                                    // ignore the first token
                                    st.nextElement();
                                    String type1Encoding = st.nextToken();
                                    fontEncoding =
                                        EncodingManager.INSTANCE.getEncoding(
                                                COSName.getPDFName(type1Encoding));
                                    break;
                                }
                            }
                            else if (line.startsWith("dup")) {
                                StringTokenizer st = new StringTokenizer(line.replaceAll("/"," /"));
                                // ignore the first token
                                st.nextElement();
                                int index = Integer.parseInt(st.nextToken());
                                String name = st.nextToken();
                                if(encoding == null)
                                    log.warn("Unable to get character encoding.  Encoding defintion found without /Encoding line.");
                                else
                                    encoding.addCharacterEncoding(index, name.replace("/", ""));
                            }
                        }
                        in.close();
                    }
                    catch(IOException exception)
View Full Code Here

TOP

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

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.