Package org.pdfbox.cos

Examples of org.pdfbox.cos.COSString


     * does not have one, then it will be taken from the AcroForm.
     * @return The DA element
     */
    private COSString getDefaultAppearance()
    {
        COSString dap = parent.getDefaultAppearance();
        if (dap == null)
        {
            dap = (COSString) acroForm.getDictionary().getDictionaryObject(COSName.getPDFName("DA"));
        }
        return dap;
View Full Code Here


     *
     * @throws IOException If there is an error creating the appearance stream.
     */
    public void setValue(String value) throws IOException
    {
        COSString fieldValue = new COSString(value);
        getDictionary().setItem( COSName.getPDFName( "V" ), fieldValue );
        getDictionary().setItem( COSName.getPDFName( "DV" ), fieldValue );
    }
View Full Code Here

     *
     * @throws IOException If there is an error creating the appearance stream.
     */
    public void setValue(String value) throws IOException
    {
        COSString fieldValue = new COSString(value);
        getDictionary().setItem( COSName.getPDFName( "V" ), fieldValue );
        getDictionary().setItem( COSName.getPDFName( "DV" ), fieldValue );
    }
View Full Code Here

     *
     * @param name The new name for the field.
     */
    public void setName( String name )
    {
        getDictionary().setItem( COSName.getPDFName( "T" ), new COSString( name ) );
    }
View Full Code Here

        int annotFlags = getAnnotationFlags();
        if( fieldValue != null )
        {
            if( fieldValue instanceof COSString )
            {
                COSString string = (COSString)fieldValue;
                setValue( string.getString() );
            }
            else if( fieldValue instanceof COSName )
            {
                COSName name = (COSName)fieldValue;
                setValue( name.getName() );
View Full Code Here

            for (int i = 0; i < fields.size() && retval == null; i++)
            {
                COSDictionary element = (COSDictionary) fields.getObject(i);
                if( element != null )
                {
                    COSString fieldName =
                        (COSString)element.getDictionaryObject( COSName.getPDFName( "T" ) );
                    if( fieldName.getString().equals( name ) )
                    {
                        retval = PDFieldFactory.createField( this, element );
                    }
                }
            }
View Full Code Here

                {
                    COSNumber cosCount = (COSNumber)tokens.get( i-1 );
                    for( int j=0; j<cosCount.intValue(); j++ )
                    {
                        i++;
                        COSString startRange = (COSString)tokens.get( i );
                        i++;
                        COSString endRange = (COSString)tokens.get( i );
                        CodespaceRange range = new CodespaceRange();
                        range.setStart( startRange.getBytes() );
                        range.setEnd( endRange.getBytes() );
                        result.addCodespaceRange( range );
                    }
                }
                else if( op.getOperation().equals( BEGIN_BASE_FONT_CHAR ) )
                {
                    COSNumber cosCount = (COSNumber)tokens.get( i-1 );
                    for( int j=0; j<cosCount.intValue(); j++ )
                    {
                        i++;
                        COSString inputCode = (COSString)tokens.get( i );
                        i++;
                        Object nextToken = tokens.get( i );
                        if( nextToken instanceof COSString )
                        {
                            String value = new String( ((COSString)nextToken).getBytes(), "UTF-16BE" );
                            result.addMapping( inputCode.getBytes(), value );
                        }
                        else if( nextToken instanceof COSName )
                        {
                            result.addMapping( inputCode.getBytes(), ((COSName)nextToken).getName() );
                        }
                        else
                        {
                            throw new IOException( "Error parsing CMap beginbfchar, expected{COSString " +
                                                   "or COSName} and not " + nextToken );
                        }
                    }
                }
               else if( op.getOperation().equals( BEGIN_BASE_FONT_RANGE ) )
                {
                    COSNumber cosCount = (COSNumber)tokens.get( i-1 );
                    for( int j=0; j<cosCount.intValue(); j++ )
                    {
                        i++;
                        COSString startCode = (COSString)tokens.get( i );
                        i++;
                        COSString endCode = (COSString)tokens.get( i );
                        i++;
                        Object nextToken = tokens.get( i );

                        byte[] startBytes = startCode.getBytes();
                        byte[] endBytes = endCode.getBytes();
                        byte[] tokenBytes = ((COSString)nextToken).getBytes();

                        String value = null;

                        while( !equals( startBytes, endBytes ) )
View Full Code Here

        {
            info.removeItem( key );
        }
        else
        {
            info.setItem( key, new COSString( value ) );
        }
    }
View Full Code Here

     * @return The value if it exists or null.
     */
    private Calendar getDateItem( COSName key )
    {
        Calendar retval = null;
        COSString value = (COSString)info.getDictionaryObject( key );
        if( value != null )
        {
            //lets first verify that the string is valid.
            String strValue = value.getString();
            int index = 0;
            if( strValue.startsWith( "D:" ) )
            {
                index = 2;
            }
            boolean validDate = true;
            for( int i=index; i<strValue.length(); i++ )
            {
                validDate = validDate && Character.isDigit( strValue.charAt( i ) );
            }
            if( validDate )
            {
                DateConverter converter = new DateConverter();
                try
                {
                    retval = converter.toCalendar( value.getString() );
                }
                catch( IOException e )
                {
                    retval = null;
                }
View Full Code Here

            info.removeItem( key );
        }
        else
        {
            DateConverter converter = new DateConverter();
            info.setItem( key, new COSString( converter.toString( value ) ) );
        }
    }
View Full Code Here

TOP

Related Classes of org.pdfbox.cos.COSString

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.