Package org.apache.pdfbox.cos

Examples of org.apache.pdfbox.cos.COSName


     */
    protected FontMetric getAFM() throws IOException
    {
        if(afm==null){
          COSBase baseFont = font.getDictionaryObject( COSName.BASE_FONT );
            COSName name = null;
            if( baseFont instanceof COSName )
            {
                name = (COSName)baseFont;
            }
            else if( baseFont instanceof COSString )
View Full Code Here


                        COSStream encodingStream = (COSStream)encoding;
                        parseCmap( null, encodingStream.getUnfilteredStream(), null );
                    }
                    else if( isType0Font() && encoding instanceof COSName )
                    {
                        COSName encodingName = (COSName)encoding;
                        cmap = cmapObjects.get( encodingName );
                        if( cmap == null )
                        {
                            String cmapName = encodingName.getName();
                            String resourceRoot = "Resources/cmap/";
                            String resourceName = resourceRoot + cmapName;
                            parseCmap( resourceRoot, ResourceLoader.loadResource( resourceName ), encodingName );
                            if( cmap == null && !encodingName.getName().equals( COSName.IDENTITY_H.getName() ) )
                            {
                                throw new IOException( "Error: Could not find predefined " +
                                "CMAP file for '" + encodingName.getName() + "'" );
                            }
                        }
                    }
                    else if( encoding instanceof COSName ||
                             encoding instanceof COSDictionary )
View Full Code Here

            {
                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 );
View Full Code Here

    {
        //This whole section of code needs to be replaced with an actual
        //type1 font parser!!


        COSName retvalue = null;
        //recuperer le programme de fonte dans son stream qui doit se trouver
        //dans le flux r�f�renc� par � la cl� FileFont lui m�me situ� dans
        //le dictionnaire associ� � /FontDescriptor du dictionnaire de type /Font courrant
        //get the font program in the stream which should be located in
         //the /FileFont Stream object himself in the /FontDescriptior of the current
        //font dictionary
        COSDictionary fontDescriptor = (COSDictionary) font.getDictionaryObject(
            COSName.FONT_DESC);
        if( fontDescriptor != null )
        {
            COSStream fontFile = (COSStream) fontDescriptor.getDictionaryObject(
                COSName.FONT_FILE);
            if( fontFile != null )
            {
                BufferedReader in =
                        new BufferedReader(new InputStreamReader(fontFile.getUnfilteredStream()));
                /**
                 * this section parse the FileProgram stream searching for a /Encoding entry
                 * the research stop if the entry "currentdict end" is reach or after 100 lignes
                 */
                StringTokenizer st = null;
                boolean found = false;
                String line = "";
                String key = null;
                for( int i = 0; null!=( line = in.readLine() ) &&
                                i < 40  &&
                                !line.equals("currentdict end")
                                && !found; i++)
                {
                    st = new StringTokenizer(line);
                    if( st.hasMoreTokens() )
                    {
                        key = st.nextToken();
                        if(key.equals("/Encoding") && st.hasMoreTokens() )
                        {
                            COSName value = COSName.getPDFName( st.nextToken() );
                            found = true;
                            if( value.equals( COSName.MAC_ROMAN_ENCODING ) ||
                                value.equals( COSName.PDF_DOC_ENCODING ) ||
                                value.equals( COSName.STANDARD_ENCODING ) ||
                                value.equals( COSName.WIN_ANSI_ENCODING ) )
                            {
                                //value is expected to be one of the encodings
                                //ie. StandardEncoding,WinAnsiEncoding,MacRomanEncoding,PDFDocEncoding
                                retvalue = value;
                            }
View Full Code Here

     * @return a PDFont instance, based on the SubType entry of the dictionary
     * @throws IOException
     */
    public static PDFont createFont(COSDictionary dictionary) throws IOException
    {
        COSName type = dictionary.getCOSName(COSName.TYPE, COSName.FONT);
        if (!COSName.FONT.equals(type))
        {
            throw new IOException("Expected 'Font' dictionary but found '" + type.getName() + "'");
        }

        COSName subType = dictionary.getCOSName(COSName.SUBTYPE);
        if (COSName.TYPE1.equals(subType))
        {
            COSBase fd = dictionary.getDictionaryObject(COSName.FONT_DESC);
            if (fd != null && fd instanceof COSDictionary)
            {
View Full Code Here

     * @throws IOException
     */
    static PDCIDFont createDescendantFont(COSDictionary dictionary, PDType0Font parent)
            throws IOException
    {
        COSName type = dictionary.getCOSName(COSName.TYPE, COSName.FONT);
        if (!COSName.FONT.equals(type))
        {
            throw new IllegalArgumentException("Expected 'Font' dictionary but found '" + type.getName() + "'");
        }

        COSName subType = dictionary.getCOSName(COSName.SUBTYPE);
        if (COSName.CID_FONT_TYPE0.equals(subType))
        {
            return new PDCIDFontType0(dictionary, parent);
        }
        else if (COSName.CID_FONT_TYPE2.equals(subType))
View Full Code Here

                streamParser.parse();
                tokens = streamParser.getTokens();
            }

            int setFontIndex = tokens.indexOf(Operator.getOperator("Tf"));
            COSName cosFontName = (COSName) tokens.get(setFontIndex - 2);
            retval = streamResources.getFont(cosFontName);
            if (retval == null)
            {
                retval = formResources.getFont(cosFontName);
                streamResources.put(cosFontName, retval);
View Full Code Here

        ByteArrayOutputStream os = new ByteArrayOutputStream();
        List<COSName> filters = getFilters();
        boolean done = false;
        for (int i = 0; i < filters.size() && !done; i++)
        {
            COSName nextFilter = filters.get(i);
            if (stopFilters.contains(nextFilter.getName()))
            {
                done = true;
            }
            else
            {
View Full Code Here

    {
        List<COSName> retval = null;
        COSBase filters = stream.getFilters();
        if (filters instanceof COSName)
        {
            COSName name = (COSName) filters;
            retval = new COSArrayList<COSName>(name, name, stream,
                    COSName.FILTER);
        }
        else if (filters instanceof COSArray)
        {
View Full Code Here

    {
        List<String> retval = null;
        COSBase filters = stream.getDictionaryObject(COSName.F_FILTER);
        if (filters instanceof COSName)
        {
            COSName name = (COSName) filters;
            retval = new COSArrayList<String>(name.getName(), name, stream,
                    COSName.F_FILTER);
        }
        else if (filters instanceof COSArray)
        {
            retval = COSArrayList
View Full Code Here

TOP

Related Classes of org.apache.pdfbox.cos.COSName

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.