Package org.pdfbox.cos

Examples of org.pdfbox.cos.COSName


     *
     * @throws IOException If there is an error processing this operator.
     */
    public void process(PDFOperator operator, List arguments) throws IOException
    {
        COSName name = (COSName) arguments.get( 0 );

        if (inProcess.contains(name))
        {
            // avoid recursive loop
            return;
        }

        inProcess.add(name);

        try
        {
            //PDResources res = context.getResources();

            Map xobjects = context.getXObjects();
            PDXObject xobject = (PDXObject) xobjects.get(name.getName());

            if(xobject instanceof PDXObjectForm)
            {
                PDXObjectForm form = (PDXObjectForm)xobject;
                COSStream invoke = (COSStream)form.getCOSObject();
View Full Code Here


     * @throws IOException If an error occurs while processing the font.
     */
    public void process(PDFOperator operator, List arguments) throws IOException
    {
        //set parameters from graphics state parameter dictionary
        COSName graphicsName = (COSName)arguments.get( 0 );
        PDExtendedGraphicsState gs = (PDExtendedGraphicsState)context.getGraphicsStates().get( graphicsName.getName() );
        gs.copyIntoGraphicsState( context.getGraphicsState() );
    }
View Full Code Here

        //arguments are in the wrong spot, so we will silently ignore them
        //if there are no arguments
        if( arguments.size() >= 2 )
        {
            //set font and size
            COSName fontName = (COSName)arguments.get( 0 );
            float fontSize = ((COSNumber)arguments.get( 1 ) ).floatValue();
            context.getGraphicsState().getTextState().setFontSize( fontSize );
   
            //old way
            //graphicsState.getTextState().getFont() = (COSObject)stream.getDictionaryObject( fontName );
            //if( graphicsState.getTextState().getFont() == null )
            //{
            //    graphicsState.getTextState().getFont() = (COSObject)graphicsState.getTextState().getFont()
            //                                           Dictionary.getItem( fontName );
            //}
            context.getGraphicsState().getTextState().setFont( (PDFont)context.getFonts().get( fontName.getName() ) );
            if( context.getGraphicsState().getTextState().getFont() == null )
            {
                throw new IOException( "Error: Could not find font(" + fontName + ") in map=" + context.getFonts() );
            }
        }
View Full Code Here

     *
     * @throws IOException If there is no name for the character.
     */
    public COSName getNameFromCharacter( char c ) throws IOException
    {
        COSName name = (COSName)CHARACTER_TO_NAME.get( "" + c );
        if( name == null )
        {
            throw new IOException( "No name for character '" + c + "'" );
        }
        return name;
View Full Code Here

        {
            COSDictionary obj = (COSDictionary)o;
            output.write( COSWriter.DICT_OPEN );
            for (Iterator i = obj.keyList().iterator(); i.hasNext();)
            {
                COSName name = (COSName) i.next();
                COSBase value = obj.getItem(name);
                if (value != null)
                {
                    writeObject( name );
                    output.write( SPACE );

                    writeObject( value );

                    output.write( SPACE );

                }
            }
            output.write( COSWriter.DICT_CLOSE );
            output.write( SPACE );
        }
        else if( o instanceof PDFOperator )
        {
            PDFOperator op = (PDFOperator)o;
            if( op.getOperation().equals( "BI" ) )
            {
                output.write( "BI".getBytes() );
                ImageParameters params = op.getImageParameters();
                COSDictionary dic = params.getDictionary();
                Iterator iter = dic.keyList().iterator();
                while( iter.hasNext() )
                {
                    COSName key = (COSName)iter.next();
                    Object value = dic.getDictionaryObject( key );
                    key.writePDF( output );
                    output.write( SPACE );
                    writeObject( value );
                    output.write( EOL );
                }
                output.write( "ID".getBytes() );
View Full Code Here

        //for a nonsymbolic font, it is StandardEncoding, and for a symbolic font, it
        //is the font�s built-in encoding."

        //so the default base encoding is standardEncoding
        Encoding baseEncoding = new StandardEncoding();
        COSName baseEncodingName = (COSName)encoding.getDictionaryObject( COSName.BASE_ENCODING );

        if( baseEncodingName != null )
        {
            EncodingManager manager = new EncodingManager();
            baseEncoding = manager.getEncoding( baseEncodingName );
        }
        nameToCode.putAll( baseEncoding.nameToCode );
        codeToName.putAll( baseEncoding.codeToName );


        //now replace with the differences.
        COSArray differences = (COSArray)encoding.getDictionaryObject( COSName.DIFFERENCES );
        int currentIndex = -1;
        for( int i=0; differences != null && i<differences.size(); i++ )
        {
            COSBase next = differences.getObject( i );
            if( next instanceof COSNumber )
            {
                currentIndex = ((COSNumber)next).intValue();
            }
            else if( next instanceof COSName )
            {
                COSName name = (COSName)next;
                addCharacterEncoding( currentIndex++, name );
            }
        }
    }
View Full Code Here

        throws CryptographyException, IOException
    {
        Iterator keys = dictionary.keyList().iterator();
        while( keys.hasNext() )
        {
            COSName key = (COSName)keys.next();
            Object value = dictionary.getItem( key );
            //if we are a signature dictionary and contain a Contents entry then
            //we don't decrypt it.
            if( !(key.getName().equals( "Contents" ) &&
                  value instanceof COSString &&
                  potentialSignatures.contains( dictionary )))
            {
                decrypt( value, objNum, genNum );
            }
View Full Code Here

     * @throws IOException If an error occurs while processing the font.
     */
    public void process(PDFOperator operator, List arguments) throws IOException
    {
//      (PDF 1.1) Set color space for stroking operations
        COSName name = (COSName)arguments.get( 0 );
        PDColorSpace cs = null;
        Map colorSpaces = context.getColorSpaces();
        if( colorSpaces != null )
        {
             cs = (PDColorSpace)colorSpaces.get( name.getName() );
        }
        if( cs == null )
        {
            cs = PDColorSpaceFactory.createColorSpace( name );
        }
View Full Code Here

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

     *
     * @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

TOP

Related Classes of org.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.