Package org.pdfbox.cos

Examples of org.pdfbox.cos.COSBase


        }
        Iterator iter = colorants.keyList().iterator();
        while( iter.hasNext() )
        {
            COSName name = (COSName)iter.next();
            COSBase value = colorants.getDictionaryObject( name );
            actuals.put( name.getName(), PDColorSpaceFactory.createColorSpace( value ) );
        }
        return new COSDictionaryMap( actuals, colorants );
    }
View Full Code Here


     *
     * @throws IOException If there is an error getting the alternate color space.
     */
    public PDColorSpace getAlternateColorSpace() throws IOException
    {
        COSBase alternate = array.getObject( 2 );
        return PDColorSpaceFactory.createColorSpace( alternate );
    }
View Full Code Here

     *
     * @param cs The alternate color space.
     */
    public void setAlternateColorSpace( PDColorSpace cs )
    {
        COSBase space = null;
        if( cs != null )
        {
            space = cs.getCOSObject();
        }
        array.set( 2, space );
View Full Code Here

     *
     * @throws IOException If there is an error creating the destination.
     */
    public PDDestination getDestination() throws IOException
    {
        COSBase base = getDictionary().getDictionaryObject( COSName.DEST );
        PDDestination retval = PDDestination.create( base );
           
        return retval;
    }
View Full Code Here

     *
     * @throws IOException If there is an error getting the alternate color spaces.
     */
    public List getAlternateColorSpaces() throws IOException
    {
        COSBase alternate = stream.getStream().getDictionaryObject( COSName.getPDFName( "Alternate" ) );
        COSArray alternateArray = null;
        if( alternate == null )
        {
            alternateArray = new COSArray();
            int numComponents = getNumberOfComponents();
            String csName = null;
            if( numComponents == 1 )
            {
                csName = PDDeviceGray.NAME;
            }
            else if( numComponents == 3 )
            {
                csName = PDDeviceRGB.NAME;
            }
            else if( numComponents == 4 )
            {
                csName = PDDeviceCMYK.NAME;
            }
            else
            {
                throw new IOException( "Unknown colorspace number of components:" + numComponents );
            }
            alternateArray.add( COSName.getPDFName( csName ) );
        }
        else
        {
            if( alternate instanceof COSArray )
            {
                alternateArray = (COSArray)alternate;
            }
            else if( alternate instanceof COSName )
            {
                alternateArray = new COSArray();
                alternateArray.add( alternate );
            }
            else
            {
                throw new IOException( "Error: expected COSArray or COSName and not " +
                    alternate.getClass().getName() );
            }
        }
        List retval = new ArrayList();
        for( int i=0; i<alternateArray.size(); i++ )
        {
View Full Code Here

     * @throws IOException If there is an error getting the font.
     */
    public PDFont getFont() throws IOException
    {
        PDFont retval = null;
        COSBase font = fontSetting.get( 0 );
        if( font instanceof COSDictionary )
        {
            retval = PDFontFactory.createFont( (COSDictionary)font );
        }
        return retval;
View Full Code Here

     *
     * @param wp The whitepoint tristimulus.
     */
    public void setWhitepoint( PDTristimulus wp )
    {
        COSBase wpArray = wp.getCOSObject();
        if( wpArray != null )
        {
            dictionary.setItem( COSName.getPDFName( "WhitePoint" ), wpArray );
        }
    }
View Full Code Here

     * @param bp The BlackPoint tristimulus.
     */
    public void setBlackPoint( PDTristimulus bp )
    {

        COSBase bpArray = null;
        if( bp != null )
        {
            bpArray = bp.getCOSObject();
        }
        dictionary.setItem( COSName.getPDFName( "BlackPoint" ), bpArray );
View Full Code Here

     * @throws IOException If there is error creating the base color space.
     */
    public PDColorSpace getBaseColorSpace() throws IOException
    {
        PDColorSpace retval = null;
        COSBase base = array.getObject( 1 );
        if( base instanceof COSName )
        {
            retval = PDColorSpaceFactory.createColorSpace( base );
        }
        else
View Full Code Here

        return (data[componentNumber*numberOfComponents + lookupIndex]+256)%256;
    }

    private byte[] getLookupData() throws IOException
    {
        COSBase lookupTable = array.getObject( 3 );
        byte[] data = null;
        if( lookupTable instanceof COSString )
        {
            data = ((COSString)lookupTable).getBytes();
        }
View Full Code Here

TOP

Related Classes of org.pdfbox.cos.COSBase

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.