Package org.pdfbox.cos

Examples of org.pdfbox.cos.COSName


        COSDictionary destRoot = (COSDictionary)destTrailer.getDictionaryObject( COSName.ROOT );

        COSDictionary srcTrailer = source.getTrailer();
        COSDictionary srcRoot = (COSDictionary)srcTrailer.getDictionaryObject( COSName.ROOT );

        COSName openAction = COSName.getPDFName( "OpenAction" );
        if( destRoot.getItem( openAction ) == null )
        {
            COSObject open = (COSObject)srcRoot.getItem( openAction );
            if( open != null )
            {
                destination.addObject( open );
                destRoot.setItem( openAction, open );
            }
        }

        COSName acroForm = COSName.getPDFName( "AcroForm" );
        if( destRoot.getItem( acroForm ) == null )
        {
            COSObject form = (COSObject)srcRoot.getItem( acroForm );
            if( form != null )
            {
View Full Code Here


            Map actuals = new HashMap();
            retval = new COSDictionaryMap( actuals, fonts );
            Iterator fontNames = fonts.keyList().iterator();
            while( fontNames.hasNext() )
            {
                COSName fontName = (COSName)fontNames.next();
                COSDictionary fontDictionary = (COSDictionary)fonts.getDictionaryObject( fontName );
                actuals.put( fontName, PDFontFactory.createFont( fontDictionary ) );
            }
        }
        return retval;
View Full Code Here

    {
        Iterator iter = fonts.keySet().iterator();
        COSDictionary dic = new COSDictionary();
        while( iter.hasNext() )
        {
            COSName name = (COSName)iter.next();
            PDFont font = (PDFont)fonts.get( name );
            dic.setItem( name, font.getCOSObject() );
        }
    }
View Full Code Here

            {
                done = true;
            }
            else
            {
                COSName key = parseCOSName();
                COSBase value = parseCOSDictionaryValue();

                if( value == null )
                {
                    throw new IOException("Bad Dictionary Declaration " + pdfSource );
View Full Code Here

    {
        if( log.isDebugEnabled() )
        {
            log.debug("parseCOSName() " + pdfSource );
        }
        COSName retval = null;
        if( ((char)pdfSource.peek()) != '/')
        {
            throw new IOException("expected='/' actual='" + (char)pdfSource.peek() + "' " + pdfSource );
        }
        // costruisce il nome
View Full Code Here

                COSString string = (COSString)fieldValue;
                setValue( string.getString() );
            }
            else if( fieldValue instanceof COSName )
            {
                COSName name = (COSName)fieldValue;
                setValue( name.getName() );
            }
            else
            {
                throw new IOException( "Uknown field type:" + fieldValue.getClass().getName() );
            }
View Full Code Here

     *
     * @see org.pdfbox.pdmodel.field.PDField#setValue(java.lang.String)
     */
    public void setValue(String value)
    {
        COSName val = COSName.getPDFName(value);
        for (int i = 0; i < subButtons.size(); i++)
        {
            PDRadioButton btn = (PDRadioButton) subButtons.get(i);
            if (btn.representsValue(val))
            {
View Full Code Here

     */
    public static PDFont createFont( COSDictionary dic ) throws IOException
    {
        PDFont retval = null;

        COSName type = (COSName)dic.getDictionaryObject( COSName.TYPE );
        if( !type.equals( COSName.FONT ) )
        {
            throw new IOException( "Cannot create font if /Type is not /Font.  Actual=" +type );
        }

        COSName subType = (COSName)dic.getDictionaryObject( COSName.SUBTYPE );
        if( subType.equals( COSName.getPDFName( "Type1" ) ) )
        {
            retval = new PDType1Font( dic );
        }
        else if( subType.equals( COSName.getPDFName( "MMType1" ) ) )
        {
            retval = new PDMMType1Font( dic );
        }
        else if( subType.equals( COSName.getPDFName( "TrueType" ) ) )
        {
            retval = new PDTrueTypeFont( dic );
        }
        else if( subType.equals( COSName.getPDFName( "Type3" ) ) )
        {
            retval = new PDType3Font( dic );
        }
        else if( subType.equals( COSName.getPDFName( "Type0" ) ) )
        {
            retval = new PDType0Font( dic );
        }
        else
        {
View Full Code Here

     * @throws IOException if we cannot find the width.
     */
    private float getFontWidthFromAFMFile( int code ) throws IOException
    {
        float retval = 0;
        COSName baseFont = (COSName)font.getDictionaryObject( COSName.BASE_FONT );
        if( baseFont != null )
        {
            FontMetric metric = getAFM( baseFont );
            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 during the encoding.
     */
    public String encode( byte[] c, int offset, int length ) throws IOException
    {
        String retval = new String( c );
        COSName fontSubtype = (COSName)font.getDictionaryObject( COSName.getPDFName( "Subtype" ) );
        if( (fontSubtype.getName().equals( "Type0" ) ||
            fontSubtype.getName().equals( "TrueType" ) ) &&
            font.getDictionaryObject( COSName.getPDFName( "ToUnicode" ) ) != null )
        //if( getDictionaryObject( COSName.getPDFName( "ToUnicode" ) ) != null )
        {
            retval = "";
            COSStream toUnicode = (COSStream)font.getDictionaryObject( COSName.getPDFName( "ToUnicode" ) );
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.