Examples of COSName


Examples of org.pdfbox.cos.COSName

     *
     * @throws IOException If there is an error getting the AFM object.
     */
    protected FontMetric getAFM() throws IOException
    {
        COSName name = (COSName)font.getDictionaryObject( COSName.BASE_FONT );
        FontMetric result = null;
        if( name != null )
        {
            result = (FontMetric)afmObjects.get( name );
            if( result == null )
View Full Code Here

Examples of org.pdfbox.cos.COSName

     * @throws IOException If there is an error during the encoding.
     */
    public String encode( byte[] c, int offset, int length ) throws IOException
    {
        String retval = null;
        COSName fontSubtype = (COSName)font.getDictionaryObject( COSName.SUBTYPE );
        String fontSubtypeName = fontSubtype.getName();
        if( fontSubtypeName.equals( "Type0" ) ||
            fontSubtypeName.equals( "Type1" ) ||
            fontSubtypeName.equals( "TrueType" ))
        {
            if( cmap == null )
            {
                if( font.getDictionaryObject( COSName.TO_UNICODE ) != null )
                {
                    COSStream toUnicode = (COSStream)font.getDictionaryObject( COSName.TO_UNICODE );
                    if( toUnicode != null )
                    {
                        parseCmap( toUnicode.getUnfilteredStream(), null );
                    }
                }
                else
                {
                    COSBase encoding = font.getDictionaryObject( COSName.ENCODING );
                    if( encoding instanceof COSStream )
                    {
                        COSStream encodingStream = (COSStream)encoding;
                        parseCmap( encodingStream.getUnfilteredStream(), null );
                    }
                    else if( fontSubtypeName.equals( "Type0" ) &&
                             encoding instanceof COSName )
                    {
                        COSName encodingName = (COSName)encoding;
                        cmap = (CMap)cmapObjects.get( encodingName );
                        if( cmap != null )
                        {
                            cmap = (CMap)cmapObjects.get( encodingName );
                        }
                        else
                        {
                            String cmapName = encodingName.getName();
                            cmapName = performCMAPSubstitution( cmapName );
                            String resourceName = "Resources/cmap/" + cmapName;
                            parseCmap( 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

Examples of org.pdfbox.cos.COSName

            {
                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

Examples of org.pdfbox.cos.COSName

    {
        //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

Examples of org.pdfbox.cos.COSName

     * @return The name of the font.
     */
    public String getFontName()
    {
        String retval = null;
        COSName name = (COSName)dic.getDictionaryObject( COSName.getPDFName( "FontName" ) );
        if( name != null )
        {
            retval = name.getName();
        }
        return retval;
    }
View Full Code Here

Examples of org.pdfbox.cos.COSName

     *
     * @param fontName The new name for the font.
     */
    public void setFontName( String fontName )
    {
        COSName name = null;
        if( fontName != null )
        {
            name = COSName.getPDFName( fontName );
        }
        dic.setItem( COSName.getPDFName( "FontName" ), name );
View Full Code Here

Examples of org.pdfbox.cos.COSName

     * @return The stretch of the font.
     */
    public String getFontStretch()
    {
        String retval = null;
        COSName name = (COSName)dic.getDictionaryObject( COSName.getPDFName( "FontStretch" ) );
        if( name != null )
        {
            retval = name.getName();
        }
        return retval;
    }
View Full Code Here

Examples of org.pdfbox.cos.COSName

     *
     * @param fontStretch The new stretch for the font.
     */
    public void setFontStretch( String fontStretch )
    {
        COSName name = null;
        if( fontStretch != null )
        {
            name = COSName.getPDFName( fontStretch );
        }
        dic.setItem( COSName.getPDFName( "FontStretch" ), name );
View Full Code Here

Examples of org.pdfbox.cos.COSName

        Map actuals = new HashMap();
        retval = new COSDictionaryMap( actuals, fonts );
        Iterator fontNames = fonts.keyList().iterator();
        while( fontNames.hasNext() )
        {
            COSName fontName = (COSName)fontNames.next();
            COSBase font = fonts.getDictionaryObject( fontName );
            //data-000174.pdf contains a font that is a COSArray, looks to be an error in the
            //PDF, we will just ignore entries that are not dictionaries.
            if( font instanceof COSDictionary )
            {
                COSDictionary fontDictionary = (COSDictionary)font;
                actuals.put( fontName.getName(), PDFontFactory.createFont( fontDictionary, fontCache ) );
            }
        }
        return retval;
    }
View Full Code Here

Examples of org.pdfbox.cos.COSName

        Map actuals = new HashMap();
        retval = new COSDictionaryMap( actuals, xobjects );
        Iterator imageNames = xobjects.keyList().iterator();
        while( imageNames.hasNext() )
        {
            COSName objName = (COSName)imageNames.next();
            COSBase cosObject = xobjects.getDictionaryObject(objName);
            PDXObject xobject = PDXObject.createXObject( cosObject );
            if( xobject !=null )
            {    
                actuals.put( objName.getName(), xobject);
            }
        }
        return retval;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.